Ver Fonte

Declare all permutations of coordinate systems.

Nicholas Farshidmehr há 7 anos atrás
pai
commit
d58bca2e66

+ 7 - 2
Source/Urho3D/AngelScript/PhysicsAPI.cpp

@@ -394,12 +394,17 @@ void RegisterRaycastVehicleAPI(asIScriptEngine* engine)
     engine->RegisterObjectMethod("RaycastVehicle", "Vector3 GetContactNormal(int)", asMETHOD(RaycastVehicle, GetContactNormal), asCALL_THISCALL);
     engine->RegisterObjectMethod("RaycastVehicle", "void set_inAirRPM(float)", asMETHOD(RaycastVehicle, SetInAirRPM), asCALL_THISCALL);
     engine->RegisterObjectMethod("RaycastVehicle", "float get_inAirRPM()", asMETHOD(RaycastVehicle, GetInAirRPM), asCALL_THISCALL);
-    engine->RegisterObjectMethod("RaycastVehicle", "void set_coordinateSystem(const IntVector3&in = DEFAULT_COORDINATE_SYSTEM)", asMETHOD(RaycastVehicle, SetCoordinateSystem), asCALL_THISCALL);
+    engine->RegisterObjectMethod("RaycastVehicle", "void set_coordinateSystem(const IntVector3&in = RIGHT_UP_FORWARD)", asMETHOD(RaycastVehicle, SetCoordinateSystem), asCALL_THISCALL);
     engine->RegisterObjectMethod("RaycastVehicle", "IntVector3 get_coordinateSystem() const", asMETHOD(RaycastVehicle, GetCoordinateSystem), asCALL_THISCALL);
     engine->RegisterObjectMethod("RaycastVehicle", "int get_numWheels()", asMETHOD(RaycastVehicle, GetNumWheels), asCALL_THISCALL);
 
     engine->SetDefaultNamespace("RaycastVehicle");
-    engine->RegisterGlobalProperty("const IntVector3 DEFAULT_COORDINATE_SYSTEM", (void*)&RaycastVehicle::DEFAULT_COORDINATE_SYSTEM);
+    engine->RegisterGlobalProperty("const IntVector3 RIGHT_UP_FORWARD", (void*)&RaycastVehicle::RIGHT_UP_FORWARD);
+    engine->RegisterGlobalProperty("const IntVector3 RIGHT_FORWARD_UP", (void*)&RaycastVehicle::RIGHT_FORWARD_UP);
+    engine->RegisterGlobalProperty("const IntVector3 UP_FORWARD_RIGHT", (void*)&RaycastVehicle::UP_FORWARD_RIGHT);
+    engine->RegisterGlobalProperty("const IntVector3 UP_RIGHT_FORWARD", (void*)&RaycastVehicle::UP_RIGHT_FORWARD);
+    engine->RegisterGlobalProperty("const IntVector3 FORWARD_RIGHT_UP", (void*)&RaycastVehicle::FORWARD_RIGHT_UP);
+    engine->RegisterGlobalProperty("const IntVector3 FORWARD_UP_RIGHT", (void*)&RaycastVehicle::FORWARD_UP_RIGHT);
     engine->SetDefaultNamespace("");
 }
 

+ 7 - 2
Source/Urho3D/LuaScript/pkgs/Physics/RaycastVehicle.pkg

@@ -28,7 +28,7 @@ class RaycastVehicle : public LogicComponent
     void SetMaxSideSlipSpeed(float speed);
     void SetWheelSkidInfoCumulative(int wheel, float skid);
     void SetInAirRPM(float rpm);
-    void SetCoordinateSystem(const IntVector3& coordinateSystem = DEFAULT_COORDINATE_SYSTEM);
+    void SetCoordinateSystem(const IntVector3& coordinateSystem = RIGHT_UP_FORWARD);
     void Init();
 
     Vector3 GetWheelPosition(int wheel);
@@ -59,5 +59,10 @@ class RaycastVehicle : public LogicComponent
     float GetInAirRPM() const;
     IntVector3 GetCoordinateSystem() const;
 
-    static const IntVector3 DEFAULT_COORDINATE_SYSTEM;
+    static const IntVector3 RIGHT_UP_FORWARD;
+    static const IntVector3 RIGHT_FORWARD_UP;
+    static const IntVector3 UP_FORWARD_RIGHT;
+    static const IntVector3 UP_RIGHT_FORWARD;
+    static const IntVector3 FORWARD_RIGHT_UP;
+    static const IntVector3 FORWARD_UP_RIGHT;
 };

