From eb365fc8660c84dfd4ca1d8065b8148f16fbcd81 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 4 Nov 2020 16:31:17 -0600 Subject: [PATCH 01/36] be sure to executte defaults prior to clientprefs to ensure nothing gets missed --- Templates/BaseGame/game/core/Core.cs | 3 +-- .../BaseGame/game/core/clientServer/scripts/client/client.cs | 3 +-- Templates/BaseGame/game/core/rendering/Core_Rendering.cs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Templates/BaseGame/game/core/Core.cs b/Templates/BaseGame/game/core/Core.cs index ecf508046..b03ba52c7 100644 --- a/Templates/BaseGame/game/core/Core.cs +++ b/Templates/BaseGame/game/core/Core.cs @@ -27,11 +27,10 @@ function CoreModule::onCreate(%this) ModuleDatabase.LoadExplicit( "Core_PostFX" ); ModuleDatabase.LoadExplicit( "Core_GameObjects" ); + exec("data/defaults.cs"); %prefPath = getPrefpath(); if ( isFile( %prefPath @ "/clientPrefs.cs" ) ) exec( %prefPath @ "/clientPrefs.cs" ); - else - exec("data/defaults.cs"); // Seed the random number generator. setRandomSeed(); diff --git a/Templates/BaseGame/game/core/clientServer/scripts/client/client.cs b/Templates/BaseGame/game/core/clientServer/scripts/client/client.cs index 6547e9915..0dc47139a 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/client/client.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/client/client.cs @@ -15,11 +15,10 @@ function initClient() exec( "./levelLoad.cs" ); //load prefs + exec( "data/defaults.cs" ); %prefPath = getPrefpath(); if ( isFile( %prefPath @ "/clientPrefs.cs" ) ) exec( %prefPath @ "/clientPrefs.cs" ); - else - exec( "data/defaults.cs" ); callOnModules("initClient"); diff --git a/Templates/BaseGame/game/core/rendering/Core_Rendering.cs b/Templates/BaseGame/game/core/rendering/Core_Rendering.cs index 5bda82abb..653482d43 100644 --- a/Templates/BaseGame/game/core/rendering/Core_Rendering.cs +++ b/Templates/BaseGame/game/core/rendering/Core_Rendering.cs @@ -33,11 +33,10 @@ function Core_Rendering::initClient(%this) initLightingSystems("Advanced Lighting"); //load prefs + exec("data/defaults.cs"); %prefPath = getPrefpath(); if ( isFile( %prefPath @ "/clientPrefs.cs" ) ) exec( %prefPath @ "/clientPrefs.cs" ); - else - exec("data/defaults.cs"); configureCanvas(); From d76a76a1c4777510fa0a37ee5c2390bf9394f687 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 10 Nov 2020 13:57:26 -0600 Subject: [PATCH 02/36] shader preprocessor fixes some hardware/apis do not evalueate 'not defined' as '0', so always ensure there's *some* value when doing macro value comparisons --- .../core/rendering/shaders/gl/lighting.glsl | 22 ++++++++++++++----- .../game/core/rendering/shaders/lighting.hlsl | 12 ++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index 2fc447a95..e94081142 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -24,7 +24,7 @@ #include "./brdf.glsl" #ifndef TORQUE_SHADERGEN -#line 26 +#line 27 // These are the uniforms used by most lighting shaders. uniform vec4 inLightPos[4]; @@ -52,6 +52,18 @@ uniform vec4 albedo; #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 ) { float denum = dot( plane.xyz, direction.xyz ); @@ -219,7 +231,7 @@ vec3 evaluateStandardBRDF(Surface surface, SurfaceToLight surfaceToLight) float D = D_GGX(surfaceToLight.NdotH, surface.linearRoughnessSq); vec3 Fr = D * F * Vis; -#if CAPTURING == true +#if (CAPTURING == 1) return mix(Fd + Fr,surface.f0,surface.metalness); #else return Fd + Fr; @@ -416,7 +428,7 @@ vec4 computeForwardProbes(Surface surface, } } -#if DEBUGVIZ_ATTENUATION == 1 +#if (DEBUGVIZ_ATTENUATION == 1) float contribAlpha = 1; for (i = 0; i < numProbes; ++i) { @@ -426,7 +438,7 @@ vec4 computeForwardProbes(Surface surface, return vec4(1 - contribAlpha, 1 - contribAlpha, 1 - contribAlpha, 1); #endif -#if DEBUGVIZ_CONTRIB == 1 +#if (DEBUGVIZ_CONTRIB == 1) vec3 probeContribColors[4]; probeContribColors[0] = vec3(1,0,0); probeContribColors[1] = vec3(0,1,0); @@ -653,4 +665,4 @@ vec4 debugVizForwardProbes(Surface surface, horizon *= horizon; return vec4((irradiance + specular) * horizon, 0);//alpha writes disabled -} \ No newline at end of file +} diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index b948eae27..8f6ef8c88 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -53,6 +53,18 @@ uniform float4 albedo; #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 ) { float denum = dot( plane.xyz, direction.xyz ); From a241d27b582fa7b51a17cb09bee896309db4509e Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 12:39:41 +0200 Subject: [PATCH 03/36] Expand EngineAPI type definitions --- Engine/source/T3D/trigger.cpp | 5 + Engine/source/console/engineAPI.h | 14 --- Engine/source/console/enginePrimitives.cpp | 13 +++ Engine/source/console/enginePrimitives.h | 21 ++++ Engine/source/console/engineStructs.cpp | 117 +++++++++++++++++---- Engine/source/console/engineStructs.h | 8 ++ Engine/source/console/engineTypes.h | 10 +- Engine/source/core/util/tVector.h | 28 ++++- Engine/source/core/util/uuid.cpp | 40 +++++++ Engine/source/core/util/uuid.h | 13 +++ Engine/source/math/mMatrix.cpp | 10 +- Engine/source/math/mMatrix.h | 12 +++ Engine/source/math/mathTypes.cpp | 29 +++++ 13 files changed, 284 insertions(+), 36 deletions(-) diff --git a/Engine/source/T3D/trigger.cpp b/Engine/source/T3D/trigger.cpp index 824707a5c..e6b1d2027 100644 --- a/Engine/source/T3D/trigger.cpp +++ b/Engine/source/T3D/trigger.cpp @@ -238,6 +238,11 @@ bool Trigger::castRay(const Point3F &start, const Point3F &end, RayInfo* info) DECLARE_STRUCT( Polyhedron ); IMPLEMENT_STRUCT( Polyhedron, Polyhedron,, "" ) + + FIELD(mPointList, pointList, 1, "") + FIELD(mPlaneList, planeList, 1, "") + FIELD(mEdgeList, edgeList, 1, "") + END_IMPLEMENT_STRUCT; ConsoleType(floatList, TypeTriggerPolyhedron, Polyhedron, "") diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 5c9d00dd4..38a3238a6 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -104,20 +104,6 @@ namespace engineAPI { 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 /// /// Functions for converting to/from string-based data representations. diff --git a/Engine/source/console/enginePrimitives.cpp b/Engine/source/console/enginePrimitives.cpp index de5f1f7b3..b189e6156 100644 --- a/Engine/source/console/enginePrimitives.cpp +++ b/Engine/source/console/enginePrimitives.cpp @@ -27,9 +27,22 @@ IMPLEMENT_PRIMITIVE( bool, bool,, "Boolean true/false." ); IMPLEMENT_PRIMITIVE( S8, byte,, "8bit signed 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( U32, uint,, "32bit unsigned integer." ); IMPLEMENT_PRIMITIVE( F32, float,, "32bit single-precision floating-point." ); IMPLEMENT_PRIMITIVE( F64, double,, "64bit double-precision floating-point." ); IMPLEMENT_PRIMITIVE( String, string,, "Null-terminated UTF-16 Unicode string." ); 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." ); diff --git a/Engine/source/console/enginePrimitives.h b/Engine/source/console/enginePrimitives.h index 7f0b37670..59c36d253 100644 --- a/Engine/source/console/enginePrimitives.h +++ b/Engine/source/console/enginePrimitives.h @@ -27,6 +27,8 @@ #include "console/engineTypes.h" #endif +#include "math/mPlane.h" +#include "math/mPolyhedron.h" /// @file /// Definitions for the core primitive types used in the @@ -37,6 +39,8 @@ DECLARE_PRIMITIVE_R( bool ); DECLARE_PRIMITIVE_R(S8); DECLARE_PRIMITIVE_R(U8); +DECLARE_PRIMITIVE_R(S16); +DECLARE_PRIMITIVE_R(U16); DECLARE_PRIMITIVE_R(S32); DECLARE_PRIMITIVE_R(U32); DECLARE_PRIMITIVE_R(F32); @@ -45,6 +49,15 @@ DECLARE_PRIMITIVE_R(U64); DECLARE_PRIMITIVE_R(S64); 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 @@ -80,4 +93,12 @@ template<> struct EngineTypeTraits< const UTF16* > : public EngineTypeTraits< St template<> inline const EngineTypeInfo* TYPE< const UTF16* >() { return TYPE< String >(); } inline const EngineTypeInfo* TYPE( const UTF16*& ) { return TYPE< String >(); } +//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 >(); } + #endif // !_ENGINEPRIMITIVES_H_ diff --git a/Engine/source/console/engineStructs.cpp b/Engine/source/console/engineStructs.cpp index a71922073..3577680cc 100644 --- a/Engine/source/console/engineStructs.cpp +++ b/Engine/source/console/engineStructs.cpp @@ -25,32 +25,42 @@ #include "core/util/tVector.h" #include "core/util/uuid.h" #include "core/color.h" +#include "math/mPolyhedron.h" +IMPLEMENT_STRUCT(PlaneF, + PlaneF, , + "") -IMPLEMENT_STRUCT( Vector< bool >, - BoolVector,, + FIELD(x, x, 1, "") + 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; -IMPLEMENT_STRUCT( Vector< S32 >, - IntVector,, - "" ) +IMPLEMENT_STRUCT(Torque::UUID, + UUID, , + "") + + Torque::UUIDEngineExport::getAField(), + Torque::UUIDEngineExport::getBField(), + Torque::UUIDEngineExport::getCField(), + Torque::UUIDEngineExport::getDField(), + Torque::UUIDEngineExport::getEField(), + Torque::UUIDEngineExport::getFField(), + END_IMPLEMENT_STRUCT; - -IMPLEMENT_STRUCT( Vector< F32 >, - FloatVector,, - "" ) -END_IMPLEMENT_STRUCT; - - -IMPLEMENT_STRUCT( Torque::UUID, - UUID,, - "" ) -END_IMPLEMENT_STRUCT; - - IMPLEMENT_STRUCT( ColorI, ColorI,, "RGBA color quadruple in 8bit integer precision per channel." ) @@ -73,3 +83,74 @@ IMPLEMENT_STRUCT( LinearColorF, FIELD( alpha, alpha, 1, "Alpha channel value." ) 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; diff --git a/Engine/source/console/engineStructs.h b/Engine/source/console/engineStructs.h index 8cbfad329..57b9a4050 100644 --- a/Engine/source/console/engineStructs.h +++ b/Engine/source/console/engineStructs.h @@ -27,6 +27,8 @@ #include "console/engineTypes.h" #endif +#include "math/mPlane.h" +#include "math/mPolyhedron.h" /// @file /// Definitions for the core engine structured types. @@ -44,6 +46,12 @@ class LinearColorF; DECLARE_STRUCT_R(Vector< bool >); DECLARE_STRUCT_R(Vector< S32 >); 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(ColorI); DECLARE_STRUCT_R(LinearColorF); diff --git a/Engine/source/console/engineTypes.h b/Engine/source/console/engineTypes.h index 51d2ef84d..fbce1afd6 100644 --- a/Engine/source/console/engineTypes.h +++ b/Engine/source/console/engineTypes.h @@ -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 ) \ - { #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 ) \ - { #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 ) \ diff --git a/Engine/source/core/util/tVector.h b/Engine/source/core/util/tVector.h index 0280db5f5..0700a5554 100644 --- a/Engine/source/core/util/tVector.h +++ b/Engine/source/core/util/tVector.h @@ -29,6 +29,8 @@ #include "platform/platform.h" #endif #include +#include "console/engineTypes.h" +#include "console/engineTypeInfo.h" //----------------------------------------------------------------------------- // Helper definitions for the vector class. @@ -63,6 +65,7 @@ extern bool VectorResize(U32 *aSize, U32 *aCount, void **arrayPtr, U32 newCount, template class Vector { + friend class VectorFieldEngineExport; protected: U32 mElementCount; ///< Number of elements currently in the Vector. U32 mArraySize; ///< Number of elements allocated for the Vector. @@ -188,6 +191,29 @@ class Vector /// @} }; +class VectorFieldEngineExport +{ +public: + template + static EngineFieldTable::Field getElementCountField() + { + typedef Vector ThisType; + return _FIELD(mElementCount, elementCount, 1, ""); + }; + template + static EngineFieldTable::Field getArraySizeField() + { + typedef Vector ThisType; + return _FIELD(mArraySize, arraySize, 1, ""); + }; + template + static EngineFieldTable::Field getArrayField() + { + typedef Vector ThisType; + return _FIELD(mArray, array, 1, ""); + }; +}; + template inline Vector::~Vector() { clear(); @@ -966,7 +992,7 @@ public: }; // Include vector specializations -#ifndef _VECTORSPEC_H_ +#ifndef _TVECTORSPEC_H_ #include "core/util/tVectorSpecializations.h" #endif diff --git a/Engine/source/core/util/uuid.cpp b/Engine/source/core/util/uuid.cpp index e8753de4e..6eb5c2fda 100644 --- a/Engine/source/core/util/uuid.cpp +++ b/Engine/source/core/util/uuid.cpp @@ -68,6 +68,7 @@ #include #include "core/util/md5.h" +#include "console/enginePrimitives.h" #if defined (TORQUE_OS_MAC) && defined(TORQUE_CPU_X64) 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 ] ); } } + +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, ""); +} + + + diff --git a/Engine/source/core/util/uuid.h b/Engine/source/core/util/uuid.h index e4ed4153a..e902c3002 100644 --- a/Engine/source/core/util/uuid.h +++ b/Engine/source/core/util/uuid.h @@ -26,6 +26,7 @@ #ifndef _PLATFORM_H_ #include "platform/platform.h" #endif +#include "console/engineTypeInfo.h" namespace Torque @@ -33,6 +34,7 @@ namespace Torque /// A universally unique identifier. class UUID { + friend class UUIDEngineExport; public: typedef void Parent; @@ -81,6 +83,17 @@ namespace Torque 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 diff --git a/Engine/source/math/mMatrix.cpp b/Engine/source/math/mMatrix.cpp index da1c137ca..33f0c821e 100644 --- a/Engine/source/math/mMatrix.cpp +++ b/Engine/source/math/mMatrix.cpp @@ -26,6 +26,8 @@ #include "math/mMatrix.h" #include "console/console.h" +#include "console/enginePrimitives.h" +#include "console/engineTypes.h" 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(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)]); -} \ No newline at end of file +} + +EngineFieldTable::Field MatrixFEngineExport::getMatrixField() +{ + typedef MatrixF ThisType; + return _FIELD_AS(F32, m, m, 16, ""); +} diff --git a/Engine/source/math/mMatrix.h b/Engine/source/math/mMatrix.h index 5c2f3e8ae..9591bc308 100644 --- a/Engine/source/math/mMatrix.h +++ b/Engine/source/math/mMatrix.h @@ -35,12 +35,18 @@ #include "math/mPoint4.h" #endif +#ifndef _ENGINETYPEINFO_H_ +#include "console/engineTypeInfo.h" +#endif + + /// 4x4 Matrix Class /// /// This runs at F32 precision. class MatrixF { + friend class MatrixFEngineExport; private: F32 m[16]; ///< Note: Torque uses row-major matrices @@ -224,6 +230,12 @@ public: const static MatrixF Identity; }; +class MatrixFEngineExport +{ +public: + static EngineFieldTable::Field getMatrixField(); +}; + //-------------------------------------- // Inline Functions diff --git a/Engine/source/math/mathTypes.cpp b/Engine/source/math/mathTypes.cpp index 89be98f18..9cdd1cb4e 100644 --- a/Engine/source/math/mathTypes.cpp +++ b/Engine/source/math/mathTypes.cpp @@ -88,30 +88,59 @@ END_IMPLEMENT_STRUCT; IMPLEMENT_STRUCT( RectI, 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; IMPLEMENT_STRUCT( RectF, 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; IMPLEMENT_STRUCT( MatrixF, MatrixF, MathTypes, "" ) + + MatrixFEngineExport::getMatrixField(), + END_IMPLEMENT_STRUCT; IMPLEMENT_STRUCT( AngAxisF, AngAxisF, MathTypes, "" ) + + FIELD( axis, axis, 1, "") + FIELD( angle, angle, 1, "") + END_IMPLEMENT_STRUCT; IMPLEMENT_STRUCT( TransformF, TransformF, MathTypes, "" ) + + FIELD(mPosition, position, 1, "") + FIELD(mOrientation, orientation, 1, "") + FIELD(mHasRotation, hasRotation, 1, "") + END_IMPLEMENT_STRUCT; IMPLEMENT_STRUCT( Box3F, Box3F, MathTypes, "" ) + + FIELD(minExtents, minExtents, 1, "Minimum extents of box") + FIELD(maxExtents, maxExtents, 1, "Maximum extents of box") + END_IMPLEMENT_STRUCT; IMPLEMENT_STRUCT( EaseF, EaseF, MathTypes, "" ) + + FIELD(mDir, dir, 1, "inout, in, out") + FIELD(mType, type, 1, "linear, etc...") + FIELD_AS(F32, mParam, type, 2, "optional params") + END_IMPLEMENT_STRUCT; IMPLEMENT_STRUCT(RotationF, RotationF, MathTypes, From 5a994bdddc94708524f25f488ebc732d386d00ee Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 12:41:27 +0200 Subject: [PATCH 04/36] Rename GuiSpeedometer::mColor to mNeedleColor to avoid clash with parent --- Engine/source/T3D/vehicles/guiSpeedometer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Engine/source/T3D/vehicles/guiSpeedometer.cpp b/Engine/source/T3D/vehicles/guiSpeedometer.cpp index 9d92bd5e2..b5be88cdd 100644 --- a/Engine/source/T3D/vehicles/guiSpeedometer.cpp +++ b/Engine/source/T3D/vehicles/guiSpeedometer.cpp @@ -41,7 +41,7 @@ class GuiSpeedometerHud : public GuiBitmapCtrl F32 mMaxAngle; ///< Max pos of needle F32 mMinAngle; ///< Min pos of needle Point2F mCenter; ///< Center of needle rotation - LinearColorF mColor; ///< Needle Color + LinearColorF mNeedleColor; ///< Needle Color F32 mNeedleLength; F32 mNeedleWidth; F32 mTailLength; @@ -103,7 +103,7 @@ GuiSpeedometerHud::GuiSpeedometerHud() mNeedleWidth = 3; mNeedleLength = 10; mTailLength = 5; - mColor.set(1,0,0,1); + mNeedleColor.set(1,0,0,1); } void GuiSpeedometerHud::initPersistFields() @@ -122,7 +122,7 @@ void GuiSpeedometerHud::initPersistFields() "Angle (in radians) of the needle when the Vehicle speed is >= maxSpeed. " "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" ); addField("center", TypePoint2F, Offset( mCenter, GuiSpeedometerHud ), @@ -210,7 +210,7 @@ void GuiSpeedometerHud::onRender(Point2I offset, const RectI &updateRect) GFX->setTexture(0, NULL); // 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); for(int k=0; k<5; k++){ rotMatrix.mulP(vertList[k]); From e1a6fa01ca9b4020aefe040df99395a463f90e91 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 12:47:31 +0200 Subject: [PATCH 05/36] PostEffect: Rename isEnabled field to enabled, to fix name clash --- Engine/source/postFx/postEffect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/postFx/postEffect.cpp b/Engine/source/postFx/postEffect.cpp index 68743b0f8..f93af4e5c 100644 --- a/Engine/source/postFx/postEffect.cpp +++ b/Engine/source/postFx/postEffect.cpp @@ -567,7 +567,7 @@ void PostEffect::initPersistFields() addField( "allowReflectPass", TypeBool, Offset( mAllowReflectPass, PostEffect ), "Is this effect processed during reflection render passes." ); - addProtectedField( "isEnabled", TypeBool, Offset( mEnabled, PostEffect), + addProtectedField( "enabled", TypeBool, Offset( mEnabled, PostEffect), &PostEffect::_setIsEnabled, &defaultProtectedGetFn, "Is the effect on." ); From a069496ad3948f663378705b3d137d1cdd6a290c Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 12:48:43 +0200 Subject: [PATCH 06/36] ModuleDefinition: Remove duplicate addProtectedField for ModuleId --- Engine/source/module/moduleDefinition.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Engine/source/module/moduleDefinition.cpp b/Engine/source/module/moduleDefinition.cpp index c8dae30d8..795186aef 100644 --- a/Engine/source/module/moduleDefinition.cpp +++ b/Engine/source/module/moduleDefinition.cpp @@ -82,8 +82,6 @@ void ModuleDefinition::initPersistFields() // Call parent. Parent::initPersistFields(); - addProtectedField("ModuleId", TypeString, Offset(mModuleId, ModuleDefinition), &defaultProtectedSetFn, &defaultProtectedGetFn, ""); - /// 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( "VersionId", TypeS32, Offset(mVersionId, ModuleDefinition), &setVersionId, &defaultProtectedGetFn, "The version Id. Breaking changes to a module should use a higher version Id." ); From 4eabbd5bb08bcdfb6034b628c2de8d01dc60a03b Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 12:50:41 +0200 Subject: [PATCH 07/36] GuiFilterCtrl: Rename identity function to resetFiltering to avoid clash The field "identity" previously clashed with the method "identity" --- Engine/source/gui/editor/guiFilterCtrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/gui/editor/guiFilterCtrl.cpp b/Engine/source/gui/editor/guiFilterCtrl.cpp index 03c0c8a9c..6abc3d53c 100644 --- a/Engine/source/gui/editor/guiFilterCtrl.cpp +++ b/Engine/source/gui/editor/guiFilterCtrl.cpp @@ -89,7 +89,7 @@ DefineEngineStringlyVariadicMethod( GuiFilterCtrl, setValue, void, 3, 20, "(f1, object->set(filter); } -DefineEngineMethod( GuiFilterCtrl, identity, void, (), , "Reset the filtering." +DefineEngineMethod( GuiFilterCtrl, resetFiltering, void, (), , "Reset the filtering." "@internal") { object->identity(); From 6a9c09f1454102ad90cfcd053092239a94d4576b Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 13:41:02 +0200 Subject: [PATCH 08/36] Update EngineAPI, use fixed_tuple as main underlying data structure This also fixes a few issues related to type conversions before data is sent to the engine function. Squash --- .../source/cinterface/c_consoleInterface.cpp | 14 ++- Engine/source/console/engineAPI.h | 114 +++++++++--------- Engine/source/console/engineFunctions.h | 22 ++-- 3 files changed, 79 insertions(+), 71 deletions(-) diff --git a/Engine/source/cinterface/c_consoleInterface.cpp b/Engine/source/cinterface/c_consoleInterface.cpp index 09b406da3..999956e18 100644 --- a/Engine/source/cinterface/c_consoleInterface.cpp +++ b/Engine/source/cinterface/c_consoleInterface.cpp @@ -26,6 +26,7 @@ namespace Con { + /* Consumer Callback is not defined as EngineType yet, until then we have to define these methods directly. DefineNewEngineFunction(AddConsumer, void, (ConsumerCallback cb), , "") { addConsumer(cb); @@ -35,6 +36,17 @@ namespace Con { removeConsumer(cb); } + */ + + TORQUE_API void fnAddConsumer(ConsumerCallback cb) + { + addConsumer(cb); + } + + TORQUE_API void fnRemoveConsumer(ConsumerCallback cb) + { + removeConsumer(cb); + } DefineNewEngineFunction(GetConsoleString, String, (String name),, "") { @@ -75,4 +87,4 @@ namespace Con { setBoolVariable(StringTable->insert(name), value); } -} \ No newline at end of file +} diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 38a3238a6..5e371106f 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -335,10 +335,9 @@ template struct _EngineTrampoline { template< typename R, typename ...ArgTs > struct _EngineTrampoline< R( ArgTs ... ) > { - typedef std::tuple Args; - std::tuple argT; - typedef fixed_tuple FixedArgs; - fixed_tuple fixedArgT; + template using AVT = typename EngineTypeTraits::ArgumentValueType; + typedef fixed_tuple ...> Args; + Args argT; }; template< typename T > @@ -356,21 +355,21 @@ struct _EngineFunctionTrampoline< R(ArgTs...) > : public _EngineFunctionTrampoli { private: using Super = _EngineFunctionTrampolineBase< R(ArgTs...) >; - using ArgsType = typename Super::Args; - using FixedArgsType = typename Super::FixedArgs; + using SelfType = _EngineFunctionTrampoline< R(ArgTs...) >; + using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args; template struct Seq {}; template struct Gens : Gens {}; template struct Gens<0, I...>{ typedef Seq type; }; - + + template + static typename fixed_tuple_element>::type getAndToType(const ArgsType& args) { + return typename EngineTypeTraits>::type>::ArgumentToValue(fixed_tuple_accessor::get(args)); + } + template static R dispatchHelper(typename Super::FunctionType fn, const ArgsType& args, Seq) { - return R( fn(std::get(args) ...) ); - } - - template - static R dispatchHelper(typename Super::FunctionType fn, const FixedArgsType& args, Seq) { - return R( fn(fixed_tuple_accessor::get(args) ...) ); + return R( fn(SelfType::template getAndToType(args) ...) ); } using SeqType = typename Gens::type; @@ -379,11 +378,6 @@ public: { return dispatchHelper(fn, args, SeqType()); } - - static R jmp(typename Super::FunctionType fn, const FixedArgsType& args ) - { - return dispatchHelper(fn, args, SeqType()); - } }; // Trampolines for engine methods @@ -400,21 +394,21 @@ struct _EngineMethodTrampoline< Frame, R(ArgTs ...) > : public _EngineMethodTram using FunctionType = R( typename Frame::ObjectType*, ArgTs ...); private: using Super = _EngineMethodTrampolineBase< R(ArgTs ...) >; - using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args; - using FixedArgsType = typename Super::FixedArgs; + using SelfType = _EngineMethodTrampoline< Frame, R(ArgTs ...) >; + using ArgsType = typename _EngineMethodTrampolineBase< R(ArgTs ...) >::Args; template struct Seq {}; template struct Gens : Gens {}; template struct Gens<0, I...>{ typedef Seq type; }; - - template - static R dispatchHelper(Frame f, const ArgsType& args, Seq) { - return R( f._exec(std::get(args) ...) ); + + template + static typename fixed_tuple_element>::type getAndToType(const ArgsType& args) { + return typename EngineTypeTraits>::type>::ArgumentToValue(fixed_tuple_accessor::get(args)); } - + template - static R dispatchHelper(Frame f, const FixedArgsType& args, Seq) { - return R( f._exec(fixed_tuple_accessor::get(args) ...) ); + static R dispatchHelper(Frame f, const ArgsType& args, Seq) { + return R(f._exec(SelfType::template getAndToType(args) ...)); } using SeqType = typename Gens::type; @@ -426,14 +420,6 @@ public: f.object = object; 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()); - } }; /// @} @@ -568,7 +554,7 @@ namespace engineAPI{ { return EngineUnmarshallData< IthArgType >()( argv[ startArgc + index ] ); } else { - return std::get(defaultArgs.mArgs); + return fixed_tuple_accessor::get(defaultArgs.mArgs); } } @@ -700,7 +686,7 @@ public: #define DefineEngineFunction( name, returnType, args, defaultArgs, usage ) \ static inline returnType _fn ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ - ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ + ( _EngineFunctionTrampoline< returnType args >::Args a ) \ { \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -754,7 +740,7 @@ public: #define _DefineMethodTrampoline( className, name, returnType, args ) \ 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 ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -837,7 +823,7 @@ public: #define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \ static inline returnType _fn ## className ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ - ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ + ( _EngineFunctionTrampoline< returnType args >::Args a ) \ { \ _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -872,25 +858,25 @@ public: ); \ 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); \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ - (S32 argc, const char** argv) \ + (Vector* vec) \ { \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \ - StringStackConsoleWrapper args(argc, argv); \ + StringStackConsoleWrapper args(vec->size(), vec->address()); \ return EngineTypeTraits< returnType >::ReturnValue( \ _fn ## name ## impl(NULL, args.count(), args) \ ); \ } \ - static _EngineFunctionDefaultArguments< void (S32 argc, const char** argv) > _fn ## name ## DefaultArgs; \ + static _EngineFunctionDefaultArguments< void (Vector* vec) > _fn ## name ## DefaultArgs; \ static EngineFunctionInfo _fn ## name ## FunctionInfo( \ #name, \ &_SCOPE<>()(), \ usage, \ - #returnType " " #name "(S32 argc, const char** argv)", \ + #returnType " " #name "(Vector args)", \ "fn" #name, \ - TYPE< returnType (S32 argc, const char** argv) >(), \ + TYPE< returnType (Vector* vec) >(), \ &_fn ## name ## DefaultArgs, \ ( void* ) &fn ## name, \ 0 \ @@ -899,34 +885,44 @@ public: returnType _fn ## name ## impl(SimObject *, S32 argc, ConsoleValueRef *argv) # 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 \ - (className* object, S32 argc, const char** argv) \ + (className* object, Vector* vec) \ { \ _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( \ - _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 EngineFunctionInfo _fn ## className ## _ ## name ## FunctionInfo( \ + static _EngineFunctionDefaultArguments< void (className* object, S32 argc, const char** argv) > \ + _fn ## className ## name ## DefaultArgs; \ + static EngineFunctionInfo _fn ## className ## name ## FunctionInfo( \ #name, \ - &_SCOPE<>()(), \ + &_SCOPE< className >()(), \ usage, \ - #returnType " " #name "(SimObject* object, S32 argc, const char** argv)", \ + "virtual " #returnType " " #name "(Vector args)", \ "fn" #className "_" #name, \ - TYPE< returnType (SimObject* object, S32 argc, const char** argv) >(), \ - &_fn ## className ## _ ## name ## DefaultArgs, \ + TYPE< _EngineMethodTrampoline< _ ## className ## name ## frame, returnType (Vector vec) >::FunctionType >(), \ + &_fn ## className ## name ## DefaultArgs, \ ( void* ) &fn ## className ## _ ## name, \ 0 \ ); \ returnType cm_##className##_##name##_caster(SimObject* object, S32 argc, ConsoleValueRef* argv) { \ AssertFatal( dynamic_cast( object ), "Object passed to " #name " is not a " #className "!" ); \ - conmethod_return_##returnType ) _fn ## className ## _ ## name ## impl(static_cast(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); \ - static inline returnType _fn ## className ## _ ## name ## impl(className *object, S32 argc, ConsoleValueRef *argv) + inline returnType _ ## className ## name ## frame::_exec(S32 argc, ConsoleValueRef *argv) const @@ -937,7 +933,7 @@ public: #define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage ) \ static inline returnType _fn ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ - ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ + ( _EngineFunctionTrampoline< returnType args >::Args a ) \ { \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -984,7 +980,7 @@ public: #define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \ static inline returnType _fn ## className ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ - ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ + ( _EngineFunctionTrampoline< returnType args >::Args a ) \ { \ _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ diff --git a/Engine/source/console/engineFunctions.h b/Engine/source/console/engineFunctions.h index 8f2d600fe..8c6127374 100644 --- a/Engine/source/console/engineFunctions.h +++ b/Engine/source/console/engineFunctions.h @@ -94,22 +94,21 @@ struct EngineFunctionDefaultArguments template< typename T > struct _EngineFunctionDefaultArguments {}; -template -struct _EngineFunctionDefaultArguments< void(ArgTs...) > : public EngineFunctionDefaultArguments +template +struct _EngineFunctionDefaultArguments< R(ArgTs...) > : public EngineFunctionDefaultArguments { template using DefVST = typename EngineTypeTraits::DefaultArgumentValueStoreType; - fixed_tuple ...> mFixedArgs; - std::tuple ...> mArgs; + using SelfType = _EngineFunctionDefaultArguments< R(ArgTs...) >; + fixed_tuple...> mArgs; + private: - using SelfType = _EngineFunctionDefaultArguments< void(ArgTs...) >; - template struct Seq {}; template struct Gens : Gens {}; template struct Gens<0, I...>{ typedef Seq type; }; template - static void copyHelper(std::tuple ...> &args, std::tuple ...> &defaultArgs, Seq) { + static void copyHelper(std::tuple ...> &args, std::tuple ...> &defaultArgs, Seq) { std::tie(std::get(args)...) = defaultArgs; } @@ -117,7 +116,7 @@ private: template struct DodgyVCHelper { - using type = typename std::enable_if::type; + using type = typename std::enable_if...>>::type; }; template using MaybeSelfEnabled = typename DodgyVCHelper::type; @@ -128,15 +127,16 @@ private: template static MaybeSelfEnabled tailInit(TailTs ...tail) { std::tuple...> argsT; std::tuple...> tailT = std::make_tuple(tail...); - SelfType::copyHelper(argsT, tailT, typename Gens::type()); + SelfType::template copyHelper(argsT, tailT, typename Gens::type()); return argsT; }; public: template _EngineFunctionDefaultArguments(TailTs ...tail) - : EngineFunctionDefaultArguments({sizeof...(TailTs)}), mArgs(SelfType::tailInit(tail...)) + : EngineFunctionDefaultArguments({sizeof...(TailTs)}) { - fixed_tuple_mutator...), void(DefVST...)>::copy(mArgs, mFixedArgs); + std::tuple...> tmpTup = SelfType::tailInit(tail...); + fixed_tuple_mutator...), void(DefVST...)>::copy(tmpTup, mArgs); } }; From 0b5fd8db6ecfc2dda84f1c427a241cabb14174fe Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 13:46:07 +0200 Subject: [PATCH 09/36] Engine API: Pass structs by reference --- Engine/source/console/engineTypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/console/engineTypes.h b/Engine/source/console/engineTypes.h index fbce1afd6..e6bb3a6ea 100644 --- a/Engine/source/console/engineTypes.h +++ b/Engine/source/console/engineTypes.h @@ -240,12 +240,12 @@ struct _EngineStructTypeTraits typedef void SuperType; // Structs get passed in as pointers and passed out as full copies. - typedef T ArgumentValueType; + typedef T* ArgumentValueType; typedef T ReturnValueType; typedef T DefaultArgumentValueStoreType; typedef ReturnValueType ReturnValue; - static ValueType ArgumentToValue( ArgumentValueType val ) { return val; } + static ValueType ArgumentToValue( ArgumentValueType val ) { return *val; } static const EngineTypeInfo* const TYPEINFO; }; From 68b688466528ba9d1234c9b10eca0c38d48d5c11 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 15:03:20 +0200 Subject: [PATCH 10/36] EngineAPI: Expose strings as UTF8 instead of UTF16 --- Engine/source/console/enginePrimitives.cpp | 1 + Engine/source/console/enginePrimitives.h | 27 ++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Engine/source/console/enginePrimitives.cpp b/Engine/source/console/enginePrimitives.cpp index b189e6156..99549e774 100644 --- a/Engine/source/console/enginePrimitives.cpp +++ b/Engine/source/console/enginePrimitives.cpp @@ -34,6 +34,7 @@ IMPLEMENT_PRIMITIVE( U32, uint,, "32bit unsigned integer." ); IMPLEMENT_PRIMITIVE( F32, float,, "32bit single-precision floating-point." ); IMPLEMENT_PRIMITIVE( F64, double,, "64bit double-precision floating-point." ); 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." ); // Define pointer types for vectors. diff --git a/Engine/source/console/enginePrimitives.h b/Engine/source/console/enginePrimitives.h index 59c36d253..d1f373e00 100644 --- a/Engine/source/console/enginePrimitives.h +++ b/Engine/source/console/enginePrimitives.h @@ -62,7 +62,7 @@ DECLARE_PRIMITIVE_R(const char**); //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 -// 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 // 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 @@ -71,21 +71,20 @@ _DECLARE_TYPE_R(String); template<> struct EngineTypeTraits< String > : public _EnginePrimitiveTypeTraits< String > { - typedef const UTF16* ArgumentValueType; - typedef const UTF16* ReturnValueType; + typedef const UTF8* ArgumentValueType; + typedef const UTF8* ReturnValueType; //FIXME: this needs to be sorted out; for now, we store default value literals in ASCII typedef const char* DefaultArgumentValueStoreType; - static const UTF16* ReturnValue( const String& str ) + static const UTF8* ReturnValue( const String& str ) { static String sTemp; sTemp = str; - return sTemp.utf16(); + return sTemp.utf8(); } }; - // 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 // back to String. @@ -93,12 +92,20 @@ template<> struct EngineTypeTraits< const UTF16* > : public EngineTypeTraits< St template<> inline const EngineTypeInfo* TYPE< const UTF16* >() { return TYPE< String >(); } inline const EngineTypeInfo* TYPE( const UTF16*& ) { return TYPE< String >(); } -//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 >(); } +_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_ From fe09d6e125b323bde58cd0018dfe0cab2cca46e7 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 15:04:21 +0200 Subject: [PATCH 11/36] ModuleSystem: Lookup CInterface methods when calling module create func --- Engine/source/console/simObject.cpp | 5 +++++ Engine/source/module/moduleManager.cpp | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index a4b938e2d..ea0da309c 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -42,6 +42,7 @@ #include "persistence/taml/tamlCustom.h" #include "sim/netObject.h" +#include "cinterface/cinterface.h" IMPLEMENT_CONOBJECT( SimObject ); @@ -831,6 +832,10 @@ bool SimObject::isMethod( const char* methodName ) if( !methodName || !methodName[0] ) return false; + if (CInterface::isMethod(this->getName(), methodName) || CInterface::isMethod(this->getClassName(), methodName)) { + return true; + } + StringTableEntry stname = StringTable->insert( methodName ); if( getNamespace() ) diff --git a/Engine/source/module/moduleManager.cpp b/Engine/source/module/moduleManager.cpp index b3ef89446..2e71e9e67 100644 --- a/Engine/source/module/moduleManager.cpp +++ b/Engine/source/module/moduleManager.cpp @@ -38,6 +38,8 @@ #include "console/consoleTypes.h" #endif +#include "cinterface/cinterface.h" + #ifndef _MODULE_DEFINITION_H #include "module/moduleDefinition.h" #endif @@ -837,16 +839,7 @@ bool ModuleManager::loadModuleExplicit( const char* pModuleId, const U32 version const bool scriptFileExecuted = dAtob( Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath() ) ); // Did we execute the script file? - 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 + if ( !scriptFileExecuted ) { // 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.", @@ -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. raiseModulePostLoadNotifications( pLoadReadyModuleDefinition ); } From e95a5bf139f25137b2a75de2488d72cfec67bdbe Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 15:04:38 +0200 Subject: [PATCH 12/36] Expose SimPersistID to EngineAPI --- Engine/source/console/simPersistID.cpp | 20 +++++++++++++++++ Engine/source/console/simPersistID.h | 31 ++++++++++++++++---------- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Engine/source/console/simPersistID.cpp b/Engine/source/console/simPersistID.cpp index c4f26e18e..92b183c9a 100644 --- a/Engine/source/console/simPersistID.cpp +++ b/Engine/source/console/simPersistID.cpp @@ -24,16 +24,26 @@ #include "console/simObject.h" #include "core/util/tDictionary.h" #include "core/util/safeDelete.h" +#include "engineAPI.h" //#define DEBUG_SPEW +IMPLEMENT_CLASS(SimPersistID, "") +END_IMPLEMENT_CLASS; SimPersistID::LookupTableType* SimPersistID::smLookupTable; //----------------------------------------------------------------------------- +SimPersistID::SimPersistID() +{ + mObject = NULL; + mUUID.generate(); + smLookupTable->insertUnique(mUUID, this); +} + SimPersistID::SimPersistID( SimObject* object ) : mObject( object ) { @@ -136,3 +146,13 @@ SimPersistID* SimPersistID::findOrCreate( const Torque::UUID& uuid ) return pid; } + +DefineNewEngineMethod(SimPersistID, getUUID, Torque::UUID, (), , "") +{ + return object->getUUID(); +} + +DefineNewEngineMethod(SimPersistID, getObject, SimObject*, (), , "") +{ + return object->getObject(); +} diff --git a/Engine/source/console/simPersistID.h b/Engine/source/console/simPersistID.h index 46b1a4559..1035f0768 100644 --- a/Engine/source/console/simPersistID.h +++ b/Engine/source/console/simPersistID.h @@ -30,6 +30,9 @@ #include "core/util/refBase.h" #endif +#ifndef _ENGINEOBJECT_H_ + #include "console/engineObject.h" +#endif /// @file /// Persistent IDs for SimObjects. @@ -40,12 +43,27 @@ template< typename, typename > class HashTable; /// A globally unique persistent ID for a SimObject. -class SimPersistID : public StrongRefBase +class SimPersistID : public EngineObject { public: + DECLARE_CLASS(SimPersistID, EngineObject); typedef void Parent; 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: @@ -60,17 +78,6 @@ class SimPersistID : public StrongRefBase /// Table of persistent object IDs. 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. void resolve( SimObject* object ); From 03769bb79dd8f8df5ae9377e617042d6a5d0920b Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 17:49:41 +0200 Subject: [PATCH 13/36] Remove superfluous Get/SetField API methods --- Engine/source/cinterface/c_simobjectInterface.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Engine/source/cinterface/c_simobjectInterface.cpp b/Engine/source/cinterface/c_simobjectInterface.cpp index 4c018c0ab..1c687af28 100644 --- a/Engine/source/cinterface/c_simobjectInterface.cpp +++ b/Engine/source/cinterface/c_simobjectInterface.cpp @@ -28,16 +28,6 @@ DefineNewEngineMethod(SimObject, RegisterObject, bool, (),,"") 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),, "") { if (parent) @@ -66,4 +56,4 @@ DefineNewEngineMethod(SimObject, InspectPreApply, void, (), , "") DefineNewEngineMethod(SimObject, InspectPostApply, void, (), , "") { object->inspectPostApply(); -} \ No newline at end of file +} From b76a3fa50872aa6eb6cbba0838912f41755240f9 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 17:50:53 +0200 Subject: [PATCH 14/36] Correct name of EaseF param in struct EngineAPI export --- Engine/source/math/mathTypes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/math/mathTypes.cpp b/Engine/source/math/mathTypes.cpp index 9cdd1cb4e..ba8c49dca 100644 --- a/Engine/source/math/mathTypes.cpp +++ b/Engine/source/math/mathTypes.cpp @@ -139,7 +139,7 @@ IMPLEMENT_STRUCT( EaseF, FIELD(mDir, dir, 1, "inout, in, out") FIELD(mType, type, 1, "linear, etc...") - FIELD_AS(F32, mParam, type, 2, "optional params") + FIELD_AS(F32, mParam, param, 2, "optional params") END_IMPLEMENT_STRUCT; IMPLEMENT_STRUCT(RotationF, From 84960633b3102b87163df9614a8917c14a41d6d0 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 17:51:36 +0200 Subject: [PATCH 15/36] Fix typo in reverbModDepth field name --- Engine/source/sfx/sfxDescription.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/sfx/sfxDescription.cpp b/Engine/source/sfx/sfxDescription.cpp index 3b41b9b80..f07a8f7d6 100644 --- a/Engine/source/sfx/sfxDescription.cpp +++ b/Engine/source/sfx/sfxDescription.cpp @@ -425,8 +425,8 @@ void SFXDescription::initPersistFields() "Reverb echo depth."); addField("reverbModTime", TypeF32, Offset(mReverb.flModulationTime, SFXDescription), "Reverb Modulation time."); - addField("reverbModTime", TypeF32, Offset(mReverb.flModulationDepth, SFXDescription), - "Reverb Modulation time."); + addField("reverbModDepth", TypeF32, Offset(mReverb.flModulationDepth, SFXDescription), + "Reverb Modulation Depth."); addField("airAbsorbtionGainHF", TypeF32, Offset(mReverb.flAirAbsorptionGainHF, SFXDescription), "High Frequency air absorbtion"); addField("reverbHFRef", TypeF32, Offset(mReverb.flHFReference, SFXDescription), From c0eec93d556a2fa30bb34845b09d5a74bd3dfadc Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 17:52:02 +0200 Subject: [PATCH 16/36] Avoid nameclash in guiScriptNotifyControl fields --- Engine/source/gui/core/guiScriptNotifyControl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Engine/source/gui/core/guiScriptNotifyControl.cpp b/Engine/source/gui/core/guiScriptNotifyControl.cpp index 93ec5bb90..d756f562f 100644 --- a/Engine/source/gui/core/guiScriptNotifyControl.cpp +++ b/Engine/source/gui/core/guiScriptNotifyControl.cpp @@ -69,13 +69,13 @@ void GuiScriptNotifyCtrl::initPersistFields() { // Callbacks Group addGroup("Callbacks"); - addField("onChildAdded", TypeBool, Offset( mOnChildAdded, GuiScriptNotifyCtrl ), "Enables/disables onChildAdded callback" ); - addField("onChildRemoved", TypeBool, Offset( mOnChildRemoved, GuiScriptNotifyCtrl ), "Enables/disables onChildRemoved callback" ); - addField("onChildResized", TypeBool, Offset( mOnChildResized, GuiScriptNotifyCtrl ), "Enables/disables onChildResized callback" ); - addField("onParentResized", TypeBool, Offset( mOnParentResized, GuiScriptNotifyCtrl ), "Enables/disables onParentResized callback" ); - addField("onResize", TypeBool, Offset( mOnResize, GuiScriptNotifyCtrl ), "Enables/disables onResize callback" ); - addField("onLoseFirstResponder", TypeBool, Offset( mOnLoseFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onLoseFirstResponder callback" ); - addField("onGainFirstResponder", TypeBool, Offset( mOnGainFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onGainFirstResponder callback" ); + addField("notifyOnChildAdded", TypeBool, Offset( mOnChildAdded, GuiScriptNotifyCtrl ), "Enables/disables onChildAdded callback" ); + addField("notifyOnChildRemoved", TypeBool, Offset( mOnChildRemoved, GuiScriptNotifyCtrl ), "Enables/disables onChildRemoved callback" ); + addField("notifyOnChildResized", TypeBool, Offset( mOnChildResized, GuiScriptNotifyCtrl ), "Enables/disables onChildResized callback" ); + addField("notifyOnParentResized", TypeBool, Offset( mOnParentResized, GuiScriptNotifyCtrl ), "Enables/disables onParentResized callback" ); + addField("notifyOnResize", TypeBool, Offset( mOnResize, GuiScriptNotifyCtrl ), "Enables/disables onResize callback" ); + addField("notifyOnLoseFirstResponder", TypeBool, Offset( mOnLoseFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onLoseFirstResponder callback" ); + addField("notifyOnGainFirstResponder", TypeBool, Offset( mOnGainFirstResponder, GuiScriptNotifyCtrl ), "Enables/disables onGainFirstResponder callback" ); endGroup("Callbacks"); Parent::initPersistFields(); From 6dae9981b57dbbd81ad7f6d990596a6dba939f95 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 17:53:10 +0200 Subject: [PATCH 17/36] Remove double quotes inside string definition in UndoManagerpushCompound --- Engine/source/util/undo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/util/undo.cpp b/Engine/source/util/undo.cpp index ae6163774..3276e1875 100644 --- a/Engine/source/util/undo.cpp +++ b/Engine/source/util/undo.cpp @@ -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 ); From 8bede52d3b622c5fd3ecaaf57b099b92be1b04be Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 17:53:39 +0200 Subject: [PATCH 18/36] Comment out unused Call Ins for setting SFXSource transform --- Engine/source/sfx/sfxSource.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Engine/source/sfx/sfxSource.cpp b/Engine/source/sfx/sfxSource.cpp index 56c8b7d63..abc5b35e1 100644 --- a/Engine/source/sfx/sfxSource.cpp +++ b/Engine/source/sfx/sfxSource.cpp @@ -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 // 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 ),,, "Set the position of the source's 3D sound.\n\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 ); source->setTransform( mat ); } +*/ // Console interop version. From d567bc97355a9d547d5b223c82937ebee983352f Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sat, 3 Aug 2019 17:54:21 +0200 Subject: [PATCH 19/36] Improve Engine API export, robust Default Value logic and allow _ in arg --- Engine/source/console/engineFunctions.h | 33 ++++++---- Engine/source/console/engineXMLExport.cpp | 76 ++++++++++++++--------- Engine/source/console/fixedTuple.h | 20 +++++- 3 files changed, 86 insertions(+), 43 deletions(-) diff --git a/Engine/source/console/engineFunctions.h b/Engine/source/console/engineFunctions.h index 8c6127374..84bc298d4 100644 --- a/Engine/source/console/engineFunctions.h +++ b/Engine/source/console/engineFunctions.h @@ -67,18 +67,9 @@ struct EngineFunctionDefaultArguments /// @warn This is @b NOT the size of the memory block returned by getArgs() and also /// not the number of elements it contains. U32 mNumDefaultArgs; - - /// Return a pointer to the variable-sized array of default argument values. - /// - /// @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 ); - } + + U32* mOffsets; + U8* mFirst; }; @@ -130,13 +121,29 @@ private: SelfType::template copyHelper(argsT, tailT, typename Gens::type()); return argsT; }; + + template + typename std::enable_if::type initOffsetsHelper() + { } + + template + typename std::enable_if < I < sizeof...(ArgTs)>::type initOffsetsHelper() + { + mOffsets[I] = fixed_tuple_offset(mArgs); + initOffsetsHelper(); + } public: template _EngineFunctionDefaultArguments(TailTs ...tail) - : EngineFunctionDefaultArguments({sizeof...(TailTs)}) + : EngineFunctionDefaultArguments() { std::tuple...> tmpTup = SelfType::tailInit(tail...); fixed_tuple_mutator...), void(DefVST...)>::copy(tmpTup, mArgs); + + mNumDefaultArgs = sizeof...(TailTs); + mOffsets = new U32[sizeof...(ArgTs)]; + initOffsetsHelper(); + mFirst = (U8*)& mArgs; } }; diff --git a/Engine/source/console/engineXMLExport.cpp b/Engine/source/console/engineXMLExport.cpp index ae1b182bb..2da81ff50 100644 --- a/Engine/source/console/engineXMLExport.cpp +++ b/Engine/source/console/engineXMLExport.cpp @@ -58,9 +58,9 @@ static const char* getDocString(const EngineExport* exportInfo) } 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. const char* end = ptr + 1; - while (ptr > prototype && dIsalnum(*ptr)) + while (ptr > prototype && (dIsalnum(*ptr) || *ptr == '_')) ptr--; const char* start = ptr + 1; @@ -169,20 +169,19 @@ static Vector< String > parseFunctionArgumentNames(const EngineFunctionInfo* fun } //----------------------------------------------------------------------------- - -static String getDefaultArgumentValue(const EngineFunctionInfo* function, const EngineTypeInfo* type, U32 offset) +static String getValueForType(const EngineTypeInfo* type, void* addr) { String value; - const EngineFunctionDefaultArguments* defaultArgs = function->getDefaultArguments(); +#define ADDRESS_TO_TYPE(tp) *(const tp*)(addr); switch (type->getTypeKind()) { case EngineTypeKindPrimitive: { -#define PRIMTYPE( tp ) \ +#define PRIMTYPE( tp ) \ if( TYPE< tp >() == type ) \ { \ - tp val = getArgValue< tp >( defaultArgs, offset ); \ + tp val = ADDRESS_TO_TYPE(tp); \ value = String::ToString( val ); \ } @@ -195,9 +194,9 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const PRIMTYPE(F64); //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(defaultArgs->getArgs() + offset); + const UTF8* val = *((const UTF8**)(addr)); value = val; } @@ -207,7 +206,7 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const case EngineTypeKindEnum: { - S32 val = getArgValue< S32 >(defaultArgs, offset); + S32 val = ADDRESS_TO_TYPE(S32); AssertFatal(type->getEnumTable(), "engineXMLExport - Enum type without table!"); const EngineEnumTable& table = *(type->getEnumTable()); @@ -225,7 +224,7 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const case EngineTypeKindBitfield: { - S32 val = getArgValue< S32 >(defaultArgs, offset); + S32 val = ADDRESS_TO_TYPE(S32); AssertFatal(type->getEnumTable(), "engineXMLExport - Bitfield type without table!"); const EngineEnumTable& table = *(type->getEnumTable()); @@ -247,7 +246,24 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const 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(); + AssertFatal((*fieldTable)[i].getNumElements() == 1, "engineXMLExport - numElements != 1 not supported currently."); + if (i == 0) { + value = getValueForType(fieldType, (void*)((size_t)addr + fieldOffset)); + } + else { + value += " " + getValueForType(fieldType, (void*)((size_t)addr + fieldOffset)); + } + } + break; } @@ -257,7 +273,7 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const // For these two kinds, we support "null" as the only valid // default value. - const void* ptr = getArgValue< const void* >(defaultArgs, offset); + const void* ptr = ADDRESS_TO_TYPE(void*); if (!ptr) value = "null"; break; @@ -267,11 +283,20 @@ static String getDefaultArgumentValue(const EngineFunctionInfo* function, const break; } +#undef ADDRESS_TO_TYPE 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) { if (isExportFiltered(function)) @@ -295,9 +320,6 @@ static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* x Vector< String > argumentNames = parseFunctionArgumentNames(function); const U32 numArgumentNames = argumentNames.size(); - // Accumulated offset in function argument frame vector. - U32 argFrameOffset = 0; - for (U32 i = 0; i < numArguments; ++i) { xml->pushNewElement("EngineFunctionArgument"); @@ -313,21 +335,17 @@ static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* x if (i >= firstDefaultArg) { - String defaultValue = getDefaultArgumentValue(function, type, argFrameOffset); + String defaultValue = getDefaultArgumentValue(function, type, i); 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(); - - 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(); @@ -579,4 +597,4 @@ DefineEngineFunction(exportEngineAPIToXML, SimXMLDocument*, (), , exportScope(EngineExportScope::getGlobalScope(), xml, true); return xml; -} \ No newline at end of file +} diff --git a/Engine/source/console/fixedTuple.h b/Engine/source/console/fixedTuple.h index 871cd7011..60b43be1f 100644 --- a/Engine/source/console/fixedTuple.h +++ b/Engine/source/console/fixedTuple.h @@ -22,6 +22,9 @@ #ifndef _FIXEDTUPLE_H_ #define _FIXEDTUPLE_H_ + +#include "engineTypes.h" + /// @name Fixed-layout tuple definition /// These structs and templates serve as a way to pass arguments from external /// applications and into the T3D console system. @@ -113,6 +116,21 @@ struct fixed_tuple_accessor<0> } }; +#pragma warning( push ) +#pragma warning( disable : 4267 ) +template +static U32 fixed_tuple_offset(fixed_tuple& t) +{ + return (U32)((size_t)& fixed_tuple_accessor::get(t)) - ((size_t)& t); +} + +template +static U32 fixed_tuple_offset(const fixed_tuple& t) +{ + return (U32)((size_t)& fixed_tuple_accessor::get(t)) - ((size_t)& t); +} +#pragma warning(pop) + template< typename T1, typename T2 > struct fixed_tuple_mutator {}; @@ -150,4 +168,4 @@ struct fixed_tuple_mutator /// @} -#endif // !_FIXEDTUPLE_H_ \ No newline at end of file +#endif // !_FIXEDTUPLE_H_ From c9609fbdbf094ee3800f7e117b1371eeed3cfc67 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Sun, 4 Aug 2019 11:20:01 +0200 Subject: [PATCH 20/36] CInterface integration in CodeInterpreter null ptr fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mNSEntry can be null if there is no TorqueScript defintion, but there could still be a result from an externally defined source. ยด Furthermore fixes an issue where StringStackConsoleWrapper would die before the value was read. --- Engine/source/console/codeInterpreter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Engine/source/console/codeInterpreter.cpp b/Engine/source/console/codeInterpreter.cpp index 8099ac575..434d8d2c8 100644 --- a/Engine/source/console/codeInterpreter.cpp +++ b/Engine/source/console/codeInterpreter.cpp @@ -2181,14 +2181,15 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip) // ConsoleFunctionType is for any function defined by script. // Any 'callback' type is an engine function that is exposed to script. - if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType - || cFunctionRes) + if (cFunctionRes || mNSEntry->mType == Namespace::Entry::ConsoleFunctionType) { + ConsoleValue retVal; ConsoleValueRef ret; if (cFunctionRes) { - StringStackConsoleWrapper retVal(1, &cRetRes); - ret = retVal.argv[0]; + retVal.init(); + ret.value = &retVal; + retVal.setStackStringValue(cRetRes); } else if (mNSEntry->mFunctionOffset) { From bcb75e21ac33a79b27659861978cdd7cc7acd7b9 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 7 Oct 2019 10:23:34 +0200 Subject: [PATCH 21/36] Remove typename from ArgumentToValue specifier --- Engine/source/console/engineAPI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 5e371106f..8b745ea0e 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -364,7 +364,7 @@ private: template static typename fixed_tuple_element>::type getAndToType(const ArgsType& args) { - return typename EngineTypeTraits>::type>::ArgumentToValue(fixed_tuple_accessor::get(args)); + return EngineTypeTraits>::type>::ArgumentToValue(fixed_tuple_accessor::get(args)); } template From 42ca15530135d5b12bb037f503b149d3726e166a Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 7 Oct 2019 10:35:22 +0200 Subject: [PATCH 22/36] Fix non-mvc compilation in EngineDefaultArguments --- Engine/source/console/engineFunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/console/engineFunctions.h b/Engine/source/console/engineFunctions.h index 84bc298d4..947e37654 100644 --- a/Engine/source/console/engineFunctions.h +++ b/Engine/source/console/engineFunctions.h @@ -112,7 +112,7 @@ private: template using MaybeSelfEnabled = typename DodgyVCHelper::type; #else - template using MaybeSelfEnabled = typename std::enable_if::type; + template using MaybeSelfEnabled = typename std::enable_if...>>::type; #endif template static MaybeSelfEnabled tailInit(TailTs ...tail) { From e69c4f0f6a4a5f5157e5bfe939ea8a69b1a04787 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 7 Oct 2019 10:44:54 +0200 Subject: [PATCH 23/36] Remove typename from ArgumentToValue specifier in MethodTrampoline --- Engine/source/console/engineAPI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 8b745ea0e..aa8762f4b 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -403,7 +403,7 @@ private: template static typename fixed_tuple_element>::type getAndToType(const ArgsType& args) { - return typename EngineTypeTraits>::type>::ArgumentToValue(fixed_tuple_accessor::get(args)); + return EngineTypeTraits>::type>::ArgumentToValue(fixed_tuple_accessor::get(args)); } template From 90d460d9a4156153212fa9ccacb1ee1b144f1bd7 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 9 Oct 2019 00:24:22 +0200 Subject: [PATCH 24/36] Remove object and function namespace from argument list --- Engine/source/console/codeInterpreter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/console/codeInterpreter.cpp b/Engine/source/console/codeInterpreter.cpp index 434d8d2c8..614eb8fec 100644 --- a/Engine/source/console/codeInterpreter.cpp +++ b/Engine/source/console/codeInterpreter.cpp @@ -2082,7 +2082,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip) mNSEntry = Namespace::global()->lookup(fnName); 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) { @@ -2115,7 +2115,7 @@ OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip) mNSEntry = NULL; 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 { From 47411e2d3aff8d510904675e705db19defd4902d Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 15 Oct 2019 22:33:51 +0200 Subject: [PATCH 25/36] Properly mark Parent class of DebugDrawer for Console hierarchy --- Engine/source/gfx/sim/debugDraw.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Engine/source/gfx/sim/debugDraw.h b/Engine/source/gfx/sim/debugDraw.h index e40889dc0..d3c75cf69 100644 --- a/Engine/source/gfx/sim/debugDraw.h +++ b/Engine/source/gfx/sim/debugDraw.h @@ -93,6 +93,7 @@ class GFont; /// class DebugDrawer : public SimObject { + typedef SimObject Parent; public: DECLARE_CONOBJECT(DebugDrawer); @@ -162,8 +163,6 @@ public: /// @} private: - typedef SimObject Parent; - static DebugDrawer* sgDebugDrawer; struct DebugPrim From a7f3724dd14d9e51f08c239ed179d02479813c94 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 4 Oct 2020 02:28:15 +0200 Subject: [PATCH 26/36] Handle MatrixF default values --- Engine/source/console/engineXMLExport.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Engine/source/console/engineXMLExport.cpp b/Engine/source/console/engineXMLExport.cpp index 2da81ff50..8e6b0b1d2 100644 --- a/Engine/source/console/engineXMLExport.cpp +++ b/Engine/source/console/engineXMLExport.cpp @@ -255,12 +255,16 @@ static String getValueForType(const EngineTypeInfo* type, void* addr) { const EngineTypeInfo* fieldType = (*fieldTable)[i].getType(); U32 fieldOffset = (*fieldTable)[i].getOffset(); - AssertFatal((*fieldTable)[i].getNumElements() == 1, "engineXMLExport - numElements != 1 not supported currently."); - if (i == 0) { - value = getValueForType(fieldType, (void*)((size_t)addr + fieldOffset)); - } - else { - value += " " + getValueForType(fieldType, (void*)((size_t)addr + fieldOffset)); + 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()))); + } } } @@ -572,6 +576,7 @@ static void exportScope(const EngineExportScope* scope, SimXMLDocument* xml, boo break; default: + AssertFatal(true, "Unknown EngineExportKind: " + exportInfo->getExportKind()); break; } } From f4c8e2683e3a418ee5a466adc3c61cf72b71c06d Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 4 Oct 2020 03:00:26 +0200 Subject: [PATCH 27/36] Improve type detection of EngineAPI types --- Engine/source/console/engineXMLExport.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Engine/source/console/engineXMLExport.cpp b/Engine/source/console/engineXMLExport.cpp index 8e6b0b1d2..9d1d71532 100644 --- a/Engine/source/console/engineXMLExport.cpp +++ b/Engine/source/console/engineXMLExport.cpp @@ -514,7 +514,12 @@ static void exportType(const EngineTypeInfo* type, SimXMLDocument* xml) ConsoleBaseType *cbt = ConsoleBaseType::getType(property.getType()); 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 { From 158bf5528c9b59f6601292e965d47e321b50be3c Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 4 Oct 2020 03:18:54 +0200 Subject: [PATCH 28/36] Remove name-clashes in AFX code-base --- Engine/source/afx/afxEffectGroup.cpp | 4 ++-- Engine/source/afx/afxEffectron.cpp | 4 ++-- Engine/source/afx/afxMagicSpell.cpp | 10 +++++----- Engine/source/afx/afxSelectron.cpp | 2 +- Engine/source/afx/ce/afxPhraseEffect.cpp | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Engine/source/afx/afxEffectGroup.cpp b/Engine/source/afx/afxEffectGroup.cpp index 71c6a89b6..e7677d4a7 100644 --- a/Engine/source/afx/afxEffectGroup.cpp +++ b/Engine/source/afx/afxEffectGroup.cpp @@ -253,13 +253,13 @@ DefineEngineMethod(afxEffectGroupData, reset, void, (),, 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" "@ingroup AFX") { if (!effect) { - Con::errorf("afxEffectGroupData::addEffect() -- missing afxEffectWrapperData."); + Con::errorf("afxEffectGroupData::pushEffect() -- missing afxEffectWrapperData."); return; } diff --git a/Engine/source/afx/afxEffectron.cpp b/Engine/source/afx/afxEffectron.cpp index cf60ede4b..1c68256c1 100644 --- a/Engine/source/afx/afxEffectron.cpp +++ b/Engine/source/afx/afxEffectron.cpp @@ -216,13 +216,13 @@ DefineEngineMethod(afxEffectronData, reset, void, (),, 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" "@ingroup AFX") { if (!effect) { - Con::errorf("afxEffectronData::addEffect() -- missing afxEffectWrapperData."); + Con::errorf("afxEffectronData::pushEffect() -- missing afxEffectWrapperData."); return; } diff --git a/Engine/source/afx/afxMagicSpell.cpp b/Engine/source/afx/afxMagicSpell.cpp index e169d70d7..b45d7c131 100644 --- a/Engine/source/afx/afxMagicSpell.cpp +++ b/Engine/source/afx/afxMagicSpell.cpp @@ -460,7 +460,7 @@ DefineEngineMethod(afxMagicSpellData, reset, void, (),, 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" "@ingroup AFX") { @@ -475,7 +475,7 @@ DefineEngineMethod(afxMagicSpellData, addCastingEffect, void, (afxEffectBaseData 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" "@ingroup AFX") @@ -491,7 +491,7 @@ DefineEngineMethod(afxMagicSpellData, addLaunchEffect, void, (afxEffectBaseData* 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" "@ingroup AFX") @@ -507,7 +507,7 @@ DefineEngineMethod(afxMagicSpellData, addDeliveryEffect, void, (afxEffectBaseDat 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" "@ingroup AFX") @@ -523,7 +523,7 @@ DefineEngineMethod(afxMagicSpellData, addImpactEffect, void, (afxEffectBaseData* 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" "@ingroup AFX") diff --git a/Engine/source/afx/afxSelectron.cpp b/Engine/source/afx/afxSelectron.cpp index 67cd32849..033940dc3 100644 --- a/Engine/source/afx/afxSelectron.cpp +++ b/Engine/source/afx/afxSelectron.cpp @@ -35,7 +35,7 @@ //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// // afxSelectronData::ewValidator // -// When an effect is added using "addEffect", this validator intercepts the value +// When an effect is added using "pushEffect", this validator intercepts the value // and adds it to the dynamic effects list. // void afxSelectronData::ewValidator::validateType(SimObject* object, void* typePtr) diff --git a/Engine/source/afx/ce/afxPhraseEffect.cpp b/Engine/source/afx/ce/afxPhraseEffect.cpp index b574afbed..eff1315ec 100644 --- a/Engine/source/afx/ce/afxPhraseEffect.cpp +++ b/Engine/source/afx/ce/afxPhraseEffect.cpp @@ -297,12 +297,12 @@ void afxPhraseEffectData::gather_cons_defs(Vector& 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" ) { if (!effectData) { - Con::errorf("afxPhraseEffectData::addEffect() -- failed to resolve effect datablock."); + Con::errorf("afxPhraseEffectData::pushEffect() -- failed to resolve effect datablock."); return; } From 97edf1ae34c83ba2895c17f5323807469f682722 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 4 Oct 2020 13:18:31 +0200 Subject: [PATCH 29/36] Remove duplicate definition of glowMul --- Engine/source/materials/materialDefinition.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index 43adb4260..9aafd40b8 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -306,8 +306,6 @@ void Material::initPersistFields() addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES, "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, "Enables rendering as glowing."); From 55f459cf2d51a97aa80393edf811085144a5277c Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 18 Oct 2020 02:23:37 +0200 Subject: [PATCH 30/36] Add missing call to CInterface::IsMethod --- Engine/source/console/consoleFunctions.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index e54b4c5ae..2b04236b1 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -30,6 +30,7 @@ #include "console/consoleFunctions.h" #endif +#include "cinterface/cinterface.h" #include "core/strings/findMatch.h" #include "core/strings/stringUnit.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" "@ingroup Scripting\n") { + if (CInterface::isMethod(nameSpace, method)) { + return true; + } + Namespace* ns = Namespace::find( StringTable->insert( nameSpace ) ); Namespace::Entry* nse = ns->lookup( StringTable->insert( method ) ); if( !nse ) From 763c2054510fc5db5020c7f82bf41a1d53c4c259 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 18 Oct 2020 02:25:44 +0200 Subject: [PATCH 31/36] Add type of Children in SimGroup and GuiControl --- Engine/source/console/simSet.cpp | 2 +- Engine/source/console/simSet.h | 1 + Engine/source/gui/core/guiControl.cpp | 2 +- Engine/source/gui/core/guiControl.h | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Engine/source/console/simSet.cpp b/Engine/source/console/simSet.cpp index 67d22b5fd..06024c2c6 100644 --- a/Engine/source/console/simSet.cpp +++ b/Engine/source/console/simSet.cpp @@ -37,7 +37,7 @@ #include "math/mMathFn.h" -IMPLEMENT_CONOBJECT( SimSet ); +IMPLEMENT_CONOBJECT_CHILDREN( SimSet ); IMPLEMENT_CONOBJECT( SimGroup ); ConsoleDocClass( SimSet, diff --git a/Engine/source/console/simSet.h b/Engine/source/console/simSet.h index 441180d18..01f636662 100644 --- a/Engine/source/console/simSet.h +++ b/Engine/source/console/simSet.h @@ -95,6 +95,7 @@ class SimSet : public SimObject, public TamlChildren public: typedef SimObject Parent; + typedef SimObject Children; enum SetModification { diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index e47404799..7e0f27791 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -44,7 +44,7 @@ //#define DEBUG_SPEW -IMPLEMENT_CONOBJECT( GuiControl ); +IMPLEMENT_CONOBJECT_CHILDREN( GuiControl ); ConsoleDocClass( GuiControl, "@brief Base class for all Gui control objects.\n\n" diff --git a/Engine/source/gui/core/guiControl.h b/Engine/source/gui/core/guiControl.h index eae37a8df..997213f75 100644 --- a/Engine/source/gui/core/guiControl.h +++ b/Engine/source/gui/core/guiControl.h @@ -107,6 +107,7 @@ class GuiControl : public SimGroup public: typedef SimGroup Parent; + typedef GuiControl Children; friend class GuiWindowCtrl; // mCollapseGroupVec friend class GuiCanvas; From 9c4191702cc00788e6897435e09fd714e7c54331 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 18 Oct 2020 02:27:01 +0200 Subject: [PATCH 32/36] Properly specify type of console types with a different native type --- Engine/source/console/dynamicTypes.h | 20 ++++++++++++++++++++ Engine/source/math/mathTypes.cpp | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Engine/source/console/dynamicTypes.h b/Engine/source/console/dynamicTypes.h index e06f3e6b3..476d029f9 100644 --- a/Engine/source/console/dynamicTypes.h +++ b/Engine/source/console/dynamicTypes.h @@ -284,6 +284,26 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); } }; \ 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(var); delete nativeVar; } \ + virtual StringTableEntry getTypePrefix( void ) const { return StringTable->insert( typePrefix ); } \ + }; \ + ConsoleType ## type gConsoleType ## type ## Instance; + #define ImplementConsoleTypeCasters( type, nativeType ) \ 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; } \ diff --git a/Engine/source/math/mathTypes.cpp b/Engine/source/math/mathTypes.cpp index ba8c49dca..14c7335e8 100644 --- a/Engine/source/math/mathTypes.cpp +++ b/Engine/source/math/mathTypes.cpp @@ -376,7 +376,7 @@ ConsoleSetType( TypeMatrixF ) //----------------------------------------------------------------------------- // TypeMatrixPosition //----------------------------------------------------------------------------- -ConsoleType(MatrixPosition, TypeMatrixPosition, MatrixF, "") +ConsoleMappedType(MatrixPosition, TypeMatrixPosition, Point3F, MatrixF, "") ConsoleGetType( TypeMatrixPosition ) { @@ -411,7 +411,7 @@ ConsoleSetType( TypeMatrixPosition ) //----------------------------------------------------------------------------- // TypeMatrixRotation //----------------------------------------------------------------------------- -ConsoleType(MatrixRotation, TypeMatrixRotation, MatrixF, "") +ConsoleMappedType(MatrixRotation, TypeMatrixRotation, AngAxisF, MatrixF, "") ConsoleGetType( TypeMatrixRotation ) { From 6ee6d7c717ef0303f871f76f3d25432739c9727a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 10 Nov 2020 03:07:40 -0600 Subject: [PATCH 33/36] Field PostEffect::isEnabled -> enabled followup --- Templates/BaseGame/game/core/gui/scripts/canvas.cs | 2 +- .../BaseGame/game/core/lighting/scripts/basicLighting_Init.cs | 2 +- Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Templates/BaseGame/game/core/gui/scripts/canvas.cs b/Templates/BaseGame/game/core/gui/scripts/canvas.cs index 55fa1735a..fae68b602 100644 --- a/Templates/BaseGame/game/core/gui/scripts/canvas.cs +++ b/Templates/BaseGame/game/core/gui/scripts/canvas.cs @@ -133,7 +133,7 @@ function configureCanvas() // It's formatted as AATypexAALevel // So, FXAAx4 or MLAAx2 if ( isObject( FXAA_PostEffect ) ) - FXAA_PostEffect.isEnabled = ( %aa > 0 ) ? true : false; + FXAA_PostEffect.Enabled = ( %aa > 0 ) ? true : false; } function GuiCanvas::modeStrToPrefs(%this, %modeStr) diff --git a/Templates/BaseGame/game/core/lighting/scripts/basicLighting_Init.cs b/Templates/BaseGame/game/core/lighting/scripts/basicLighting_Init.cs index 46dc45509..ef50d670e 100644 --- a/Templates/BaseGame/game/core/lighting/scripts/basicLighting_Init.cs +++ b/Templates/BaseGame/game/core/lighting/scripts/basicLighting_Init.cs @@ -64,7 +64,7 @@ singleton CustomMaterial( BL_ProjectedShadowMaterial ) function onActivateBasicLM() { // If HDR is enabled... enable the special format token. - if ( HDRPostFx.isEnabled ) + if ( HDRPostFx.Enabled ) AL_FormatToken.enable(); // Create render pass for projected shadow. diff --git a/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs b/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs index 61fcf93ff..f7f5dad59 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/postFxManager.cs @@ -122,7 +122,7 @@ function PostFXManager::savePresetHandler( %filename ) { %postEffect = PostFXManager.getKey(%i); - if(isObject(%postEffect) && %postEffect.isEnabled && %postEffect.isMethod("savePresetSettings")) + if(isObject(%postEffect) && %postEffect.Enabled && %postEffect.isMethod("savePresetSettings")) { %postEffect.savePresetSettings(); } From 48a38f61ef5c91b3a9f938e801ed1e302054670c Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 10 Nov 2020 10:37:44 -0600 Subject: [PATCH 34/36] Field PostEffect::isEnabled -> enabled followup GuiScriptNotifyCtrl::onXXX->notifyOnXXX followup --- .../tools/VerveEditor/GUI/VerveEditor.gui | 42 +++++++++---------- .../tools/guiEditor/scripts/guiEditor.ed.cs | 2 +- .../guiEditor/scripts/guiEditorCanvas.ed.cs | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui index a5259e821..091288fe0 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui +++ b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui @@ -59,13 +59,13 @@ childMargin = "0 0"; new GuiScriptNotifyCtrl(VerveEditorGroupNotify) { - onChildAdded = "0"; - onChildRemoved = "0"; - onChildResized = "0"; - onParentResized = "1"; - onResize = "1"; - onLoseFirstResponder = "0"; - onGainFirstResponder = "0"; + notifyOnChildAdded = "0"; + notifyOnChildRemoved = "0"; + notifyOnChildResized = "0"; + notifyOnParentResized = "1"; + notifyOnResize = "1"; + notifyOnLoseFirstResponder = "0"; + notifyOnGainFirstResponder = "0"; canSaveDynamicFields = "0"; class = "VerveEditorScrollNotifyV"; className = "VerveEditorScrollNotifyV"; @@ -155,13 +155,13 @@ childMargin = "0 0"; new GuiScriptNotifyCtrl(VerveEditorTrackNotify) { - onChildAdded = "0"; - onChildRemoved = "0"; - onChildResized = "0"; - onParentResized = "1"; - onResize = "1"; - onLoseFirstResponder = "0"; - onGainFirstResponder = "0"; + notifyOnChildAdded = "0"; + notifyOnChildRemoved = "0"; + notifyOnChildResized = "0"; + notifyOnParentResized = "1"; + notifyOnResize = "1"; + notifyOnLoseFirstResponder = "0"; + notifyOnGainFirstResponder = "0"; canSaveDynamicFields = "0"; class = "VerveEditorScrollNotify"; className = "VerveEditorScrollNotify"; @@ -406,13 +406,13 @@ childMargin = "0 0"; new GuiScriptNotifyCtrl(VerveEditorTimeNotify) { - onChildAdded = "0"; - onChildRemoved = "0"; - onChildResized = "0"; - onParentResized = "1"; - onResize = "1"; - onLoseFirstResponder = "0"; - onGainFirstResponder = "0"; + notifyOnChildAdded = "0"; + notifyOnChildRemoved = "0"; + notifyOnChildResized = "0"; + notifyOnParentResized = "1"; + notifyOnResize = "1"; + notifyOnLoseFirstResponder = "0"; + notifyOnGainFirstResponder = "0"; canSaveDynamicFields = "0"; class = "VerveEditorScrollNotifyH"; className = "VerveEditorScrollNotifyH"; diff --git a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditor.ed.cs b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditor.ed.cs index 2b9a5937b..71988bf9a 100644 --- a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditor.ed.cs +++ b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditor.ed.cs @@ -46,7 +46,7 @@ function GuiEdit( %val ) //Temp fix to disable MLAA when in GUI editor if( isObject(MLAAFx) && MLAAFx.isEnabled==true ) { - MLAAFx.isEnabled = false; + MLAAFx.Enabled = false; $MLAAFxGuiEditorTemp = true; } diff --git a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs index c19ffb316..450920e6f 100644 --- a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs +++ b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.cs @@ -544,7 +544,7 @@ function GuiEditCanvas::quit( %this ) //Temp fix to disable MLAA when in GUI editor if( isObject(MLAAFx) && $MLAAFxGuiEditorTemp==true ) { - MLAAFx.isEnabled = true; + MLAAFx.Enabled = true; $MLAAFxGuiEditorTemp = false; } } From 70358d0dbcd0ef1aa0ea8d8ac4dfc316becacb1f Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 11 Nov 2020 12:44:00 -0600 Subject: [PATCH 35/36] yet more `PostEffect::isEnabled -> enabled` that somehow slipped through the search filter --- .../scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs | 2 +- .../game/core/postFX/scripts/Caustics/CausticsPostFX.cs | 2 +- .../ChromaticAberration/ChromaticAberrationPostFX.cs | 2 +- .../core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs | 2 +- .../game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs | 2 +- .../BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs | 2 +- .../BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs | 2 +- .../BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs | 2 +- .../BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs | 2 +- .../BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs | 4 ++-- .../BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs | 4 ++-- .../postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs | 2 +- .../game/core/postFX/scripts/LightRays/lightRays.cs | 2 +- .../BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs | 2 +- .../scripts/ReflectionProbes/reflectionProbeArrayPostFX.cs | 2 +- .../game/core/postFX/scripts/Sharpen/SharpenPostFX.cs | 2 +- .../game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs | 2 +- .../postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs | 2 +- .../core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs | 6 +++--- .../game/core/postFX/scripts/Vignette/VignettePostFX.cs | 2 +- Templates/BaseGame/game/core/postFX/scripts/afxHighlight.cs | 2 +- .../BaseGame/game/core/rendering/scripts/renderManager.cs | 2 +- 22 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs index 3dc2d8d63..2d4141d6c 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/CameraMotionBlur/CameraMotionBlurPostFX.cs @@ -113,7 +113,7 @@ function CameraMotionBlurPostFX::savePresetSettings(%this) //Our actual postFX singleton PostEffect( CameraMotionBlurPostFX ) { - isEnabled = false; + enabled = false; renderTime = "PFXAfterDiffuse"; shader = CameraMotionBlurPostFX_Shader; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs index 4df9e37d2..cba25b0c1 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Caustics/CausticsPostFX.cs @@ -50,7 +50,7 @@ singleton ShaderData( PFX_CausticsShader ) singleton PostEffect( CausticsPFX ) { - isEnabled = false; + enabled = false; renderTime = "PFXAfterDiffuse"; renderBin = "ObjTranslucentBin"; //renderPriority = 0.1; diff --git a/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs index c55bd4d8e..a153788ff 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/ChromaticAberration/ChromaticAberrationPostFX.cs @@ -132,7 +132,7 @@ function ChromaticAberrationPostFX::savePresetSettings(%this) //Our actual postFX singleton PostEffect( ChromaticAberrationPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; // Resolve the HDR before we render any editor stuff diff --git a/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs index c55d39774..8072ffc4a 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.cs @@ -404,7 +404,7 @@ function DepthOfFieldPostFX::setLerpDist( %this, %d0, %d1, %d2 ) singleton PostEffect( DepthOfFieldPostFX ) { - isEnabled = false; + enabled = false; renderTime = "PFXAfterBin"; renderBin = "GlowBin"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs index 3decba411..658b7c67e 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/EdgeDetect/edgeAAPostFX.cs @@ -84,7 +84,7 @@ singleton PostEffect( EdgeDetectPostEffect ) texture[0] = "#deferred"; target = "#edge"; - isEnabled = true; + enabled = true; }; singleton PostEffect( EdgeAAPostEffect ) diff --git a/Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs index be27a075e..5f02af898 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/FXAA/FXAAPostFX.cs @@ -49,7 +49,7 @@ singleton ShaderData( FXAA_ShaderData ) singleton PostEffect( FXAAPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; renderTime = "PFXAfterDiffuse"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs index 8d26bb4fc..022f31bd8 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Flash/flashPostFX.cs @@ -37,7 +37,7 @@ singleton ShaderData( PFX_FlashShader ) singleton PostEffect( FlashFx ) { - isEnabled = false; + enabled = false; allowReflectPass = false; renderTime = "PFXAfterDiffuse"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs index cb0365622..3b4165f03 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Fog/fogPostFX.cs @@ -63,5 +63,5 @@ singleton PostEffect( fogPostFX ) renderPriority = 5; targetFormat = getBestHDRFormat(); - isEnabled = true; + enabled = true; }; \ No newline at end of file diff --git a/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs index 11fe55ed7..b240f0fc7 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Gamma/GammaPostFX.cs @@ -43,7 +43,7 @@ singleton GFXStateBlockData( GammaStateBlock : PFX_DefaultStateBlock ) singleton PostEffect( GammaPostFX ) { - isEnabled = true; + enabled = true; allowReflectPass = true; renderTime = "PFXBeforeBin"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs index 2e977a208..8f2c5a72d 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.cs @@ -77,7 +77,7 @@ singleton PostEffect( GlowPostFX ) target = "$outTex"; targetScale = "0.5 0.5"; - isEnabled = true; + enabled = true; // Blur vertically new PostEffect() @@ -146,7 +146,7 @@ singleton PostEffect( VolFogGlowPostFx ) texture[0] = "$backbuffer"; target = "$outTex"; targetScale = "0.5 0.5"; - isEnabled = false; + enabled = false; // Blur vertically new PostEffect() { diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs index db25b7c76..c990f54e2 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.cs @@ -412,7 +412,7 @@ function HDRPostFX::savePresetSettings(%this) singleton PostEffect( HDRPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; // Resolve the HDR before we render any editor stuff @@ -580,7 +580,7 @@ function LuminanceVisPostFX::setShaderConsts( %this ) singleton PostEffect( LuminanceVisPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; // Render before we do any editor rendering. diff --git a/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs index e3842b04a..0d0acd8d3 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/LUTColorGrading/LUTColorGradePostFX.cs @@ -120,7 +120,7 @@ function LUTColorGradePostFX::savePresetSettings(%this) //Our actual postFX singleton PostEffect( LUTColorGradePostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; // Resolve the HDR before we render any editor stuff diff --git a/Templates/BaseGame/game/core/postFX/scripts/LightRays/lightRays.cs b/Templates/BaseGame/game/core/postFX/scripts/LightRays/lightRays.cs index 30e235814..9d029b9b0 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/LightRays/lightRays.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/LightRays/lightRays.cs @@ -69,7 +69,7 @@ singleton GFXStateBlockData( LightRayStateBlock : PFX_DefaultStateBlock ) singleton PostEffect( LightRayPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; renderTime = "PFXBeforeBin"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs index 9e26954f3..32fb1bd3f 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/MLAA/MLAAPostFX.cs @@ -119,7 +119,7 @@ singleton ShaderData( MLAA_NeighborhoodBlendingShader ) singleton PostEffect( MLAAFx ) { - isEnabled = false; + enabled = false; allowReflectPass = false; renderTime = "PFXAfterDiffuse"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.cs index 5445f8a24..c5811c34b 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/ReflectionProbes/reflectionProbeArrayPostFX.cs @@ -7,7 +7,7 @@ singleton PostEffect( reflectionProbeArrayPostFX ) renderTime = "PFXAfterBin"; renderBin = "ProbeBin"; renderPriority = 9999; - isEnabled = true; + enabled = true; shader = PFX_ReflectionProbeArray; stateBlock = PFX_ReflectionProbeArrayStateBlock; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs index b8f72ea8f..3a1390950 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Sharpen/SharpenPostFX.cs @@ -121,7 +121,7 @@ function SharpenPostFX::savePresetSettings(%this) //Our actual postFX singleton PostEffect( SharpenPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; // Resolve the HDR before we render any editor stuff diff --git a/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs index d6a5064e4..2d30550a5 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.cs @@ -44,7 +44,7 @@ singleton ShaderData( PFX_TurbulenceShader ) singleton PostEffect( TurbulencePostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = true; renderTime = "PFXAfterDiffuse"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs index 03176b59f..fe2063ec4 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/UnderwaterFog/underWaterFogPostFX.cs @@ -70,7 +70,7 @@ singleton PostEffect( underWaterFogPostFX ) // Needs to happen after the FogPostFx renderPriority = 4; - isEnabled = true; + enabled = true; }; function underWaterFogPostFX::onEnabled( %this ) diff --git a/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs index e413537ff..0e423e953 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/VR/ovrBarrelDistortionPostFX.cs @@ -81,7 +81,7 @@ singleton GFXStateBlockData( OVRBarrelDistortionStateBlock : PFX_DefaultStateBlo //----------------------------------------------------------------------------- singleton BarrelDistortionPostEffect( OVRBarrelDistortionPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; renderTime = "PFXAfterDiffuse"; @@ -107,7 +107,7 @@ singleton BarrelDistortionPostEffect( OVRBarrelDistortionPostFX ) //----------------------------------------------------------------------------- singleton BarrelDistortionPostEffect( OVRBarrelDistortionChromaPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; renderTime = "PFXAfterDiffuse"; @@ -132,7 +132,7 @@ singleton BarrelDistortionPostEffect( OVRBarrelDistortionChromaPostFX ) //----------------------------------------------------------------------------- singleton PostEffect( OVRBarrelDistortionMonoPostFX ) { - isEnabled = false; + enabled = false; allowReflectPass = false; renderTime = "PFXAfterDiffuse"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs index 34699f918..014dc6524 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/Vignette/VignettePostFX.cs @@ -119,7 +119,7 @@ function VignettePostFX::savePresetSettings(%this) //Our actual postFX singleton PostEffect( VignettePostFX ) { - isEnabled = false; + enabled = false; renderTime = "PFXBeforeBin"; renderBin = "EditorBin"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/afxHighlight.cs b/Templates/BaseGame/game/core/postFX/scripts/afxHighlight.cs index 115decbbf..f81f3d855 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/afxHighlight.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/afxHighlight.cs @@ -36,7 +36,7 @@ singleton PostEffect( afxHighlightPostFX ) renderTime = "PFXAfterDiffuse"; renderBin = "HighlightBin"; renderPriority = 1; - isEnabled = true; + enabled = true; shader = PFX_afxHighlightShader; stateBlock = PFX_afxDefaultHighlightStateBlock; diff --git a/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs b/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs index 07b4f08a6..3f14a4569 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs +++ b/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs @@ -125,7 +125,7 @@ singleton PostEffect( AL_FormatCopy ) { // This PostEffect is used by 'AL_FormatToken' directly. It is never added to // the PostEffectManager. Do not call enable() on it. - isEnabled = false; + enabled = false; allowReflectPass = true; shader = PFX_PassthruShader; From 44dcdc751581764f21b80c7d3cb16069cc33374e Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sun, 15 Nov 2020 21:37:54 +0100 Subject: [PATCH 36/36] Revert wrong rename of addEffect in comment --- Engine/source/afx/afxSelectron.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/afx/afxSelectron.cpp b/Engine/source/afx/afxSelectron.cpp index 033940dc3..67cd32849 100644 --- a/Engine/source/afx/afxSelectron.cpp +++ b/Engine/source/afx/afxSelectron.cpp @@ -35,7 +35,7 @@ //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// // afxSelectronData::ewValidator // -// When an effect is added using "pushEffect", this validator intercepts the value +// When an effect is added using "addEffect", this validator intercepts the value // and adds it to the dynamic effects list. // void afxSelectronData::ewValidator::validateType(SimObject* object, void* typePtr)