From af7787b4bb36c4d971296aae2ce8ca730e7932e2 Mon Sep 17 00:00:00 2001 From: DavidWyand-GG Date: Tue, 22 Jan 2013 17:37:57 -0500 Subject: [PATCH] New console type for Point3I --- Engine/source/math/mathTypes.cpp | 33 ++++++++++++++++++++++++++++++++ Engine/source/math/mathTypes.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/Engine/source/math/mathTypes.cpp b/Engine/source/math/mathTypes.cpp index d92f293e1..cbe123452 100644 --- a/Engine/source/math/mathTypes.cpp +++ b/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 //----------------------------------------------------------------------------- diff --git a/Engine/source/math/mathTypes.h b/Engine/source/math/mathTypes.h index c6ff83d7b..b17329cf8 100644 --- a/Engine/source/math/mathTypes.h +++ b/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 )