+ 8 - 3
Source/Urho3D/Physics/RaycastVehicle.cpp

@@ -34,7 +34,12 @@
 namespace Urho3D
 {
 
-const IntVector3 RaycastVehicle::DEFAULT_COORDINATE_SYSTEM(0, 1, 2);
+const IntVector3 RaycastVehicle::RIGHT_UP_FORWARD(0, 1, 2);
+const IntVector3 RaycastVehicle::RIGHT_FORWARD_UP(0, 2, 1);
+const IntVector3 RaycastVehicle::UP_FORWARD_RIGHT(1, 2, 0);
+const IntVector3 RaycastVehicle::UP_RIGHT_FORWARD(1, 0, 2);
+const IntVector3 RaycastVehicle::FORWARD_RIGHT_UP(2, 0, 1);
+const IntVector3 RaycastVehicle::FORWARD_UP_RIGHT(2, 1, 0);
 
 struct RaycastVehicleData
 {
@@ -137,7 +142,7 @@ RaycastVehicle::RaycastVehicle(Context* context) :
     // fixed update() for inputs and post update() to sync wheels for rendering
     SetUpdateEventMask(USE_FIXEDUPDATE | USE_FIXEDPOSTUPDATE | USE_POSTUPDATE);
     vehicleData_ = new RaycastVehicleData();
-    coordinateSystem_ = DEFAULT_COORDINATE_SYSTEM;
+    coordinateSystem_ = RIGHT_UP_FORWARD;
     wheelNodes_.Clear();
     activate_ = false;
     inAirRPM_ = 0.0f;
@@ -183,7 +188,7 @@ void RaycastVehicle::RegisterObject(Context* context)
         .SetMetadata(AttributeMetadata::P_VECTOR_STRUCT_ELEMENTS, wheelElementNames);
     URHO3D_ATTRIBUTE("Maximum side slip threshold", float, maxSideSlipSpeed_, 4.0f, AM_DEFAULT);
     URHO3D_ATTRIBUTE("RPM for wheel motors in air (0=calculate)", float, inAirRPM_, 0.0f, AM_DEFAULT);
-    URHO3D_ATTRIBUTE("Coordinate system", IntVector3, coordinateSystem_, DEFAULT_COORDINATE_SYSTEM, AM_DEFAULT);
+    URHO3D_ATTRIBUTE("Coordinate system", IntVector3, coordinateSystem_, RIGHT_UP_FORWARD, AM_DEFAULT);
 }
 
 void RaycastVehicle::OnSetEnabled()

+ 13 - 3
Source/Urho3D/Physics/RaycastVehicle.h

@@ -92,7 +92,7 @@ public:
     /// Set revolution per minute value for when wheel doesn't touch ground. If set to 0 (or not set), calculated from engine force (probably not what you want).
     void SetInAirRPM(float rpm);
     /// Set the coordinate system. The default is (0, 1, 2).
-    void SetCoordinateSystem(const IntVector3& coordinateSystem = DEFAULT_COORDINATE_SYSTEM);
+    void SetCoordinateSystem(const IntVector3& coordinateSystem = RIGHT_FORWARD_UP);
     /// Init the vehicle component after creation.
     void Init();
     /// Perform fixed step pre-update.
@@ -164,8 +164,18 @@ public:
     /// Set wheel data attribute during loading.
     void SetWheelDataAttr(const VariantVector& value);
 
-    /// The default coordinate system (0, 1, 2).
-    static const IntVector3 DEFAULT_COORDINATE_SYSTEM;
+    /// (0, 1, 2) coordinate system (default).
+    static const IntVector3 RIGHT_UP_FORWARD;
+    /// (0, 2, 1) coordinate system.
+    static const IntVector3 RIGHT_FORWARD_UP;
+    /// (1, 2, 0) coordinate system.
+    static const IntVector3 UP_FORWARD_RIGHT;
+    /// (1, 0, 2) coordinate system.
+    static const IntVector3 UP_RIGHT_FORWARD;
+    /// (2, 0, 1) coordinate system.
+    static const IntVector3 FORWARD_RIGHT_UP;
+    /// (2, 1, 0) coordinate system.
+    static const IntVector3 FORWARD_UP_RIGHT;
 
 private:
     /// If the RigidBody should be activated.