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,