Browse Source

New console type for Point3I

DavidWyand-GG 12 years ago
parent
commit
af7787b4bb
2 changed files with 36 additions and 0 deletions
  1. 33 0
      Engine/source/math/mathTypes.cpp
  2. 3 0
      Engine/source/math/mathTypes.h

+ 33 - 0
Engine/source/math/mathTypes.cpp

@@ -55,6 +55,15 @@ IMPLEMENT_STRUCT( Point2F,
       FIELD( x, x, 1, "X coordinate." )
       FIELD( y, y, 1, "Y coordinate." )
 
+END_IMPLEMENT_STRUCT;
+IMPLEMENT_STRUCT( Point3I,
+   Point3I, MathTypes,
+   "" )
+
+      FIELD( x, x, 1, "X coordinate." )
+      FIELD( y, y, 1, "Y coordinate." )
+      FIELD( z, z, 1, "Z coordinate." )
+
 END_IMPLEMENT_STRUCT;
 IMPLEMENT_STRUCT( Point3F,
    Point3F, MathTypes,
@@ -153,6 +162,30 @@ ConsoleSetType( TypePoint2F )
       Con::printf("Point2F must be set as { x, y } or \"x y\"");
 }
 
+//-----------------------------------------------------------------------------
+// TypePoint3I
+//-----------------------------------------------------------------------------
+ConsoleType( Point3I, TypePoint3I, Point3I )
+ImplementConsoleTypeCasters(TypePoint3I, Point3I)
+
+ConsoleGetType( TypePoint3I )
+{
+   Point3I *pt = (Point3I *) dptr;
+   char* returnBuffer = Con::getReturnBuffer(256);
+   dSprintf(returnBuffer, 256, "%d %d %d", pt->x, pt->y, pt->z);
+   return returnBuffer;
+}
+
+ConsoleSetType( TypePoint3I )
+{
+   if(argc == 1)
+      dSscanf(argv[0], "%d %d %d", &((Point3I *) dptr)->x, &((Point3I *) dptr)->y, &((Point3I *) dptr)->z);
+   else if(argc == 3)
+      *((Point3I *) dptr) = Point3I(dAtoi(argv[0]), dAtoi(argv[1]), dAtoi(argv[2]));
+   else
+      Con::printf("Point3I must be set as { x, y, z } or \"x y z\"");
+}
+
 //-----------------------------------------------------------------------------
 // TypePoint3F
 //-----------------------------------------------------------------------------

+ 3 - 0
Engine/source/math/mathTypes.h

@@ -33,6 +33,7 @@ void RegisterMathFunctions(void);
 
 class Point2I;
 class Point2F;
+class Point3I;
 class Point3F;
 class Point4F;
 class RectI;
@@ -49,6 +50,7 @@ DECLARE_SCOPE( MathTypes );
 
 DECLARE_STRUCT( Point2I );
 DECLARE_STRUCT( Point2F );
+DECLARE_STRUCT( Point3I );
 DECLARE_STRUCT( Point3F );
 DECLARE_STRUCT( Point4F );
 DECLARE_STRUCT( RectI );
@@ -63,6 +65,7 @@ DECLARE_STRUCT( EaseF );
 // Legacy console types.
 DefineConsoleType( TypePoint2I, Point2I )
 DefineConsoleType( TypePoint2F, Point2F )
+DefineConsoleType( TypePoint3I, Point3I )
 DefineConsoleType( TypePoint3F, Point3F )
 DefineConsoleType( TypePoint4F, Point4F )
 DefineConsoleType( TypeRectI, RectI )