Merge branch 'Preview4_0' into alpha40_lightreview

# Conflicts:
#	Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl
This commit is contained in:
AzaezelX 2020-11-16 04:23:00 -06:00
commit 1e107ceb94
76 changed files with 682 additions and 297 deletions

View file

@ -238,6 +238,11 @@ bool Trigger::castRay(const Point3F &start, const Point3F &end, RayInfo* info)
DECLARE_STRUCT( Polyhedron ); DECLARE_STRUCT( Polyhedron );
IMPLEMENT_STRUCT( Polyhedron, Polyhedron,, IMPLEMENT_STRUCT( Polyhedron, Polyhedron,,
"" ) "" )
FIELD(mPointList, pointList, 1, "")
FIELD(mPlaneList, planeList, 1, "")
FIELD(mEdgeList, edgeList, 1, "")
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
ConsoleType(floatList, TypeTriggerPolyhedron, Polyhedron, "") ConsoleType(floatList, TypeTriggerPolyhedron, Polyhedron, "")

View file

@ -41,7 +41,7 @@ class GuiSpeedometerHud : public GuiBitmapCtrl
F32 mMaxAngle; ///< Max pos of needle F32 mMaxAngle; ///< Max pos of needle
F32 mMinAngle; ///< Min pos of needle F32 mMinAngle; ///< Min pos of needle
Point2F mCenter; ///< Center of needle rotation Point2F mCenter; ///< Center of needle rotation
LinearColorF mColor; ///< Needle Color LinearColorF mNeedleColor; ///< Needle Color
F32 mNeedleLength; F32 mNeedleLength;
F32 mNeedleWidth; F32 mNeedleWidth;
F32 mTailLength; F32 mTailLength;
@ -103,7 +103,7 @@ GuiSpeedometerHud::GuiSpeedometerHud()
mNeedleWidth = 3; mNeedleWidth = 3;
mNeedleLength = 10; mNeedleLength = 10;
mTailLength = 5; mTailLength = 5;
mColor.set(1,0,0,1); mNeedleColor.set(1,0,0,1);
} }
void GuiSpeedometerHud::initPersistFields() void GuiSpeedometerHud::initPersistFields()
@ -122,7 +122,7 @@ void GuiSpeedometerHud::initPersistFields()
"Angle (in radians) of the needle when the Vehicle speed is >= maxSpeed. " "Angle (in radians) of the needle when the Vehicle speed is >= maxSpeed. "
"An angle of 0 points right, 90 points up etc)." ); "An angle of 0 points right, 90 points up etc)." );
addField("color", TypeColorF, Offset( mColor, GuiSpeedometerHud ), addField("color", TypeColorF, Offset( mNeedleColor, GuiSpeedometerHud ),
"Color of the needle" ); "Color of the needle" );
addField("center", TypePoint2F, Offset( mCenter, GuiSpeedometerHud ), addField("center", TypePoint2F, Offset( mCenter, GuiSpeedometerHud ),
@ -210,7 +210,7 @@ void GuiSpeedometerHud::onRender(Point2I offset, const RectI &updateRect)
GFX->setTexture(0, NULL); GFX->setTexture(0, NULL);
// Render the needle // Render the needle
PrimBuild::color4f(mColor.red, mColor.green, mColor.blue, mColor.alpha); PrimBuild::color4f(mNeedleColor.red, mNeedleColor.green, mNeedleColor.blue, mNeedleColor.alpha);
PrimBuild::begin(GFXLineStrip, 5); PrimBuild::begin(GFXLineStrip, 5);
for(int k=0; k<5; k++){ for(int k=0; k<5; k++){
rotMatrix.mulP(vertList[k]); rotMatrix.mulP(vertList[k]);

View file

@ -253,13 +253,13 @@ DefineEngineMethod(afxEffectGroupData, reset, void, (),,
object->reloadReset(); object->reloadReset();
} }
DefineEngineMethod(afxEffectGroupData, addEffect, void, (afxEffectBaseData* effect),, DefineEngineMethod(afxEffectGroupData, pushEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to an effect-group.\n\n" "Adds an effect (wrapper or group) to an effect-group.\n\n"
"@ingroup AFX") "@ingroup AFX")
{ {
if (!effect) if (!effect)
{ {
Con::errorf("afxEffectGroupData::addEffect() -- missing afxEffectWrapperData."); Con::errorf("afxEffectGroupData::pushEffect() -- missing afxEffectWrapperData.");
return; return;
} }

View file

@ -216,13 +216,13 @@ DefineEngineMethod(afxEffectronData, reset, void, (),,
object->reloadReset(); object->reloadReset();
} }
DefineEngineMethod(afxEffectronData, addEffect, void, (afxEffectBaseData* effect),, DefineEngineMethod(afxEffectronData, pushEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to an effectron's phase.\n\n" "Adds an effect (wrapper or group) to an effectron's phase.\n\n"
"@ingroup AFX") "@ingroup AFX")
{ {
if (!effect) if (!effect)
{ {
Con::errorf("afxEffectronData::addEffect() -- missing afxEffectWrapperData."); Con::errorf("afxEffectronData::pushEffect() -- missing afxEffectWrapperData.");
return; return;
} }

View file

@ -460,7 +460,7 @@ DefineEngineMethod(afxMagicSpellData, reset, void, (),,
object->reloadReset(); object->reloadReset();
} }
DefineEngineMethod(afxMagicSpellData, addCastingEffect, void, (afxEffectBaseData* effect),, DefineEngineMethod(afxMagicSpellData, pushCastingEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's casting phase.\n\n" "Adds an effect (wrapper or group) to a spell's casting phase.\n\n"
"@ingroup AFX") "@ingroup AFX")
{ {
@ -475,7 +475,7 @@ DefineEngineMethod(afxMagicSpellData, addCastingEffect, void, (afxEffectBaseData
object->mCasting_fx_list.push_back(effect); object->mCasting_fx_list.push_back(effect);
} }
DefineEngineMethod(afxMagicSpellData, addLaunchEffect, void, (afxEffectBaseData* effect),, DefineEngineMethod(afxMagicSpellData, pushLaunchEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's launch phase.\n\n" "Adds an effect (wrapper or group) to a spell's launch phase.\n\n"
"@ingroup AFX") "@ingroup AFX")
@ -491,7 +491,7 @@ DefineEngineMethod(afxMagicSpellData, addLaunchEffect, void, (afxEffectBaseData*
object->mLaunch_fx_list.push_back(effect); object->mLaunch_fx_list.push_back(effect);
} }
DefineEngineMethod(afxMagicSpellData, addDeliveryEffect, void, (afxEffectBaseData* effect),, DefineEngineMethod(afxMagicSpellData, pushDeliveryEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's delivery phase.\n\n" "Adds an effect (wrapper or group) to a spell's delivery phase.\n\n"
"@ingroup AFX") "@ingroup AFX")
@ -507,7 +507,7 @@ DefineEngineMethod(afxMagicSpellData, addDeliveryEffect, void, (afxEffectBaseDat
object->mDelivery_fx_list.push_back(effect); object->mDelivery_fx_list.push_back(effect);
} }
DefineEngineMethod(afxMagicSpellData, addImpactEffect, void, (afxEffectBaseData* effect),, DefineEngineMethod(afxMagicSpellData, pushImpactEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's impact phase.\n\n" "Adds an effect (wrapper or group) to a spell's impact phase.\n\n"
"@ingroup AFX") "@ingroup AFX")
@ -523,7 +523,7 @@ DefineEngineMethod(afxMagicSpellData, addImpactEffect, void, (afxEffectBaseData*
object->mImpact_fx_list.push_back(effect); object->mImpact_fx_list.push_back(effect);
} }
DefineEngineMethod(afxMagicSpellData, addLingerEffect, void, (afxEffectBaseData* effect),, DefineEngineMethod(afxMagicSpellData, pushLingerEffect, void, (afxEffectBaseData* effect),,
"Adds an effect (wrapper or group) to a spell's linger phase.\n\n" "Adds an effect (wrapper or group) to a spell's linger phase.\n\n"
"@ingroup AFX") "@ingroup AFX")

View file

@ -297,12 +297,12 @@ void afxPhraseEffectData::gather_cons_defs(Vector<afxConstraintDef>& defs)
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
DefineEngineMethod( afxPhraseEffectData, addEffect, void, ( afxEffectBaseData* effectData ),, DefineEngineMethod( afxPhraseEffectData, pushEffect, void, ( afxEffectBaseData* effectData ),,
"Add a child effect to a phrase effect datablock. Argument can be an afxEffectWrappperData or an afxEffectGroupData.\n" ) "Add a child effect to a phrase effect datablock. Argument can be an afxEffectWrappperData or an afxEffectGroupData.\n" )
{ {
if (!effectData) if (!effectData)
{ {
Con::errorf("afxPhraseEffectData::addEffect() -- failed to resolve effect datablock."); Con::errorf("afxPhraseEffectData::pushEffect() -- failed to resolve effect datablock.");
return; return;
} }

View file

@ -26,6 +26,7 @@
namespace Con namespace Con
{ {
/* Consumer Callback is not defined as EngineType yet, until then we have to define these methods directly.
DefineNewEngineFunction(AddConsumer, void, (ConsumerCallback cb), , "") DefineNewEngineFunction(AddConsumer, void, (ConsumerCallback cb), , "")
{ {
addConsumer(cb); addConsumer(cb);
@ -35,6 +36,17 @@ namespace Con
{ {
removeConsumer(cb); removeConsumer(cb);
} }
*/
TORQUE_API void fnAddConsumer(ConsumerCallback cb)
{
addConsumer(cb);
}
TORQUE_API void fnRemoveConsumer(ConsumerCallback cb)
{
removeConsumer(cb);
}
DefineNewEngineFunction(GetConsoleString, String, (String name),, "") DefineNewEngineFunction(GetConsoleString, String, (String name),, "")
{ {
@ -75,4 +87,4 @@ namespace Con
{ {
setBoolVariable(StringTable->insert(name), value); setBoolVariable(StringTable->insert(name), value);
} }
} }

View file

@ -28,16 +28,6 @@ DefineNewEngineMethod(SimObject, RegisterObject, bool, (),,"")
return object->registerObject(); return object->registerObject();
} }
DefineNewEngineMethod(SimObject, GetField, String, (String fieldName, String arrayIndex),, "")
{
return object->getDataField(StringTable->insert(fieldName), StringTable->insert(arrayIndex));
}
DefineNewEngineMethod(SimObject, SetField, void, (String fieldName, String arrayIndex, String value),, "")
{
object->setDataField(StringTable->insert(fieldName), StringTable->insert(arrayIndex), StringTable->insert(value));
}
DefineNewEngineMethod(SimObject, CopyFrom, void, (SimObject* parent),, "") DefineNewEngineMethod(SimObject, CopyFrom, void, (SimObject* parent),, "")
{ {
if (parent) if (parent)
@ -66,4 +56,4 @@ DefineNewEngineMethod(SimObject, InspectPreApply, void, (), , "")
DefineNewEngineMethod(SimObject, InspectPostApply, void, (), , "") DefineNewEngineMethod(SimObject, InspectPostApply, void, (), , "")
{ {
object->inspectPostApply(); object->inspectPostApply();
} }

View file

@ -2082,7 +2082,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
mNSEntry = Namespace::global()->lookup(fnName); mNSEntry = Namespace::global()->lookup(fnName);
StringStackWrapper args(mCallArgc, mCallArgv); StringStackWrapper args(mCallArgc, mCallArgv);
cRetRes = CInterface::GetCInterface().CallFunction(fnNamespace, fnName, args.argv, args.argc, &cFunctionRes); cRetRes = CInterface::CallFunction(fnNamespace, fnName, args.argv + 1, args.argc - 1, &cFunctionRes);
} }
else if (callType == FuncCallExprNode::MethodCall) else if (callType == FuncCallExprNode::MethodCall)
{ {
@ -2115,7 +2115,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
mNSEntry = NULL; mNSEntry = NULL;
StringStackWrapper args(mCallArgc, mCallArgv); StringStackWrapper args(mCallArgc, mCallArgv);
cRetRes = CInterface::GetCInterface().CallMethod(gEvalState.thisObject, fnName, args.argv, args.argc, &cFunctionRes); cRetRes = CInterface::CallMethod(gEvalState.thisObject, fnName, args.argv + 2, args.argc - 2, &cFunctionRes);
} }
else // it's a ParentCall else // it's a ParentCall
{ {
@ -2181,14 +2181,15 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip)
// ConsoleFunctionType is for any function defined by script. // ConsoleFunctionType is for any function defined by script.
// Any 'callback' type is an engine function that is exposed to script. // Any 'callback' type is an engine function that is exposed to script.
if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType if (cFunctionRes || mNSEntry->mType == Namespace::Entry::ConsoleFunctionType)
|| cFunctionRes)
{ {
ConsoleValue retVal;
ConsoleValueRef ret; ConsoleValueRef ret;
if (cFunctionRes) if (cFunctionRes)
{ {
StringStackConsoleWrapper retVal(1, &cRetRes); retVal.init();
ret = retVal.argv[0]; ret.value = &retVal;
retVal.setStackStringValue(cRetRes);
} }
else if (mNSEntry->mFunctionOffset) else if (mNSEntry->mFunctionOffset)
{ {

View file

@ -30,6 +30,7 @@
#include "console/consoleFunctions.h" #include "console/consoleFunctions.h"
#endif #endif
#include "cinterface/cinterface.h"
#include "core/strings/findMatch.h" #include "core/strings/findMatch.h"
#include "core/strings/stringUnit.h" #include "core/strings/stringUnit.h"
#include "core/strings/unicode.h" #include "core/strings/unicode.h"
@ -2426,6 +2427,10 @@ DefineEngineFunction( isMethod, bool, ( const char* nameSpace, const char* metho
"@return True if the method exists, false if not\n" "@return True if the method exists, false if not\n"
"@ingroup Scripting\n") "@ingroup Scripting\n")
{ {
if (CInterface::isMethod(nameSpace, method)) {
return true;
}
Namespace* ns = Namespace::find( StringTable->insert( nameSpace ) ); Namespace* ns = Namespace::find( StringTable->insert( nameSpace ) );
Namespace::Entry* nse = ns->lookup( StringTable->insert( method ) ); Namespace::Entry* nse = ns->lookup( StringTable->insert( method ) );
if( !nse ) if( !nse )

View file

@ -284,6 +284,26 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
}; \ }; \
ConsoleType ## type gConsoleType ## type ## Instance; ConsoleType ## type gConsoleType ## type ## Instance;
#define ConsoleMappedType( typeName, type, consoleType, nativeType, typePrefix ) \
S32 type; \
class ConsoleType##type : public ConsoleBaseType \
{ \
public: \
typedef nativeType T; \
ConsoleType##type() \
: ConsoleBaseType( sizeof( nativeType ), &type, #type ) \
{ \
mTypeInfo = _MAPTYPE< consoleType >(); \
} \
virtual void setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag); \
virtual const char *getData(void *dptr, const EnumTable *tbl, BitSet32 flag ); \
virtual const char *getTypeClassName() { return #typeName ; } \
virtual void *getNativeVariable() { T* var = new T; return (void*)var; } \
virtual void deleteNativeVariable(void* var) { T* nativeVar = reinterpret_cast<T*>(var); delete nativeVar; } \
virtual StringTableEntry getTypePrefix( void ) const { return StringTable->insert( typePrefix ); } \
}; \
ConsoleType ## type gConsoleType ## type ## Instance;
#define ImplementConsoleTypeCasters( type, nativeType ) \ #define ImplementConsoleTypeCasters( type, nativeType ) \
const char *castConsoleTypeToString( _ConsoleConstType< nativeType >::ConstType &arg ) { return Con::getData(type, const_cast< nativeType* >( &arg ), 0); } \ const char *castConsoleTypeToString( _ConsoleConstType< nativeType >::ConstType &arg ) { return Con::getData(type, const_cast< nativeType* >( &arg ), 0); } \
bool castConsoleTypeFromString( nativeType &arg, const char *str ) { Con::setData(type, const_cast< nativeType* >( &arg ), 0, 1, &str); return true; } \ bool castConsoleTypeFromString( nativeType &arg, const char *str ) { Con::setData(type, const_cast< nativeType* >( &arg ), 0, 1, &str); return true; } \

View file

@ -104,20 +104,6 @@ namespace engineAPI {
extern bool gIsInitialized; extern bool gIsInitialized;
} }
//FIXME: this allows const char* to be used as a struct field type
// Temp support for allowing const char* to remain in the API functions as long as we
// still have the console system around. When that is purged, these definitions should
// be deleted and all const char* uses be replaced with String.
template<> struct EngineTypeTraits< const char* > : public EngineTypeTraits< String > {};
template<> inline const EngineTypeInfo* TYPE< const char* >() { return TYPE< String >(); }
/// @name Marshalling /// @name Marshalling
/// ///
/// Functions for converting to/from string-based data representations. /// Functions for converting to/from string-based data representations.
@ -349,10 +335,9 @@ template<typename T> struct _EngineTrampoline {
template< typename R, typename ...ArgTs > template< typename R, typename ...ArgTs >
struct _EngineTrampoline< R( ArgTs ... ) > struct _EngineTrampoline< R( ArgTs ... ) >
{ {
typedef std::tuple<ArgTs ...> Args; template<typename T> using AVT = typename EngineTypeTraits<T>::ArgumentValueType;
std::tuple<ArgTs ...> argT; typedef fixed_tuple<AVT<ArgTs> ...> Args;
typedef fixed_tuple<ArgTs ...> FixedArgs; Args argT;
fixed_tuple<ArgTs ...> fixedArgT;
}; };
template< typename T > template< typename T >
@ -370,21 +355,21 @@ struct _EngineFunctionTrampoline< R(ArgTs...) > : public _EngineFunctionTrampoli
{ {
private: private:
using Super = _EngineFunctionTrampolineBase< R(ArgTs...) >; using Super = _EngineFunctionTrampolineBase< R(ArgTs...) >;
using ArgsType = typename Super::Args; using SelfType = _EngineFunctionTrampoline< R(ArgTs...) >;
using FixedArgsType = typename Super::FixedArgs; using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args;
template<size_t ...> struct Seq {}; template<size_t ...> struct Seq {};
template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {}; template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
template<size_t ...I> struct Gens<0, I...>{ typedef Seq<I...> type; }; template<size_t ...I> struct Gens<0, I...>{ typedef Seq<I...> type; };
template<size_t I>
static typename fixed_tuple_element<I, fixed_tuple<ArgTs...>>::type getAndToType(const ArgsType& args) {
return EngineTypeTraits<typename fixed_tuple_element<I, fixed_tuple<ArgTs...>>::type>::ArgumentToValue(fixed_tuple_accessor<I>::get(args));
}
template<size_t ...I> template<size_t ...I>
static R dispatchHelper(typename Super::FunctionType fn, const ArgsType& args, Seq<I...>) { static R dispatchHelper(typename Super::FunctionType fn, const ArgsType& args, Seq<I...>) {
return R( fn(std::get<I>(args) ...) ); return R( fn(SelfType::template getAndToType<I>(args) ...) );
}
template<size_t ...I>
static R dispatchHelper(typename Super::FunctionType fn, const FixedArgsType& args, Seq<I...>) {
return R( fn(fixed_tuple_accessor<I>::get(args) ...) );
} }
using SeqType = typename Gens<sizeof...(ArgTs)>::type; using SeqType = typename Gens<sizeof...(ArgTs)>::type;
@ -393,11 +378,6 @@ public:
{ {
return dispatchHelper(fn, args, SeqType()); return dispatchHelper(fn, args, SeqType());
} }
static R jmp(typename Super::FunctionType fn, const FixedArgsType& args )
{
return dispatchHelper(fn, args, SeqType());
}
}; };
// Trampolines for engine methods // Trampolines for engine methods
@ -414,21 +394,21 @@ struct _EngineMethodTrampoline< Frame, R(ArgTs ...) > : public _EngineMethodTram
using FunctionType = R( typename Frame::ObjectType*, ArgTs ...); using FunctionType = R( typename Frame::ObjectType*, ArgTs ...);
private: private:
using Super = _EngineMethodTrampolineBase< R(ArgTs ...) >; using Super = _EngineMethodTrampolineBase< R(ArgTs ...) >;
using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args; using SelfType = _EngineMethodTrampoline< Frame, R(ArgTs ...) >;
using FixedArgsType = typename Super::FixedArgs; using ArgsType = typename _EngineMethodTrampolineBase< R(ArgTs ...) >::Args;
template<size_t ...> struct Seq {}; template<size_t ...> struct Seq {};
template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {}; template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
template<size_t ...I> struct Gens<0, I...>{ typedef Seq<I...> type; }; template<size_t ...I> struct Gens<0, I...>{ typedef Seq<I...> type; };
template<size_t ...I> template<size_t I>
static R dispatchHelper(Frame f, const ArgsType& args, Seq<I...>) { static typename fixed_tuple_element<I, fixed_tuple<ArgTs...>>::type getAndToType(const ArgsType& args) {
return R( f._exec(std::get<I>(args) ...) ); return EngineTypeTraits<typename fixed_tuple_element<I, fixed_tuple<ArgTs...>>::type>::ArgumentToValue(fixed_tuple_accessor<I>::get(args));
} }
template<size_t ...I> template<size_t ...I>
static R dispatchHelper(Frame f, const FixedArgsType& args, Seq<I...>) { static R dispatchHelper(Frame f, const ArgsType& args, Seq<I...>) {
return R( f._exec(fixed_tuple_accessor<I>::get(args) ...) ); return R(f._exec(SelfType::template getAndToType<I>(args) ...));
} }
using SeqType = typename Gens<sizeof...(ArgTs)>::type; using SeqType = typename Gens<sizeof...(ArgTs)>::type;
@ -440,14 +420,6 @@ public:
f.object = object; f.object = object;
return dispatchHelper(f, args, SeqType()); return dispatchHelper(f, args, SeqType());
} }
static R jmp( typename Frame::ObjectType* object, const FixedArgsType& args )
{
Frame f;
f.object = object;
return dispatchHelper(f, args, SeqType());
}
}; };
/// @} /// @}
@ -582,7 +554,7 @@ namespace engineAPI{
{ {
return EngineUnmarshallData< IthArgType<index> >()( argv[ startArgc + index ] ); return EngineUnmarshallData< IthArgType<index> >()( argv[ startArgc + index ] );
} else { } else {
return std::get<index + method_offset>(defaultArgs.mArgs); return fixed_tuple_accessor<index + method_offset>::get(defaultArgs.mArgs);
} }
} }
@ -714,7 +686,7 @@ public:
#define DefineEngineFunction( name, returnType, args, defaultArgs, usage ) \ #define DefineEngineFunction( name, returnType, args, defaultArgs, usage ) \
static inline returnType _fn ## name ## impl args; \ static inline returnType _fn ## name ## impl args; \
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ ( _EngineFunctionTrampoline< returnType args >::Args a ) \
{ \ { \
_CHECK_ENGINE_INITIALIZED( name, returnType ); \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \
return EngineTypeTraits< returnType >::ReturnValue( \ return EngineTypeTraits< returnType >::ReturnValue( \
@ -768,7 +740,7 @@ public:
#define _DefineMethodTrampoline( className, name, returnType, args ) \ #define _DefineMethodTrampoline( className, name, returnType, args ) \
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType \
fn ## className ## _ ## name ( className* object, _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::FixedArgs a )\ fn ## className ## _ ## name ( className* object, _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::Args a )\
{ \ { \
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \ _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
return EngineTypeTraits< returnType >::ReturnValue( \ return EngineTypeTraits< returnType >::ReturnValue( \
@ -851,7 +823,7 @@ public:
#define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \ #define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
static inline returnType _fn ## className ## name ## impl args; \ static inline returnType _fn ## className ## name ## impl args; \
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ ( _EngineFunctionTrampoline< returnType args >::Args a ) \
{ \ { \
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \ _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
return EngineTypeTraits< returnType >::ReturnValue( \ return EngineTypeTraits< returnType >::ReturnValue( \
@ -886,25 +858,25 @@ public:
); \ ); \
static inline returnType _fn ## className ## name ## impl args static inline returnType _fn ## className ## name ## impl args
# define DefineEngineStringlyVariadicFunction(name,returnType,minArgs,maxArgs,usage) \ # define DefineEngineStringlyVariadicFunction(name,returnType,minArgs,maxArgs,usage) \
static inline returnType _fn ## name ## impl (SimObject *, S32 argc, ConsoleValueRef *argv); \ static inline returnType _fn ## name ## impl (SimObject *, S32 argc, ConsoleValueRef *argv); \
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
(S32 argc, const char** argv) \ (Vector<const char*>* vec) \
{ \ { \
_CHECK_ENGINE_INITIALIZED( name, returnType ); \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \
StringStackConsoleWrapper args(argc, argv); \ StringStackConsoleWrapper args(vec->size(), vec->address()); \
return EngineTypeTraits< returnType >::ReturnValue( \ return EngineTypeTraits< returnType >::ReturnValue( \
_fn ## name ## impl(NULL, args.count(), args) \ _fn ## name ## impl(NULL, args.count(), args) \
); \ ); \
} \ } \
static _EngineFunctionDefaultArguments< void (S32 argc, const char** argv) > _fn ## name ## DefaultArgs; \ static _EngineFunctionDefaultArguments< void (Vector<const char*>* vec) > _fn ## name ## DefaultArgs; \
static EngineFunctionInfo _fn ## name ## FunctionInfo( \ static EngineFunctionInfo _fn ## name ## FunctionInfo( \
#name, \ #name, \
&_SCOPE<>()(), \ &_SCOPE<>()(), \
usage, \ usage, \
#returnType " " #name "(S32 argc, const char** argv)", \ #returnType " " #name "(Vector<String> args)", \
"fn" #name, \ "fn" #name, \
TYPE< returnType (S32 argc, const char** argv) >(), \ TYPE< returnType (Vector<const char*>* vec) >(), \
&_fn ## name ## DefaultArgs, \ &_fn ## name ## DefaultArgs, \
( void* ) &fn ## name, \ ( void* ) &fn ## name, \
0 \ 0 \
@ -913,34 +885,44 @@ public:
returnType _fn ## name ## impl(SimObject *, S32 argc, ConsoleValueRef *argv) returnType _fn ## name ## impl(SimObject *, S32 argc, ConsoleValueRef *argv)
# define DefineEngineStringlyVariadicMethod(className, name,returnType,minArgs,maxArgs,usage) \ # define DefineEngineStringlyVariadicMethod(className, name,returnType,minArgs,maxArgs,usage) \
static inline returnType _fn ## className ## _ ## name ## impl (className* object, S32 argc, ConsoleValueRef* argv); \ struct _ ## className ## name ## frame \
{ \
typedef className ObjectType; \
className* object; \
inline returnType _exec (S32 argc, ConsoleValueRef* argv) const; \
}; \
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
(className* object, S32 argc, const char** argv) \ (className* object, Vector<const char*>* vec) \
{ \ { \
_CHECK_ENGINE_INITIALIZED( name, returnType ); \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \
StringStackConsoleWrapper args(argc, argv); \ StringStackConsoleWrapper args(vec->size(), vec->address()); \
_ ## className ## name ## frame frame {}; \
frame.object = static_cast< className* >( object ); \
return EngineTypeTraits< returnType >::ReturnValue( \ return EngineTypeTraits< returnType >::ReturnValue( \
_fn ## className ## _ ## name ## impl(object, args.count(), args) \ frame._exec(args.count(), args) \
); \ ); \
} \ } \
static _EngineFunctionDefaultArguments< void (className* object, S32 argc, const char** argv) > _fn ## className ## _ ## name ## DefaultArgs; \ static _EngineFunctionDefaultArguments< void (className* object, S32 argc, const char** argv) > \
static EngineFunctionInfo _fn ## className ## _ ## name ## FunctionInfo( \ _fn ## className ## name ## DefaultArgs; \
static EngineFunctionInfo _fn ## className ## name ## FunctionInfo( \
#name, \ #name, \
&_SCOPE<>()(), \ &_SCOPE< className >()(), \
usage, \ usage, \
#returnType " " #name "(SimObject* object, S32 argc, const char** argv)", \ "virtual " #returnType " " #name "(Vector<String> args)", \
"fn" #className "_" #name, \ "fn" #className "_" #name, \
TYPE< returnType (SimObject* object, S32 argc, const char** argv) >(), \ TYPE< _EngineMethodTrampoline< _ ## className ## name ## frame, returnType (Vector<const char*> vec) >::FunctionType >(), \
&_fn ## className ## _ ## name ## DefaultArgs, \ &_fn ## className ## name ## DefaultArgs, \
( void* ) &fn ## className ## _ ## name, \ ( void* ) &fn ## className ## _ ## name, \
0 \ 0 \
); \ ); \
returnType cm_##className##_##name##_caster(SimObject* object, S32 argc, ConsoleValueRef* argv) { \ returnType cm_##className##_##name##_caster(SimObject* object, S32 argc, ConsoleValueRef* argv) { \
AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" ); \ AssertFatal( dynamic_cast<className*>( object ), "Object passed to " #name " is not a " #className "!" ); \
conmethod_return_##returnType ) _fn ## className ## _ ## name ## impl(static_cast<className*>(object),argc,argv); \ _ ## className ## name ## frame frame {}; \
frame.object = static_cast< className* >( object ); \
conmethod_return_##returnType ) frame._exec(argc,argv); \
}; \ }; \
ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage,minArgs,maxArgs); \ ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage,minArgs,maxArgs); \
static inline returnType _fn ## className ## _ ## name ## impl(className *object, S32 argc, ConsoleValueRef *argv) inline returnType _ ## className ## name ## frame::_exec(S32 argc, ConsoleValueRef *argv) const
@ -951,7 +933,7 @@ public:
#define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage ) \ #define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage ) \
static inline returnType _fn ## name ## impl args; \ static inline returnType _fn ## name ## impl args; \
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ ( _EngineFunctionTrampoline< returnType args >::Args a ) \
{ \ { \
_CHECK_ENGINE_INITIALIZED( name, returnType ); \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \
return EngineTypeTraits< returnType >::ReturnValue( \ return EngineTypeTraits< returnType >::ReturnValue( \
@ -998,7 +980,7 @@ public:
#define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \ #define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
static inline returnType _fn ## className ## name ## impl args; \ static inline returnType _fn ## className ## name ## impl args; \
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ ( _EngineFunctionTrampoline< returnType args >::Args a ) \
{ \ { \
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \ _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
return EngineTypeTraits< returnType >::ReturnValue( \ return EngineTypeTraits< returnType >::ReturnValue( \

View file

@ -67,18 +67,9 @@ struct EngineFunctionDefaultArguments
/// @warn This is @b NOT the size of the memory block returned by getArgs() and also /// @warn This is @b NOT the size of the memory block returned by getArgs() and also
/// not the number of elements it contains. /// not the number of elements it contains.
U32 mNumDefaultArgs; U32 mNumDefaultArgs;
/// Return a pointer to the variable-sized array of default argument values. U32* mOffsets;
/// U8* mFirst;
/// @warn The arguments must be stored @b IMMEDIATELY after #mNumDefaultArgs.
/// @warn This is a @b FULL frame and not just the default arguments, i.e. it starts with the
/// first argument that the function takes and ends with the last argument it takes.
/// @warn If the compiler's #pragma pack is buggy, the elements in this structure are allowed
/// to be 4-byte aligned rather than byte-aligned as they should be.
const U8* getArgs() const
{
return ( const U8* ) &( mNumDefaultArgs ) + sizeof( mNumDefaultArgs );
}
}; };
@ -94,22 +85,21 @@ struct EngineFunctionDefaultArguments
template< typename T > template< typename T >
struct _EngineFunctionDefaultArguments {}; struct _EngineFunctionDefaultArguments {};
template<typename ...ArgTs> template<typename R, typename ...ArgTs>
struct _EngineFunctionDefaultArguments< void(ArgTs...) > : public EngineFunctionDefaultArguments struct _EngineFunctionDefaultArguments< R(ArgTs...) > : public EngineFunctionDefaultArguments
{ {
template<typename T> using DefVST = typename EngineTypeTraits<T>::DefaultArgumentValueStoreType; template<typename T> using DefVST = typename EngineTypeTraits<T>::DefaultArgumentValueStoreType;
fixed_tuple<DefVST<ArgTs> ...> mFixedArgs; using SelfType = _EngineFunctionDefaultArguments< R(ArgTs...) >;
std::tuple<DefVST<ArgTs> ...> mArgs; fixed_tuple<DefVST<ArgTs>...> mArgs;
private: private:
using SelfType = _EngineFunctionDefaultArguments< void(ArgTs...) >;
template<size_t ...> struct Seq {}; template<size_t ...> struct Seq {};
template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {}; template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
template<size_t ...I> struct Gens<0, I...>{ typedef Seq<I...> type; }; template<size_t ...I> struct Gens<0, I...>{ typedef Seq<I...> type; };
template<typename ...TailTs, size_t ...I> template<typename ...TailTs, size_t ...I>
static void copyHelper(std::tuple<DefVST<ArgTs> ...> &args, std::tuple<DefVST<TailTs> ...> &defaultArgs, Seq<I...>) { static void copyHelper(std::tuple<DefVST<ArgTs> ...> &args, std::tuple<DefVST<TailTs> ...> &defaultArgs, Seq<I...>) {
std::tie(std::get<I + (sizeof...(ArgTs) - sizeof...(TailTs))>(args)...) = defaultArgs; std::tie(std::get<I + (sizeof...(ArgTs) - sizeof...(TailTs))>(args)...) = defaultArgs;
} }
@ -117,26 +107,43 @@ private:
template<typename ...TailTs> template<typename ...TailTs>
struct DodgyVCHelper struct DodgyVCHelper
{ {
using type = typename std::enable_if<sizeof...(TailTs) <= sizeof...(ArgTs), decltype(mArgs)>::type; using type = typename std::enable_if<sizeof...(TailTs) <= sizeof...(ArgTs), std::tuple<DefVST<ArgTs>...>>::type;
}; };
template<typename ...TailTs> using MaybeSelfEnabled = typename DodgyVCHelper<TailTs...>::type; template<typename ...TailTs> using MaybeSelfEnabled = typename DodgyVCHelper<TailTs...>::type;
#else #else
template<typename ...TailTs> using MaybeSelfEnabled = typename std::enable_if<sizeof...(TailTs) <= sizeof...(ArgTs), decltype(mArgs)>::type; template<typename ...TailTs> using MaybeSelfEnabled = typename std::enable_if<sizeof...(TailTs) <= sizeof...(ArgTs), std::tuple<DefVST<ArgTs>...>>::type;
#endif #endif
template<typename ...TailTs> static MaybeSelfEnabled<TailTs...> tailInit(TailTs ...tail) { template<typename ...TailTs> static MaybeSelfEnabled<TailTs...> tailInit(TailTs ...tail) {
std::tuple<DefVST<ArgTs>...> argsT; std::tuple<DefVST<ArgTs>...> argsT;
std::tuple<DefVST<TailTs>...> tailT = std::make_tuple(tail...); std::tuple<DefVST<TailTs>...> tailT = std::make_tuple(tail...);
SelfType::copyHelper<TailTs...>(argsT, tailT, typename Gens<sizeof...(TailTs)>::type()); SelfType::template copyHelper<TailTs...>(argsT, tailT, typename Gens<sizeof...(TailTs)>::type());
return argsT; return argsT;
}; };
template<size_t I = 0>
typename std::enable_if<I == sizeof...(ArgTs)>::type initOffsetsHelper()
{ }
template<size_t I = 0>
typename std::enable_if < I < sizeof...(ArgTs)>::type initOffsetsHelper()
{
mOffsets[I] = fixed_tuple_offset<I>(mArgs);
initOffsetsHelper<I + 1>();
}
public: public:
template<typename ...TailTs> _EngineFunctionDefaultArguments(TailTs ...tail) template<typename ...TailTs> _EngineFunctionDefaultArguments(TailTs ...tail)
: EngineFunctionDefaultArguments({sizeof...(TailTs)}), mArgs(SelfType::tailInit(tail...)) : EngineFunctionDefaultArguments()
{ {
fixed_tuple_mutator<void(DefVST<ArgTs>...), void(DefVST<ArgTs>...)>::copy(mArgs, mFixedArgs); std::tuple<DefVST<ArgTs>...> tmpTup = SelfType::tailInit(tail...);
fixed_tuple_mutator<void(DefVST<ArgTs>...), void(DefVST<ArgTs>...)>::copy(tmpTup, mArgs);
mNumDefaultArgs = sizeof...(TailTs);
mOffsets = new U32[sizeof...(ArgTs)];
initOffsetsHelper();
mFirst = (U8*)& mArgs;
} }
}; };

View file

@ -27,9 +27,23 @@
IMPLEMENT_PRIMITIVE( bool, bool,, "Boolean true/false." ); IMPLEMENT_PRIMITIVE( bool, bool,, "Boolean true/false." );
IMPLEMENT_PRIMITIVE( S8, byte,, "8bit signed integer." ); IMPLEMENT_PRIMITIVE( S8, byte,, "8bit signed integer." );
IMPLEMENT_PRIMITIVE( U8, ubyte,, "8bit unsigned integer." ); IMPLEMENT_PRIMITIVE( U8, ubyte,, "8bit unsigned integer." );
IMPLEMENT_PRIMITIVE( S16, short,, "16bit signed integer.");
IMPLEMENT_PRIMITIVE( U16, ushort,, "16bit unsigned integer.");
IMPLEMENT_PRIMITIVE( S32, int,, "32bit signed integer." ); IMPLEMENT_PRIMITIVE( S32, int,, "32bit signed integer." );
IMPLEMENT_PRIMITIVE( U32, uint,, "32bit unsigned integer." ); IMPLEMENT_PRIMITIVE( U32, uint,, "32bit unsigned integer." );
IMPLEMENT_PRIMITIVE( F32, float,, "32bit single-precision floating-point." ); IMPLEMENT_PRIMITIVE( F32, float,, "32bit single-precision floating-point." );
IMPLEMENT_PRIMITIVE( F64, double,, "64bit double-precision floating-point." ); IMPLEMENT_PRIMITIVE( F64, double,, "64bit double-precision floating-point." );
IMPLEMENT_PRIMITIVE( String, string,, "Null-terminated UTF-16 Unicode string." ); IMPLEMENT_PRIMITIVE( String, string,, "Null-terminated UTF-16 Unicode string." );
IMPLEMENT_PRIMITIVE( const UTF8*, cstring,, "Null-terminated UTF-8 Unicode string.");
IMPLEMENT_PRIMITIVE( void*, ptr,, "Opaque pointer." ); IMPLEMENT_PRIMITIVE( void*, ptr,, "Opaque pointer." );
// Define pointer types for vectors.
IMPLEMENT_PRIMITIVE( bool*, ptr_bool,, "Pointer to a bool." );
IMPLEMENT_PRIMITIVE( U8*, ptr_ubyte,, "Pointer to an unsigned byte." );
IMPLEMENT_PRIMITIVE( U32*, ptr_uint,, "Pointer to an unsigned 32bit int." );
IMPLEMENT_PRIMITIVE( S32*, ptr_int,, "Pointer to a 32bit int." );
IMPLEMENT_PRIMITIVE( F32*, ptr_float,, "Pointer to a 32bit float." );
IMPLEMENT_PRIMITIVE( Point3F*, ptr_Point3F,, "Pointer to a Point3F struct." );
IMPLEMENT_PRIMITIVE( PlaneF*, ptr_PlaneF,, "Pointer to a PlaneF struct." );
IMPLEMENT_PRIMITIVE( PolyhedronData::Edge*, ptr_Edge,, "Pointer to an Edge struct." );
IMPLEMENT_PRIMITIVE( const UTF8**, ptr_string,, "Pointer to an UTF-8 string." );

View file

@ -27,6 +27,8 @@
#include "console/engineTypes.h" #include "console/engineTypes.h"
#endif #endif
#include "math/mPlane.h"
#include "math/mPolyhedron.h"
/// @file /// @file
/// Definitions for the core primitive types used in the /// Definitions for the core primitive types used in the
@ -37,6 +39,8 @@
DECLARE_PRIMITIVE_R( bool ); DECLARE_PRIMITIVE_R( bool );
DECLARE_PRIMITIVE_R(S8); DECLARE_PRIMITIVE_R(S8);
DECLARE_PRIMITIVE_R(U8); DECLARE_PRIMITIVE_R(U8);
DECLARE_PRIMITIVE_R(S16);
DECLARE_PRIMITIVE_R(U16);
DECLARE_PRIMITIVE_R(S32); DECLARE_PRIMITIVE_R(S32);
DECLARE_PRIMITIVE_R(U32); DECLARE_PRIMITIVE_R(U32);
DECLARE_PRIMITIVE_R(F32); DECLARE_PRIMITIVE_R(F32);
@ -45,11 +49,20 @@ DECLARE_PRIMITIVE_R(U64);
DECLARE_PRIMITIVE_R(S64); DECLARE_PRIMITIVE_R(S64);
DECLARE_PRIMITIVE_R(void*); DECLARE_PRIMITIVE_R(void*);
DECLARE_PRIMITIVE_R(bool*);
DECLARE_PRIMITIVE_R(U8*);
DECLARE_PRIMITIVE_R(S32*);
DECLARE_PRIMITIVE_R(U32*);
DECLARE_PRIMITIVE_R(F32*);
DECLARE_PRIMITIVE_R(Point3F*);
DECLARE_PRIMITIVE_R(PlaneF*);
DECLARE_PRIMITIVE_R(PolyhedronData::Edge*);
DECLARE_PRIMITIVE_R(const char**);
//FIXME: this allows String to be used as a struct field type //FIXME: this allows String to be used as a struct field type
// String is special in the way its data is exchanged through the API. Through // String is special in the way its data is exchanged through the API. Through
// calls, strings are passed as plain, null-terminated UTF-16 character strings. // calls, strings are passed as plain, null-terminated UTF-8 character strings.
// In addition, strings passed back as return values from engine API functions // In addition, strings passed back as return values from engine API functions
// are considered to be owned by the API layer itself. The rule here is that such // are considered to be owned by the API layer itself. The rule here is that such
// a string is only valid until the next API call is made. Usually, control layers // a string is only valid until the next API call is made. Usually, control layers
@ -58,21 +71,20 @@ _DECLARE_TYPE_R(String);
template<> template<>
struct EngineTypeTraits< String > : public _EnginePrimitiveTypeTraits< String > struct EngineTypeTraits< String > : public _EnginePrimitiveTypeTraits< String >
{ {
typedef const UTF16* ArgumentValueType; typedef const UTF8* ArgumentValueType;
typedef const UTF16* ReturnValueType; typedef const UTF8* ReturnValueType;
//FIXME: this needs to be sorted out; for now, we store default value literals in ASCII //FIXME: this needs to be sorted out; for now, we store default value literals in ASCII
typedef const char* DefaultArgumentValueStoreType; typedef const char* DefaultArgumentValueStoreType;
static const UTF16* ReturnValue( const String& str ) static const UTF8* ReturnValue( const String& str )
{ {
static String sTemp; static String sTemp;
sTemp = str; sTemp = str;
return sTemp.utf16(); return sTemp.utf8();
} }
}; };
// For struct fields, String cannot be used directly but "const UTF16*" must be used // For struct fields, String cannot be used directly but "const UTF16*" must be used
// instead. Make sure this works with the template machinery by redirecting the type // instead. Make sure this works with the template machinery by redirecting the type
// back to String. // back to String.
@ -80,4 +92,20 @@ template<> struct EngineTypeTraits< const UTF16* > : public EngineTypeTraits< St
template<> inline const EngineTypeInfo* TYPE< const UTF16* >() { return TYPE< String >(); } template<> inline const EngineTypeInfo* TYPE< const UTF16* >() { return TYPE< String >(); }
inline const EngineTypeInfo* TYPE( const UTF16*& ) { return TYPE< String >(); } inline const EngineTypeInfo* TYPE( const UTF16*& ) { return TYPE< String >(); }
// Temp support for allowing const char* to remain in the API functions as long as we
// still have the console system around. When that is purged, these definitions should
// be deleted and all const char* uses be replaced with String.
_DECLARE_TYPE_R(const UTF8*);
template<>
struct EngineTypeTraits< const UTF8* > : public _EnginePrimitiveTypeTraits< const UTF8* >
{
static const UTF8* ReturnValue(const String& str)
{
static String sTemp;
sTemp = str;
return sTemp.utf8();
}
};
#endif // !_ENGINEPRIMITIVES_H_ #endif // !_ENGINEPRIMITIVES_H_

View file

@ -25,32 +25,42 @@
#include "core/util/tVector.h" #include "core/util/tVector.h"
#include "core/util/uuid.h" #include "core/util/uuid.h"
#include "core/color.h" #include "core/color.h"
#include "math/mPolyhedron.h"
IMPLEMENT_STRUCT(PlaneF,
PlaneF, ,
"")
IMPLEMENT_STRUCT( Vector< bool >, FIELD(x, x, 1, "")
BoolVector,, FIELD(y, y, 1, "")
FIELD(z, z, 1, "")
FIELD(d, d, 1, "")
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( PolyhedronData::Edge,
Edge,,
"" ) "" )
FIELD_AS(U32, face, face, 2, "")
FIELD_AS(U32, vertex, vertex, 2, "")
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< S32 >, IMPLEMENT_STRUCT(Torque::UUID,
IntVector,, UUID, ,
"" ) "")
Torque::UUIDEngineExport::getAField(),
Torque::UUIDEngineExport::getBField(),
Torque::UUIDEngineExport::getCField(),
Torque::UUIDEngineExport::getDField(),
Torque::UUIDEngineExport::getEField(),
Torque::UUIDEngineExport::getFField(),
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< F32 >,
FloatVector,,
"" )
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Torque::UUID,
UUID,,
"" )
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( ColorI, IMPLEMENT_STRUCT( ColorI,
ColorI,, ColorI,,
"RGBA color quadruple in 8bit integer precision per channel." ) "RGBA color quadruple in 8bit integer precision per channel." )
@ -73,3 +83,74 @@ IMPLEMENT_STRUCT( LinearColorF,
FIELD( alpha, alpha, 1, "Alpha channel value." ) FIELD( alpha, alpha, 1, "Alpha channel value." )
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
// Vectors
IMPLEMENT_STRUCT( Vector< bool >,
BoolVector,,
"" )
VectorFieldEngineExport::getElementCountField< bool >(),
VectorFieldEngineExport::getArraySizeField< bool >(),
VectorFieldEngineExport::getArrayField< bool >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< S32 >,
IntVector,,
"" )
VectorFieldEngineExport::getElementCountField< S32 >(),
VectorFieldEngineExport::getArraySizeField< S32 >(),
VectorFieldEngineExport::getArrayField< S32 >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< F32 >,
FloatVector,,
"" )
VectorFieldEngineExport::getElementCountField< F32 >(),
VectorFieldEngineExport::getArraySizeField< F32 >(),
VectorFieldEngineExport::getArrayField< F32 >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< Point3F >,
Point3FVector,,
"" )
VectorFieldEngineExport::getElementCountField< Point3F >(),
VectorFieldEngineExport::getArraySizeField< Point3F >(),
VectorFieldEngineExport::getArrayField< Point3F >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT(Vector< PlaneF >,
PlaneFVector, ,
"")
VectorFieldEngineExport::getElementCountField< PlaneF >(),
VectorFieldEngineExport::getArraySizeField< PlaneF >(),
VectorFieldEngineExport::getArrayField< PlaneF >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT(Vector< PolyhedronData::Edge >,
EdgeVector, ,
"")
VectorFieldEngineExport::getElementCountField< PolyhedronData::Edge >(),
VectorFieldEngineExport::getArraySizeField< PolyhedronData::Edge >(),
VectorFieldEngineExport::getArrayField< PolyhedronData::Edge >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT(Vector< const char* >,
StringVector, ,
"")
VectorFieldEngineExport::getElementCountField< const char* >(),
VectorFieldEngineExport::getArraySizeField< const char* >(),
VectorFieldEngineExport::getArrayField< const char* >(),
END_IMPLEMENT_STRUCT;

View file

@ -27,6 +27,8 @@
#include "console/engineTypes.h" #include "console/engineTypes.h"
#endif #endif
#include "math/mPlane.h"
#include "math/mPolyhedron.h"
/// @file /// @file
/// Definitions for the core engine structured types. /// Definitions for the core engine structured types.
@ -44,6 +46,12 @@ class LinearColorF;
DECLARE_STRUCT_R(Vector< bool >); DECLARE_STRUCT_R(Vector< bool >);
DECLARE_STRUCT_R(Vector< S32 >); DECLARE_STRUCT_R(Vector< S32 >);
DECLARE_STRUCT_R(Vector< F32 >); DECLARE_STRUCT_R(Vector< F32 >);
DECLARE_STRUCT_R(Vector< Point3F >);
DECLARE_STRUCT_R(PlaneF);
DECLARE_STRUCT_R(Vector< PlaneF >);
DECLARE_STRUCT_R(PolyhedronData::Edge);
DECLARE_STRUCT_R(Vector< PolyhedronData::Edge >);
DECLARE_STRUCT_R(Vector< const char* >);
DECLARE_STRUCT_R(Torque::UUID); DECLARE_STRUCT_R(Torque::UUID);
DECLARE_STRUCT_R(ColorI); DECLARE_STRUCT_R(ColorI);
DECLARE_STRUCT_R(LinearColorF); DECLARE_STRUCT_R(LinearColorF);

View file

@ -240,12 +240,12 @@ struct _EngineStructTypeTraits
typedef void SuperType; typedef void SuperType;
// Structs get passed in as pointers and passed out as full copies. // Structs get passed in as pointers and passed out as full copies.
typedef T ArgumentValueType; typedef T* ArgumentValueType;
typedef T ReturnValueType; typedef T ReturnValueType;
typedef T DefaultArgumentValueStoreType; typedef T DefaultArgumentValueStoreType;
typedef ReturnValueType ReturnValue; typedef ReturnValueType ReturnValue;
static ValueType ArgumentToValue( ArgumentValueType val ) { return val; } static ValueType ArgumentToValue( ArgumentValueType val ) { return *val; }
static const EngineTypeInfo* const TYPEINFO; static const EngineTypeInfo* const TYPEINFO;
}; };
@ -564,12 +564,18 @@ namespace _Private {
/// ///
#define _FIELD( fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), (U32)FIELDOFFSET( fieldName ) } // Artificial offset to avoid compiler warnings.
#define FIELD( fieldName, exportName, numElements, doc ) \ #define FIELD( fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), (U32)FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings. _FIELD(fieldName, exportName, numElements, doc),
/// ///
#define _FIELD_AS( type, fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( *( ( type* ) &( ( ThisType* ) 16 )->fieldName ) ), (U32)FIELDOFFSET( fieldName ) } // Artificial offset to avoid compiler warnings.
#define FIELD_AS( type, fieldName, exportName, numElements, doc ) \ #define FIELD_AS( type, fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( *( ( type* ) &( ( ThisType* ) 16 )->fieldName ) ), (U32)FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings. _FIELD_AS(type, fieldName, exportName, numElements, doc),
/// ///
#define FIELDOFFSET( fieldName ) \ #define FIELDOFFSET( fieldName ) \

View file

@ -58,9 +58,9 @@ static const char* getDocString(const EngineExport* exportInfo)
} }
template< typename T > template< typename T >
inline T getArgValue(const EngineFunctionDefaultArguments* defaultArgs, U32 offset) inline T getArgValue(const EngineFunctionDefaultArguments* defaultArgs, U32 idx)
{ {
return *reinterpret_cast< const T* >(defaultArgs->getArgs() + offset); return *(const T*)(defaultArgs->mFirst + defaultArgs->mOffsets[idx]);
} }
@ -122,7 +122,7 @@ static Vector< String > parseFunctionArgumentNames(const EngineFunctionInfo* fun
// Parse out name. // Parse out name.
const char* end = ptr + 1; const char* end = ptr + 1;
while (ptr > prototype && dIsalnum(*ptr)) while (ptr > prototype && (dIsalnum(*ptr) || *ptr == '_'))
ptr--; ptr--;
const char* start = ptr + 1; const char* start = ptr + 1;
@ -169,20 +169,19 @@ static Vector< String > parseFunctionArgumentNames(const EngineFunctionInfo* fun
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static String getValueForType(const EngineTypeInfo* type, void* addr)
static String getDefaultArgumentValue(const EngineFunctionInfo* function, const EngineTypeInfo* type, U32 offset)
{ {
String value; String value;
const EngineFunctionDefaultArguments* defaultArgs = function->getDefaultArguments(); #define ADDRESS_TO_TYPE(tp) *(const tp*)(addr);
switch (type->getTypeKind()) switch (type->getTypeKind())
{ {
case EngineTypeKindPrimitive: case EngineTypeKindPrimitive:
{ {
#define PRIMTYPE( tp ) \ #define PRIMTYPE( tp ) \
if( TYPE< tp >() == type ) \ if( TYPE< tp >() == type ) \
{ \ { \
tp val = getArgValue< tp >( defaultArgs, offset ); \ tp val = ADDRESS_TO_TYPE(tp); \
value = String::ToString( val ); \ value = String::ToString( val ); \
} }
@ -195,9 +194,9 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const
PRIMTYPE(F64); PRIMTYPE(F64);
//TODO: for now we store string literals in ASCII; needs to be sorted out //TODO: for now we store string literals in ASCII; needs to be sorted out
if (TYPE< const char* >() == type) if (TYPE< String >() == type || TYPE< const UTF8* >() == type)
{ {
const char* val = reinterpret_cast<const char*>(defaultArgs->getArgs() + offset); const UTF8* val = *((const UTF8**)(addr));
value = val; value = val;
} }
@ -207,7 +206,7 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const
case EngineTypeKindEnum: case EngineTypeKindEnum:
{ {
S32 val = getArgValue< S32 >(defaultArgs, offset); S32 val = ADDRESS_TO_TYPE(S32);
AssertFatal(type->getEnumTable(), "engineXMLExport - Enum type without table!"); AssertFatal(type->getEnumTable(), "engineXMLExport - Enum type without table!");
const EngineEnumTable& table = *(type->getEnumTable()); const EngineEnumTable& table = *(type->getEnumTable());
@ -225,7 +224,7 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const
case EngineTypeKindBitfield: case EngineTypeKindBitfield:
{ {
S32 val = getArgValue< S32 >(defaultArgs, offset); S32 val = ADDRESS_TO_TYPE(S32);
AssertFatal(type->getEnumTable(), "engineXMLExport - Bitfield type without table!"); AssertFatal(type->getEnumTable(), "engineXMLExport - Bitfield type without table!");
const EngineEnumTable& table = *(type->getEnumTable()); const EngineEnumTable& table = *(type->getEnumTable());
@ -247,7 +246,28 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const
case EngineTypeKindStruct: case EngineTypeKindStruct:
{ {
//TODO: struct type default argument values AssertFatal(type->getFieldTable(), "engineXMLExport - Struct type without table!");
const EngineFieldTable* fieldTable = type->getFieldTable();
U32 numFields = fieldTable->getNumFields();
for (int i = 0; i < numFields; ++i)
{
const EngineTypeInfo* fieldType = (*fieldTable)[i].getType();
U32 fieldOffset = (*fieldTable)[i].getOffset();
U32 numElements = (*fieldTable)[i].getNumElements();
for (int j = 0; j < numElements; ++j)
{
if (i == 0 && j == 0) {
value = getValueForType(fieldType, (void*)((size_t)addr + fieldOffset));
}
else {
value += " " + getValueForType(fieldType, (void*)((size_t)addr + (size_t)fieldOffset * ((size_t)j * fieldType->getInstanceSize())));
}
}
}
break; break;
} }
@ -257,7 +277,7 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const
// For these two kinds, we support "null" as the only valid // For these two kinds, we support "null" as the only valid
// default value. // default value.
const void* ptr = getArgValue< const void* >(defaultArgs, offset); const void* ptr = ADDRESS_TO_TYPE(void*);
if (!ptr) if (!ptr)
value = "null"; value = "null";
break; break;
@ -267,11 +287,20 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const
break; break;
} }
#undef ADDRESS_TO_TYPE
return value; return value;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static String getDefaultArgumentValue(const EngineFunctionInfo* function, const EngineTypeInfo* type, U32 idx)
{
const EngineFunctionDefaultArguments* defaultArgs = function->getDefaultArguments();
return getValueForType(type, (void*)(defaultArgs->mFirst + defaultArgs->mOffsets[idx]));
}
//-----------------------------------------------------------------------------
static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* xml) static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* xml)
{ {
if (isExportFiltered(function)) if (isExportFiltered(function))
@ -295,9 +324,6 @@ static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* x
Vector< String > argumentNames = parseFunctionArgumentNames(function); Vector< String > argumentNames = parseFunctionArgumentNames(function);
const U32 numArgumentNames = argumentNames.size(); const U32 numArgumentNames = argumentNames.size();
// Accumulated offset in function argument frame vector.
U32 argFrameOffset = 0;
for (U32 i = 0; i < numArguments; ++i) for (U32 i = 0; i < numArguments; ++i)
{ {
xml->pushNewElement("EngineFunctionArgument"); xml->pushNewElement("EngineFunctionArgument");
@ -313,21 +339,17 @@ static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* x
if (i >= firstDefaultArg) if (i >= firstDefaultArg)
{ {
String defaultValue = getDefaultArgumentValue(function, type, argFrameOffset); String defaultValue = getDefaultArgumentValue(function, type, i);
xml->setAttribute("defaultValue", defaultValue); xml->setAttribute("defaultValue", defaultValue);
} }
// A bit hacky, default arguments have all offsets.
if (function->getDefaultArguments() != NULL)
{
xml->setAttribute("offset", String::ToString(function->getDefaultArguments()->mOffsets[i]));
}
xml->popElement(); xml->popElement();
if (type->getTypeKind() == EngineTypeKindStruct)
argFrameOffset += type->getInstanceSize();
else
argFrameOffset += type->getValueSize();
#ifdef _PACK_BUG_WORKAROUNDS
if (argFrameOffset % 4 > 0)
argFrameOffset += 4 - (argFrameOffset % 4);
#endif
} }
xml->popElement(); xml->popElement();
@ -492,7 +514,12 @@ static void exportType(const EngineTypeInfo* type, SimXMLDocument* xml)
ConsoleBaseType *cbt = ConsoleBaseType::getType(property.getType()); ConsoleBaseType *cbt = ConsoleBaseType::getType(property.getType());
if (cbt != NULL) if (cbt != NULL)
{ {
xml->setAttribute("type", cbt->getTypeClassName()); if (cbt->getTypeInfo() != NULL) {
xml->setAttribute("type", cbt->getTypeInfo()->getTypeName());
}
else {
xml->setAttribute("type", cbt->getTypeClassName());
}
} }
else else
{ {
@ -554,6 +581,7 @@ static void exportScope(const EngineExportScope* scope, SimXMLDocument* xml, boo
break; break;
default: default:
AssertFatal(true, "Unknown EngineExportKind: " + exportInfo->getExportKind());
break; break;
} }
} }
@ -579,4 +607,4 @@ DefineEngineFunction(exportEngineAPIToXML, SimXMLDocument*, (), ,
exportScope(EngineExportScope::getGlobalScope(), xml, true); exportScope(EngineExportScope::getGlobalScope(), xml, true);
return xml; return xml;
} }

View file

@ -22,6 +22,9 @@
#ifndef _FIXEDTUPLE_H_ #ifndef _FIXEDTUPLE_H_
#define _FIXEDTUPLE_H_ #define _FIXEDTUPLE_H_
#include "engineTypes.h"
/// @name Fixed-layout tuple definition /// @name Fixed-layout tuple definition
/// These structs and templates serve as a way to pass arguments from external /// These structs and templates serve as a way to pass arguments from external
/// applications and into the T3D console system. /// applications and into the T3D console system.
@ -113,6 +116,21 @@ struct fixed_tuple_accessor<0>
} }
}; };
#pragma warning( push )
#pragma warning( disable : 4267 )
template <size_t I, class... Ts>
static U32 fixed_tuple_offset(fixed_tuple<Ts...>& t)
{
return (U32)((size_t)& fixed_tuple_accessor<I>::get(t)) - ((size_t)& t);
}
template <size_t I, class... Ts>
static U32 fixed_tuple_offset(const fixed_tuple<Ts...>& t)
{
return (U32)((size_t)& fixed_tuple_accessor<I>::get(t)) - ((size_t)& t);
}
#pragma warning(pop)
template< typename T1, typename T2 > template< typename T1, typename T2 >
struct fixed_tuple_mutator {}; struct fixed_tuple_mutator {};
@ -150,4 +168,4 @@ struct fixed_tuple_mutator<void(Tdest...), void(Tsrc...)>
/// @} /// @}
#endif // !_FIXEDTUPLE_H_ #endif // !_FIXEDTUPLE_H_

View file

@ -42,6 +42,7 @@
#include "persistence/taml/tamlCustom.h" #include "persistence/taml/tamlCustom.h"
#include "sim/netObject.h" #include "sim/netObject.h"
#include "cinterface/cinterface.h"
IMPLEMENT_CONOBJECT( SimObject ); IMPLEMENT_CONOBJECT( SimObject );
@ -831,6 +832,10 @@ bool SimObject::isMethod( const char* methodName )
if( !methodName || !methodName[0] ) if( !methodName || !methodName[0] )
return false; return false;
if (CInterface::isMethod(this->getName(), methodName) || CInterface::isMethod(this->getClassName(), methodName)) {
return true;
}
StringTableEntry stname = StringTable->insert( methodName ); StringTableEntry stname = StringTable->insert( methodName );
if( getNamespace() ) if( getNamespace() )

View file

@ -24,16 +24,26 @@
#include "console/simObject.h" #include "console/simObject.h"
#include "core/util/tDictionary.h" #include "core/util/tDictionary.h"
#include "core/util/safeDelete.h" #include "core/util/safeDelete.h"
#include "engineAPI.h"
//#define DEBUG_SPEW //#define DEBUG_SPEW
IMPLEMENT_CLASS(SimPersistID, "")
END_IMPLEMENT_CLASS;
SimPersistID::LookupTableType* SimPersistID::smLookupTable; SimPersistID::LookupTableType* SimPersistID::smLookupTable;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
SimPersistID::SimPersistID()
{
mObject = NULL;
mUUID.generate();
smLookupTable->insertUnique(mUUID, this);
}
SimPersistID::SimPersistID( SimObject* object ) SimPersistID::SimPersistID( SimObject* object )
: mObject( object ) : mObject( object )
{ {
@ -136,3 +146,13 @@ SimPersistID* SimPersistID::findOrCreate( const Torque::UUID& uuid )
return pid; return pid;
} }
DefineNewEngineMethod(SimPersistID, getUUID, Torque::UUID, (), , "")
{
return object->getUUID();
}
DefineNewEngineMethod(SimPersistID, getObject, SimObject*, (), , "")
{
return object->getObject();
}

View file

@ -30,6 +30,9 @@
#include "core/util/refBase.h" #include "core/util/refBase.h"
#endif #endif
#ifndef _ENGINEOBJECT_H_
#include "console/engineObject.h"
#endif
/// @file /// @file
/// Persistent IDs for SimObjects. /// Persistent IDs for SimObjects.
@ -40,12 +43,27 @@ template< typename, typename > class HashTable;
/// A globally unique persistent ID for a SimObject. /// A globally unique persistent ID for a SimObject.
class SimPersistID : public StrongRefBase class SimPersistID : public EngineObject
{ {
public: public:
DECLARE_CLASS(SimPersistID, EngineObject);
typedef void Parent; typedef void Parent;
friend class SimObject; friend class SimObject;
///
SimPersistID();
/// Construct a new persistent ID for "object" by generating a fresh
/// unique identifier.
SimPersistID(SimObject* object);
/// Construct a persistent ID stub for the given unique identifier.
/// The stub remains not bound to any object until it is resolved.
SimPersistID(const Torque::UUID& uuid);
///
~SimPersistID();
protected: protected:
@ -60,17 +78,6 @@ class SimPersistID : public StrongRefBase
/// Table of persistent object IDs. /// Table of persistent object IDs.
static LookupTableType* smLookupTable; static LookupTableType* smLookupTable;
/// Construct a new persistent ID for "object" by generating a fresh
/// unique identifier.
SimPersistID( SimObject* object );
/// Construct a persistent ID stub for the given unique identifier.
/// The stub remains not bound to any object until it is resolved.
SimPersistID( const Torque::UUID& uuid );
///
~SimPersistID();
/// Bind this unresolved PID to the given object. /// Bind this unresolved PID to the given object.
void resolve( SimObject* object ); void resolve( SimObject* object );

View file

@ -37,7 +37,7 @@
#include "math/mMathFn.h" #include "math/mMathFn.h"
IMPLEMENT_CONOBJECT( SimSet ); IMPLEMENT_CONOBJECT_CHILDREN( SimSet );
IMPLEMENT_CONOBJECT( SimGroup ); IMPLEMENT_CONOBJECT( SimGroup );
ConsoleDocClass( SimSet, ConsoleDocClass( SimSet,

View file

@ -95,6 +95,7 @@ class SimSet : public SimObject, public TamlChildren
public: public:
typedef SimObject Parent; typedef SimObject Parent;
typedef SimObject Children;
enum SetModification enum SetModification
{ {

View file

@ -29,6 +29,8 @@
#include "platform/platform.h" #include "platform/platform.h"
#endif #endif
#include <algorithm> #include <algorithm>
#include "console/engineTypes.h"
#include "console/engineTypeInfo.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Helper definitions for the vector class. // Helper definitions for the vector class.
@ -63,6 +65,7 @@ extern bool VectorResize(U32 *aSize, U32 *aCount, void **arrayPtr, U32 newCount,
template<class T> template<class T>
class Vector class Vector
{ {
friend class VectorFieldEngineExport;
protected: protected:
U32 mElementCount; ///< Number of elements currently in the Vector. U32 mElementCount; ///< Number of elements currently in the Vector.
U32 mArraySize; ///< Number of elements allocated for the Vector. U32 mArraySize; ///< Number of elements allocated for the Vector.
@ -188,6 +191,29 @@ class Vector
/// @} /// @}
}; };
class VectorFieldEngineExport
{
public:
template <class T>
static EngineFieldTable::Field getElementCountField()
{
typedef Vector<T> ThisType;
return _FIELD(mElementCount, elementCount, 1, "");
};
template <class T>
static EngineFieldTable::Field getArraySizeField()
{
typedef Vector<T> ThisType;
return _FIELD(mArraySize, arraySize, 1, "");
};
template <class T>
static EngineFieldTable::Field getArrayField()
{
typedef Vector<T> ThisType;
return _FIELD(mArray, array, 1, "");
};
};
template<class T> inline Vector<T>::~Vector() template<class T> inline Vector<T>::~Vector()
{ {
clear(); clear();
@ -966,7 +992,7 @@ public:
}; };
// Include vector specializations // Include vector specializations
#ifndef _VECTORSPEC_H_ #ifndef _TVECTORSPEC_H_
#include "core/util/tVectorSpecializations.h" #include "core/util/tVectorSpecializations.h"
#endif #endif

View file

@ -68,6 +68,7 @@
#include <ctype.h> #include <ctype.h>
#include "core/util/md5.h" #include "core/util/md5.h"
#include "console/enginePrimitives.h"
#if defined (TORQUE_OS_MAC) && defined(TORQUE_CPU_X64) #if defined (TORQUE_OS_MAC) && defined(TORQUE_CPU_X64)
typedef unsigned int unsigned32; typedef unsigned int unsigned32;
@ -451,3 +452,42 @@ namespace Torque
return ( a + b + c + d + e + f[ 0 ] + f[ 1 ] + f[ 2 ] + f[ 3 ] + f[ 4 ] + f[ 5 ] ); return ( a + b + c + d + e + f[ 0 ] + f[ 1 ] + f[ 2 ] + f[ 3 ] + f[ 4 ] + f[ 5 ] );
} }
} }
EngineFieldTable::Field Torque::UUIDEngineExport::getAField()
{
typedef UUID ThisType;
return _FIELD(a, a, 1, "");
}
EngineFieldTable::Field Torque::UUIDEngineExport::getBField()
{
typedef UUID ThisType;
return _FIELD(b, b, 1, "");
}
EngineFieldTable::Field Torque::UUIDEngineExport::getCField()
{
typedef UUID ThisType;
return _FIELD(c, c, 1, "");
}
EngineFieldTable::Field Torque::UUIDEngineExport::getDField()
{
typedef UUID ThisType;
return _FIELD(d, d, 1, "");
}
EngineFieldTable::Field Torque::UUIDEngineExport::getEField()
{
typedef UUID ThisType;
return _FIELD(e, e, 1, "");
}
EngineFieldTable::Field Torque::UUIDEngineExport::getFField()
{
typedef UUID ThisType;
return _FIELD_AS(U8, f, f, 6, "");
}

View file

@ -26,6 +26,7 @@
#ifndef _PLATFORM_H_ #ifndef _PLATFORM_H_
#include "platform/platform.h" #include "platform/platform.h"
#endif #endif
#include "console/engineTypeInfo.h"
namespace Torque namespace Torque
@ -33,6 +34,7 @@ namespace Torque
/// A universally unique identifier. /// A universally unique identifier.
class UUID class UUID
{ {
friend class UUIDEngineExport;
public: public:
typedef void Parent; typedef void Parent;
@ -81,6 +83,17 @@ namespace Torque
return !( *this == uuid ); return !( *this == uuid );
} }
}; };
class UUIDEngineExport
{
public:
static EngineFieldTable::Field getAField();
static EngineFieldTable::Field getBField();
static EngineFieldTable::Field getCField();
static EngineFieldTable::Field getDField();
static EngineFieldTable::Field getEField();
static EngineFieldTable::Field getFField();
};
} }
namespace DictHash namespace DictHash

View file

@ -93,6 +93,7 @@ class GFont;
/// ///
class DebugDrawer : public SimObject class DebugDrawer : public SimObject
{ {
typedef SimObject Parent;
public: public:
DECLARE_CONOBJECT(DebugDrawer); DECLARE_CONOBJECT(DebugDrawer);
@ -162,8 +163,6 @@ public:
/// @} /// @}
private: private:
typedef SimObject Parent;
static DebugDrawer* sgDebugDrawer; static DebugDrawer* sgDebugDrawer;
struct DebugPrim struct DebugPrim

View file

@ -44,7 +44,7 @@
//#define DEBUG_SPEW //#define DEBUG_SPEW
IMPLEMENT_CONOBJECT( GuiControl ); IMPLEMENT_CONOBJECT_CHILDREN( GuiControl );
ConsoleDocClass( GuiControl, ConsoleDocClass( GuiControl,
"@brief Base class for all Gui control objects.\n\n" "@brief Base class for all Gui control objects.\n\n"

View file

@ -107,6 +107,7 @@ class GuiControl : public SimGroup
public: public:
typedef SimGroup Parent; typedef SimGroup Parent;
typedef GuiControl Children;
friend class GuiWindowCtrl; // mCollapseGroupVec friend class GuiWindowCtrl; // mCollapseGroupVec
friend class GuiCanvas; friend class GuiCanvas;

View file

@ -69,13 +69,13 @@ void GuiScriptNotifyCtrl::initPersistFields()
{ {
// Callbacks Group // Callbacks Group
addGroup("Callbacks"); addGroup("Callbacks");
addField("onChildAdded", TypeBool, Offset( mOnChildAdded, GuiScriptNotifyCtrl ), "Enables/disables onChildAdded callback" ); addField("notifyOnChildAdded", TypeBool, Offset( mOnChildAdded, GuiScriptNotifyCtrl ), "Enables/disables onChildAdded callback" );
addField("onChildRemoved", TypeBool, Offset( mOnChildRemoved, GuiScriptNotifyCtrl ), "Enables/disables onChildRemoved callback" ); addField("notifyOnChildRemoved", TypeBool, Offset( mOnChildRemoved, GuiScriptNotifyCtrl ), "Enables/disables onChildRemoved callback" );
addField("onChildResized", TypeBool, Offset( mOnChildResized, GuiScriptNotifyCtrl ), "Enables/disables onChildResized callback" ); addField("notifyOnChildResized", TypeBool, Offset( mOnChildResized, GuiScriptNotifyCtrl ), "Enables/disables onChildResized callback" );
addField("onParentResized", TypeBool, Offset( mOnParentResized, GuiScriptNotifyCtrl ), "Enables/disables onParentResized callback" ); addField("notifyOnParentResized", TypeBool, Offset( mOnParentResized, GuiScriptNotifyCtrl ), "Enables/disables onParentResized callback" );
addField("onResize", TypeBool, Offset( mOnResize, GuiScriptNotifyCtrl ), "Enables/disables onResize callback" ); addField("notifyOnResize", TypeBool, Offset( mOnResize, GuiScriptNotifyCtrl ), "Enables/disables onResize callback" );
addField("onLoseFirstResponder", TypeBool, Offset( mOnLoseFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onLoseFirstResponder callback" ); addField("notifyOnLoseFirstResponder", TypeBool, Offset( mOnLoseFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onLoseFirstResponder callback" );
addField("onGainFirstResponder", TypeBool, Offset( mOnGainFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onGainFirstResponder callback" ); addField("notifyOnGainFirstResponder", TypeBool, Offset( mOnGainFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onGainFirstResponder callback" );
endGroup("Callbacks"); endGroup("Callbacks");
Parent::initPersistFields(); Parent::initPersistFields();

View file

@ -89,7 +89,7 @@ DefineEngineStringlyVariadicMethod( GuiFilterCtrl, setValue, void, 3, 20, "(f1,
object->set(filter); object->set(filter);
} }
DefineEngineMethod( GuiFilterCtrl, identity, void, (), , "Reset the filtering." DefineEngineMethod( GuiFilterCtrl, resetFiltering, void, (), , "Reset the filtering."
"@internal") "@internal")
{ {
object->identity(); object->identity();

View file

@ -306,8 +306,6 @@ void Material::initPersistFields()
addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES, addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES,
"The input channel metalness maps use."); "The input channel metalness maps use.");
addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES,
"The input channel metalness maps use.");
addField("glow", TypeBool, Offset(mGlow, Material), MAX_STAGES, addField("glow", TypeBool, Offset(mGlow, Material), MAX_STAGES,
"Enables rendering as glowing."); "Enables rendering as glowing.");

View file

@ -26,6 +26,8 @@
#include "math/mMatrix.h" #include "math/mMatrix.h"
#include "console/console.h" #include "console/console.h"
#include "console/enginePrimitives.h"
#include "console/engineTypes.h"
const MatrixF MatrixF::Identity( true ); const MatrixF MatrixF::Identity( true );
@ -192,4 +194,10 @@ void MatrixF::dumpMatrix(const char *caption /* =NULL */) const
Con::printf("%s | %-8.4f %-8.4f %-8.4f %-8.4f |", spacerRef, m[idx(1,0)], m[idx(1, 1)], m[idx(1, 2)], m[idx(1, 3)]); Con::printf("%s | %-8.4f %-8.4f %-8.4f %-8.4f |", spacerRef, m[idx(1,0)], m[idx(1, 1)], m[idx(1, 2)], m[idx(1, 3)]);
Con::printf("%s | %-8.4f %-8.4f %-8.4f %-8.4f |", spacerRef, m[idx(2,0)], m[idx(2, 1)], m[idx(2, 2)], m[idx(2, 3)]); Con::printf("%s | %-8.4f %-8.4f %-8.4f %-8.4f |", spacerRef, m[idx(2,0)], m[idx(2, 1)], m[idx(2, 2)], m[idx(2, 3)]);
Con::printf("%s | %-8.4f %-8.4f %-8.4f %-8.4f |", spacerRef, m[idx(3,0)], m[idx(3, 1)], m[idx(3, 2)], m[idx(3, 3)]); Con::printf("%s | %-8.4f %-8.4f %-8.4f %-8.4f |", spacerRef, m[idx(3,0)], m[idx(3, 1)], m[idx(3, 2)], m[idx(3, 3)]);
} }
EngineFieldTable::Field MatrixFEngineExport::getMatrixField()
{
typedef MatrixF ThisType;
return _FIELD_AS(F32, m, m, 16, "");
}

View file

@ -35,12 +35,18 @@
#include "math/mPoint4.h" #include "math/mPoint4.h"
#endif #endif
#ifndef _ENGINETYPEINFO_H_
#include "console/engineTypeInfo.h"
#endif
/// 4x4 Matrix Class /// 4x4 Matrix Class
/// ///
/// This runs at F32 precision. /// This runs at F32 precision.
class MatrixF class MatrixF
{ {
friend class MatrixFEngineExport;
private: private:
F32 m[16]; ///< Note: Torque uses row-major matrices F32 m[16]; ///< Note: Torque uses row-major matrices
@ -224,6 +230,12 @@ public:
const static MatrixF Identity; const static MatrixF Identity;
}; };
class MatrixFEngineExport
{
public:
static EngineFieldTable::Field getMatrixField();
};
//-------------------------------------- //--------------------------------------
// Inline Functions // Inline Functions

View file

@ -88,30 +88,59 @@ END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( RectI, IMPLEMENT_STRUCT( RectI,
RectI, MathTypes, RectI, MathTypes,
"" ) "" )
FIELD( point, point, 1, "The XY coordinate of the Rect." )
FIELD( extent, extent, 1, "The width and height of the Rect." )
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( RectF, IMPLEMENT_STRUCT( RectF,
RectF, MathTypes, RectF, MathTypes,
"" ) "" )
FIELD( point, point, 1, "The XY coordinate of the Rect.")
FIELD( extent, extent, 1, "The width and height of the Rect.")
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( MatrixF, IMPLEMENT_STRUCT( MatrixF,
MatrixF, MathTypes, MatrixF, MathTypes,
"" ) "" )
MatrixFEngineExport::getMatrixField(),
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( AngAxisF, IMPLEMENT_STRUCT( AngAxisF,
AngAxisF, MathTypes, AngAxisF, MathTypes,
"" ) "" )
FIELD( axis, axis, 1, "")
FIELD( angle, angle, 1, "")
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( TransformF, IMPLEMENT_STRUCT( TransformF,
TransformF, MathTypes, TransformF, MathTypes,
"" ) "" )
FIELD(mPosition, position, 1, "")
FIELD(mOrientation, orientation, 1, "")
FIELD(mHasRotation, hasRotation, 1, "")
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Box3F, IMPLEMENT_STRUCT( Box3F,
Box3F, MathTypes, Box3F, MathTypes,
"" ) "" )
FIELD(minExtents, minExtents, 1, "Minimum extents of box")
FIELD(maxExtents, maxExtents, 1, "Maximum extents of box")
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( EaseF, IMPLEMENT_STRUCT( EaseF,
EaseF, MathTypes, EaseF, MathTypes,
"" ) "" )
FIELD(mDir, dir, 1, "inout, in, out")
FIELD(mType, type, 1, "linear, etc...")
FIELD_AS(F32, mParam, param, 2, "optional params")
END_IMPLEMENT_STRUCT; END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT(RotationF, IMPLEMENT_STRUCT(RotationF,
RotationF, MathTypes, RotationF, MathTypes,
@ -347,7 +376,7 @@ ConsoleSetType( TypeMatrixF )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// TypeMatrixPosition // TypeMatrixPosition
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ConsoleType(MatrixPosition, TypeMatrixPosition, MatrixF, "") ConsoleMappedType(MatrixPosition, TypeMatrixPosition, Point3F, MatrixF, "")
ConsoleGetType( TypeMatrixPosition ) ConsoleGetType( TypeMatrixPosition )
{ {
@ -382,7 +411,7 @@ ConsoleSetType( TypeMatrixPosition )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// TypeMatrixRotation // TypeMatrixRotation
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
ConsoleType(MatrixRotation, TypeMatrixRotation, MatrixF, "") ConsoleMappedType(MatrixRotation, TypeMatrixRotation, AngAxisF, MatrixF, "")
ConsoleGetType( TypeMatrixRotation ) ConsoleGetType( TypeMatrixRotation )
{ {

View file

@ -82,8 +82,6 @@ void ModuleDefinition::initPersistFields()
// Call parent. // Call parent.
Parent::initPersistFields(); Parent::initPersistFields();
addProtectedField("ModuleId", TypeString, Offset(mModuleId, ModuleDefinition), &defaultProtectedSetFn, &defaultProtectedGetFn, "");
/// Module configuration. /// Module configuration.
addProtectedField( "ModuleId", TypeString, Offset(mModuleId, ModuleDefinition), &setModuleId, &defaultProtectedGetFn, "A unique string Id for the module. It can contain any characters except a comma or semi-colon (the asset scope character)." ); addProtectedField( "ModuleId", TypeString, Offset(mModuleId, ModuleDefinition), &setModuleId, &defaultProtectedGetFn, "A unique string Id for the module. It can contain any characters except a comma or semi-colon (the asset scope character)." );
addProtectedField( "VersionId", TypeS32, Offset(mVersionId, ModuleDefinition), &setVersionId, &defaultProtectedGetFn, "The version Id. Breaking changes to a module should use a higher version Id." ); addProtectedField( "VersionId", TypeS32, Offset(mVersionId, ModuleDefinition), &setVersionId, &defaultProtectedGetFn, "The version Id. Breaking changes to a module should use a higher version Id." );

View file

@ -38,6 +38,8 @@
#include "console/consoleTypes.h" #include "console/consoleTypes.h"
#endif #endif
#include "cinterface/cinterface.h"
#ifndef _MODULE_DEFINITION_H #ifndef _MODULE_DEFINITION_H
#include "module/moduleDefinition.h" #include "module/moduleDefinition.h"
#endif #endif
@ -837,16 +839,7 @@ bool ModuleManager::loadModuleExplicit( const char* pModuleId, const U32 version
const bool scriptFileExecuted = dAtob( Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath() ) ); const bool scriptFileExecuted = dAtob( Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath() ) );
// Did we execute the script file? // Did we execute the script file?
if ( scriptFileExecuted ) if ( !scriptFileExecuted )
{
// Yes, so is the create method available?
if ( pScopeSet->isMethod( pLoadReadyModuleDefinition->getCreateFunction() ) )
{
// Yes, so call the create method.
Con::executef( pScopeSet, pLoadReadyModuleDefinition->getCreateFunction() );
}
}
else
{ {
// No, so warn. // No, so warn.
Con::errorf( "Module Manager: Cannot load explicit module Id '%s' at version Id '%d' as it failed to have the script file '%s' loaded.", Con::errorf( "Module Manager: Cannot load explicit module Id '%s' at version Id '%d' as it failed to have the script file '%s' loaded.",
@ -854,6 +847,13 @@ bool ModuleManager::loadModuleExplicit( const char* pModuleId, const U32 version
} }
} }
// Is the create method available?
if (pScopeSet->isMethod(pLoadReadyModuleDefinition->getCreateFunction()))
{
// Yes, so call the create method.
Con::executef(pScopeSet, pLoadReadyModuleDefinition->getCreateFunction());
}
// Raise notifications. // Raise notifications.
raiseModulePostLoadNotifications( pLoadReadyModuleDefinition ); raiseModulePostLoadNotifications( pLoadReadyModuleDefinition );
} }

View file

@ -567,7 +567,7 @@ void PostEffect::initPersistFields()
addField( "allowReflectPass", TypeBool, Offset( mAllowReflectPass, PostEffect ), addField( "allowReflectPass", TypeBool, Offset( mAllowReflectPass, PostEffect ),
"Is this effect processed during reflection render passes." ); "Is this effect processed during reflection render passes." );
addProtectedField( "isEnabled", TypeBool, Offset( mEnabled, PostEffect), addProtectedField( "enabled", TypeBool, Offset( mEnabled, PostEffect),
&PostEffect::_setIsEnabled, &defaultProtectedGetFn, &PostEffect::_setIsEnabled, &defaultProtectedGetFn,
"Is the effect on." ); "Is the effect on." );

View file

@ -425,8 +425,8 @@ void SFXDescription::initPersistFields()
"Reverb echo depth."); "Reverb echo depth.");
addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXDescription), addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXDescription),
"Reverb Modulation time."); "Reverb Modulation time.");
addField("reverbModTime", TypeF32, Offset(mReverb.flModulationDepth, SFXDescription), addField("reverbModDepth", TypeF32, Offset(mReverb.flModulationDepth, SFXDescription),
"Reverb Modulation time."); "Reverb Modulation Depth.");
addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription), addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription),
"High Frequency air absorbtion"); "High Frequency air absorbtion");
addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXDescription), addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXDescription),

View file

@ -1532,6 +1532,7 @@ DefineEngineMethod( SFXSource, setPitch, void, ( F32 pitch ),,
// Need an overload here as we can't use a default parameter to signal omission of the direction argument // Need an overload here as we can't use a default parameter to signal omission of the direction argument
// and we need to properly detect the omission to leave the currently set direction on the source as is. // and we need to properly detect the omission to leave the currently set direction on the source as is.
/* LukasPJ: For now, just use the setTransform with strings as parameters.
DEFINE_CALLIN( fnSFXSoure_setTransform1, setTransform, SFXSource, void, ( SFXSource* source, const VectorF& position ),,, DEFINE_CALLIN( fnSFXSoure_setTransform1, setTransform, SFXSource, void, ( SFXSource* source, const VectorF& position ),,,
"Set the position of the source's 3D sound.\n\n" "Set the position of the source's 3D sound.\n\n"
"@param position The new position in world space.\n" "@param position The new position in world space.\n"
@ -1551,6 +1552,7 @@ DEFINE_CALLIN( fnSFXSoure_setTransform2, setTransform, SFXSource, void, ( SFXSou
mat.setColumn( 1, direction ); mat.setColumn( 1, direction );
source->setTransform( mat ); source->setTransform( mat );
} }
*/
// Console interop version. // Console interop version.

View file

@ -565,7 +565,7 @@ DefineEngineMethod(UndoManager, getNextRedoName, const char *, (),, "UndoManager
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineMethod( UndoManager, pushCompound, const char*, ( String name ), ("\"\""), "( string name=\"\" ) - Push a CompoundUndoAction onto the compound stack for assembly." ) DefineEngineMethod( UndoManager, pushCompound, const char*, ( String name ), (""), "( string name=\"\" ) - Push a CompoundUndoAction onto the compound stack for assembly." )
{ {
CompoundUndoAction* action = object->pushCompound( name ); CompoundUndoAction* action = object->pushCompound( name );

View file

@ -27,11 +27,10 @@ function CoreModule::onCreate(%this)
ModuleDatabase.LoadExplicit( "Core_PostFX" ); ModuleDatabase.LoadExplicit( "Core_PostFX" );
ModuleDatabase.LoadExplicit( "Core_GameObjects" ); ModuleDatabase.LoadExplicit( "Core_GameObjects" );
exec("data/defaults.cs");
%prefPath = getPrefpath(); %prefPath = getPrefpath();
if ( isFile( %prefPath @ "/clientPrefs.cs" ) ) if ( isFile( %prefPath @ "/clientPrefs.cs" ) )
exec( %prefPath @ "/clientPrefs.cs" ); exec( %prefPath @ "/clientPrefs.cs" );
else
exec("data/defaults.cs");
// Seed the random number generator. // Seed the random number generator.
setRandomSeed(); setRandomSeed();

View file

@ -15,11 +15,10 @@ function initClient()
exec( "./levelLoad.cs" ); exec( "./levelLoad.cs" );
//load prefs //load prefs
exec( "data/defaults.cs" );
%prefPath = getPrefpath(); %prefPath = getPrefpath();
if ( isFile( %prefPath @ "/clientPrefs.cs" ) ) if ( isFile( %prefPath @ "/clientPrefs.cs" ) )
exec( %prefPath @ "/clientPrefs.cs" ); exec( %prefPath @ "/clientPrefs.cs" );
else
exec( "data/defaults.cs" );
callOnModules("initClient"); callOnModules("initClient");

View file

@ -133,7 +133,7 @@ function configureCanvas()
// It's formatted as AATypexAALevel // It's formatted as AATypexAALevel
// So, FXAAx4 or MLAAx2 // So, FXAAx4 or MLAAx2
if ( isObject( FXAA_PostEffect ) ) if ( isObject( FXAA_PostEffect ) )
FXAA_PostEffect.isEnabled = ( %aa > 0 ) ? true : false; FXAA_PostEffect.Enabled = ( %aa > 0 ) ? true : false;
} }
function GuiCanvas::modeStrToPrefs(%this, %modeStr) function GuiCanvas::modeStrToPrefs(%this, %modeStr)

View file

@ -64,7 +64,7 @@ singleton CustomMaterial( BL_ProjectedShadowMaterial )
function onActivateBasicLM() function onActivateBasicLM()
{ {
// If HDR is enabled... enable the special format token. // If HDR is enabled... enable the special format token.
if ( HDRPostFx.isEnabled ) if ( HDRPostFx.Enabled )
AL_FormatToken.enable(); AL_FormatToken.enable();
// Create render pass for projected shadow. // Create render pass for projected shadow.

View file

@ -113,7 +113,7 @@ function CameraMotionBlurPostFX::savePresetSettings(%this)
//Our actual postFX //Our actual postFX
singleton PostEffect( CameraMotionBlurPostFX ) singleton PostEffect( CameraMotionBlurPostFX )
{ {
isEnabled = false; enabled = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";
shader = CameraMotionBlurPostFX_Shader; shader = CameraMotionBlurPostFX_Shader;

View file

@ -50,7 +50,7 @@ singleton ShaderData( PFX_CausticsShader )
singleton PostEffect( CausticsPFX ) singleton PostEffect( CausticsPFX )
{ {
isEnabled = false; enabled = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";
renderBin = "ObjTranslucentBin"; renderBin = "ObjTranslucentBin";
//renderPriority = 0.1; //renderPriority = 0.1;

View file

@ -132,7 +132,7 @@ function ChromaticAberrationPostFX::savePresetSettings(%this)
//Our actual postFX //Our actual postFX
singleton PostEffect( ChromaticAberrationPostFX ) singleton PostEffect( ChromaticAberrationPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff

View file

@ -404,7 +404,7 @@ function DepthOfFieldPostFX::setLerpDist( %this, %d0, %d1, %d2 )
singleton PostEffect( DepthOfFieldPostFX ) singleton PostEffect( DepthOfFieldPostFX )
{ {
isEnabled = false; enabled = false;
renderTime = "PFXAfterBin"; renderTime = "PFXAfterBin";
renderBin = "GlowBin"; renderBin = "GlowBin";

View file

@ -84,7 +84,7 @@ singleton PostEffect( EdgeDetectPostEffect )
texture[0] = "#deferred"; texture[0] = "#deferred";
target = "#edge"; target = "#edge";
isEnabled = true; enabled = true;
}; };
singleton PostEffect( EdgeAAPostEffect ) singleton PostEffect( EdgeAAPostEffect )

View file

@ -49,7 +49,7 @@ singleton ShaderData( FXAA_ShaderData )
singleton PostEffect( FXAAPostFX ) singleton PostEffect( FXAAPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";

View file

@ -37,7 +37,7 @@ singleton ShaderData( PFX_FlashShader )
singleton PostEffect( FlashFx ) singleton PostEffect( FlashFx )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";

View file

@ -63,5 +63,5 @@ singleton PostEffect( fogPostFX )
renderPriority = 5; renderPriority = 5;
targetFormat = getBestHDRFormat(); targetFormat = getBestHDRFormat();
isEnabled = true; enabled = true;
}; };

View file

@ -43,7 +43,7 @@ singleton GFXStateBlockData( GammaStateBlock : PFX_DefaultStateBlock )
singleton PostEffect( GammaPostFX ) singleton PostEffect( GammaPostFX )
{ {
isEnabled = true; enabled = true;
allowReflectPass = true; allowReflectPass = true;
renderTime = "PFXBeforeBin"; renderTime = "PFXBeforeBin";

View file

@ -77,7 +77,7 @@ singleton PostEffect( GlowPostFX )
target = "$outTex"; target = "$outTex";
targetScale = "0.5 0.5"; targetScale = "0.5 0.5";
isEnabled = true; enabled = true;
// Blur vertically // Blur vertically
new PostEffect() new PostEffect()
@ -146,7 +146,7 @@ singleton PostEffect( VolFogGlowPostFx )
texture[0] = "$backbuffer"; texture[0] = "$backbuffer";
target = "$outTex"; target = "$outTex";
targetScale = "0.5 0.5"; targetScale = "0.5 0.5";
isEnabled = false; enabled = false;
// Blur vertically // Blur vertically
new PostEffect() new PostEffect()
{ {

View file

@ -412,7 +412,7 @@ function HDRPostFX::savePresetSettings(%this)
singleton PostEffect( HDRPostFX ) singleton PostEffect( HDRPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff
@ -580,7 +580,7 @@ function LuminanceVisPostFX::setShaderConsts( %this )
singleton PostEffect( LuminanceVisPostFX ) singleton PostEffect( LuminanceVisPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
// Render before we do any editor rendering. // Render before we do any editor rendering.

View file

@ -120,7 +120,7 @@ function LUTColorGradePostFX::savePresetSettings(%this)
//Our actual postFX //Our actual postFX
singleton PostEffect( LUTColorGradePostFX ) singleton PostEffect( LUTColorGradePostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff

View file

@ -69,7 +69,7 @@ singleton GFXStateBlockData( LightRayStateBlock : PFX_DefaultStateBlock )
singleton PostEffect( LightRayPostFX ) singleton PostEffect( LightRayPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
renderTime = "PFXBeforeBin"; renderTime = "PFXBeforeBin";

View file

@ -119,7 +119,7 @@ singleton ShaderData( MLAA_NeighborhoodBlendingShader )
singleton PostEffect( MLAAFx ) singleton PostEffect( MLAAFx )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";

View file

@ -7,7 +7,7 @@ singleton PostEffect( reflectionProbeArrayPostFX )
renderTime = "PFXAfterBin"; renderTime = "PFXAfterBin";
renderBin = "ProbeBin"; renderBin = "ProbeBin";
renderPriority = 9999; renderPriority = 9999;
isEnabled = true; enabled = true;
shader = PFX_ReflectionProbeArray; shader = PFX_ReflectionProbeArray;
stateBlock = PFX_ReflectionProbeArrayStateBlock; stateBlock = PFX_ReflectionProbeArrayStateBlock;

View file

@ -121,7 +121,7 @@ function SharpenPostFX::savePresetSettings(%this)
//Our actual postFX //Our actual postFX
singleton PostEffect( SharpenPostFX ) singleton PostEffect( SharpenPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff

View file

@ -44,7 +44,7 @@ singleton ShaderData( PFX_TurbulenceShader )
singleton PostEffect( TurbulencePostFX ) singleton PostEffect( TurbulencePostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = true; allowReflectPass = true;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";

View file

@ -70,7 +70,7 @@ singleton PostEffect( underWaterFogPostFX )
// Needs to happen after the FogPostFx // Needs to happen after the FogPostFx
renderPriority = 4; renderPriority = 4;
isEnabled = true; enabled = true;
}; };
function underWaterFogPostFX::onEnabled( %this ) function underWaterFogPostFX::onEnabled( %this )

View file

@ -81,7 +81,7 @@ singleton GFXStateBlockData( OVRBarrelDistortionStateBlock : PFX_DefaultStateBlo
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
singleton BarrelDistortionPostEffect( OVRBarrelDistortionPostFX ) singleton BarrelDistortionPostEffect( OVRBarrelDistortionPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";
@ -107,7 +107,7 @@ singleton BarrelDistortionPostEffect( OVRBarrelDistortionPostFX )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
singleton BarrelDistortionPostEffect( OVRBarrelDistortionChromaPostFX ) singleton BarrelDistortionPostEffect( OVRBarrelDistortionChromaPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";
@ -132,7 +132,7 @@ singleton BarrelDistortionPostEffect( OVRBarrelDistortionChromaPostFX )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
singleton PostEffect( OVRBarrelDistortionMonoPostFX ) singleton PostEffect( OVRBarrelDistortionMonoPostFX )
{ {
isEnabled = false; enabled = false;
allowReflectPass = false; allowReflectPass = false;
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";

View file

@ -119,7 +119,7 @@ function VignettePostFX::savePresetSettings(%this)
//Our actual postFX //Our actual postFX
singleton PostEffect( VignettePostFX ) singleton PostEffect( VignettePostFX )
{ {
isEnabled = false; enabled = false;
renderTime = "PFXBeforeBin"; renderTime = "PFXBeforeBin";
renderBin = "EditorBin"; renderBin = "EditorBin";

View file

@ -36,7 +36,7 @@ singleton PostEffect( afxHighlightPostFX )
renderTime = "PFXAfterDiffuse"; renderTime = "PFXAfterDiffuse";
renderBin = "HighlightBin"; renderBin = "HighlightBin";
renderPriority = 1; renderPriority = 1;
isEnabled = true; enabled = true;
shader = PFX_afxHighlightShader; shader = PFX_afxHighlightShader;
stateBlock = PFX_afxDefaultHighlightStateBlock; stateBlock = PFX_afxDefaultHighlightStateBlock;

View file

@ -122,7 +122,7 @@ function PostFXManager::savePresetHandler( %filename )
{ {
%postEffect = PostFXManager.getKey(%i); %postEffect = PostFXManager.getKey(%i);
if(isObject(%postEffect) && %postEffect.isEnabled && %postEffect.isMethod("savePresetSettings")) if(isObject(%postEffect) && %postEffect.Enabled && %postEffect.isMethod("savePresetSettings"))
{ {
%postEffect.savePresetSettings(); %postEffect.savePresetSettings();
} }

View file

@ -33,11 +33,10 @@ function Core_Rendering::initClient(%this)
initLightingSystems("Advanced Lighting"); initLightingSystems("Advanced Lighting");
//load prefs //load prefs
exec("data/defaults.cs");
%prefPath = getPrefpath(); %prefPath = getPrefpath();
if ( isFile( %prefPath @ "/clientPrefs.cs" ) ) if ( isFile( %prefPath @ "/clientPrefs.cs" ) )
exec( %prefPath @ "/clientPrefs.cs" ); exec( %prefPath @ "/clientPrefs.cs" );
else
exec("data/defaults.cs");
configureCanvas(); configureCanvas();

View file

@ -125,7 +125,7 @@ singleton PostEffect( AL_FormatCopy )
{ {
// This PostEffect is used by 'AL_FormatToken' directly. It is never added to // This PostEffect is used by 'AL_FormatToken' directly. It is never added to
// the PostEffectManager. Do not call enable() on it. // the PostEffectManager. Do not call enable() on it.
isEnabled = false; enabled = false;
allowReflectPass = true; allowReflectPass = true;
shader = PFX_PassthruShader; shader = PFX_PassthruShader;

View file

@ -24,7 +24,7 @@
#include "./brdf.glsl" #include "./brdf.glsl"
#ifndef TORQUE_SHADERGEN #ifndef TORQUE_SHADERGEN
#line 26 #line 27
// These are the uniforms used by most lighting shaders. // These are the uniforms used by most lighting shaders.
uniform vec4 inLightPos[4]; uniform vec4 inLightPos[4];
@ -52,6 +52,18 @@ uniform vec4 albedo;
#define MAX_FORWARD_LIGHT 4 #define MAX_FORWARD_LIGHT 4
#ifndef CAPTURING
#define CAPTURING 0
#endif
#ifndef DEBUGVIZ_ATTENUATION
#define DEBUGVIZ_ATTENUATION 0
#endif
#ifndef DEBUGVIZ_CONTRIB
#define DEBUGVIZ_CONTRIB 0
#endif
vec3 getDistanceVectorToPlane( vec3 origin, vec3 direction, vec4 plane ) vec3 getDistanceVectorToPlane( vec3 origin, vec3 direction, vec4 plane )
{ {
float denum = dot( plane.xyz, direction.xyz ); float denum = dot( plane.xyz, direction.xyz );
@ -416,7 +428,7 @@ vec4 computeForwardProbes(Surface surface,
} }
} }
#if DEBUGVIZ_ATTENUATION == 1 #if (DEBUGVIZ_ATTENUATION == 1)
float contribAlpha = 1; float contribAlpha = 1;
for (i = 0; i < numProbes; ++i) for (i = 0; i < numProbes; ++i)
{ {
@ -426,7 +438,7 @@ vec4 computeForwardProbes(Surface surface,
return vec4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1); return vec4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1);
#endif #endif
#if DEBUGVIZ_CONTRIB == 1 #if (DEBUGVIZ_CONTRIB == 1)
vec3 probeContribColors[4]; vec3 probeContribColors[4];
probeContribColors[0] = vec3(1,0,0); probeContribColors[0] = vec3(1,0,0);
probeContribColors[1] = vec3(0,1,0); probeContribColors[1] = vec3(0,1,0);
@ -653,4 +665,4 @@ vec4 debugVizForwardProbes(Surface surface,
horizon *= horizon; horizon *= horizon;
return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled
} }

View file

@ -53,6 +53,18 @@ uniform float4 albedo;
#define MAX_FORWARD_LIGHT 4 #define MAX_FORWARD_LIGHT 4
#ifndef CAPTURING
#define CAPTURING 0
#endif
#ifndef DEBUGVIZ_ATTENUATION
#define DEBUGVIZ_ATTENUATION 0
#endif
#ifndef DEBUGVIZ_CONTRIB
#define DEBUGVIZ_CONTRIB 0
#endif
inline float3 getDistanceVectorToPlane( float3 origin, float3 direction, float4 plane ) inline float3 getDistanceVectorToPlane( float3 origin, float3 direction, float4 plane )
{ {
float denum = dot( plane.xyz, direction.xyz ); float denum = dot( plane.xyz, direction.xyz );

View file

@ -59,13 +59,13 @@
childMargin = "0 0"; childMargin = "0 0";
new GuiScriptNotifyCtrl(VerveEditorGroupNotify) { new GuiScriptNotifyCtrl(VerveEditorGroupNotify) {
onChildAdded = "0"; notifyOnChildAdded = "0";
onChildRemoved = "0"; notifyOnChildRemoved = "0";
onChildResized = "0"; notifyOnChildResized = "0";
onParentResized = "1"; notifyOnParentResized = "1";
onResize = "1"; notifyOnResize = "1";
onLoseFirstResponder = "0"; notifyOnLoseFirstResponder = "0";
onGainFirstResponder = "0"; notifyOnGainFirstResponder = "0";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
class = "VerveEditorScrollNotifyV"; class = "VerveEditorScrollNotifyV";
className = "VerveEditorScrollNotifyV"; className = "VerveEditorScrollNotifyV";
@ -155,13 +155,13 @@
childMargin = "0 0"; childMargin = "0 0";
new GuiScriptNotifyCtrl(VerveEditorTrackNotify) { new GuiScriptNotifyCtrl(VerveEditorTrackNotify) {
onChildAdded = "0"; notifyOnChildAdded = "0";
onChildRemoved = "0"; notifyOnChildRemoved = "0";
onChildResized = "0"; notifyOnChildResized = "0";
onParentResized = "1"; notifyOnParentResized = "1";
onResize = "1"; notifyOnResize = "1";
onLoseFirstResponder = "0"; notifyOnLoseFirstResponder = "0";
onGainFirstResponder = "0"; notifyOnGainFirstResponder = "0";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
class = "VerveEditorScrollNotify"; class = "VerveEditorScrollNotify";
className = "VerveEditorScrollNotify"; className = "VerveEditorScrollNotify";
@ -406,13 +406,13 @@
childMargin = "0 0"; childMargin = "0 0";
new GuiScriptNotifyCtrl(VerveEditorTimeNotify) { new GuiScriptNotifyCtrl(VerveEditorTimeNotify) {
onChildAdded = "0"; notifyOnChildAdded = "0";
onChildRemoved = "0"; notifyOnChildRemoved = "0";
onChildResized = "0"; notifyOnChildResized = "0";
onParentResized = "1"; notifyOnParentResized = "1";
onResize = "1"; notifyOnResize = "1";
onLoseFirstResponder = "0"; notifyOnLoseFirstResponder = "0";
onGainFirstResponder = "0"; notifyOnGainFirstResponder = "0";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
class = "VerveEditorScrollNotifyH"; class = "VerveEditorScrollNotifyH";
className = "VerveEditorScrollNotifyH"; className = "VerveEditorScrollNotifyH";

View file

@ -46,7 +46,7 @@ function GuiEdit( %val )
//Temp fix to disable MLAA when in GUI editor //Temp fix to disable MLAA when in GUI editor
if( isObject(MLAAFx) && MLAAFx.isEnabled==true ) if( isObject(MLAAFx) && MLAAFx.isEnabled==true )
{ {
MLAAFx.isEnabled = false; MLAAFx.Enabled = false;
$MLAAFxGuiEditorTemp = true; $MLAAFxGuiEditorTemp = true;
} }

View file

@ -544,7 +544,7 @@ function GuiEditCanvas::quit( %this )
//Temp fix to disable MLAA when in GUI editor //Temp fix to disable MLAA when in GUI editor
if( isObject(MLAAFx) && $MLAAFxGuiEditorTemp==true ) if( isObject(MLAAFx) && $MLAAFxGuiEditorTemp==true )
{ {
MLAAFx.isEnabled = true; MLAAFx.Enabled = true;
$MLAAFxGuiEditorTemp = false; $MLAAFxGuiEditorTemp = false;
} }
} }