Browse Source

Option to disable the InternalEdgeUtility.
Mention indent spacing in coding conventions.

Lasse Öörni 12 years ago
parent
commit
1114a3fc28

+ 2 - 0
Docs/Reference.dox

@@ -1782,6 +1782,8 @@ byte[4]    Identifier "ASBC"
 
 - Indent style is Allman (BSD) -like, ie. brace on the next line from a control statement, indented on the same level. In switch-case statements the cases are on the same indent level as the switch statement.
 
+- Indents use 4 spaces instead of tabs.
+
 - Class and struct names are in camelcase beginning with an uppercase letter. They should be nouns. For example DebugRenderer, FreeTypeLibrary, Graphics.
 
 - Functions are likewise in upper-camelcase. For example CreateComponent, SetLinearRestThreshold.

+ 1 - 0
Docs/ScriptAPI.dox

@@ -5859,6 +5859,7 @@ Properties:<br>
 - int numIterations
 - int fps
 - bool interpolation
+- bool internalEdge
 - bool splitImpulse
 
 

+ 2 - 1
Engine/Physics/CollisionShape.h

@@ -30,9 +30,10 @@
 class btBvhTriangleMeshShape;
 class btCollisionShape;
 class btCompoundShape;
-class btTriangleInfoMap;
 class btTriangleMesh;
 
+struct btTriangleInfoMap;
+
 namespace Urho3D
 {
 

+ 9 - 0
Engine/Physics/PhysicsWorld.cpp

@@ -119,6 +119,7 @@ PhysicsWorld::PhysicsWorld(Context* context) :
     timeAcc_(0.0f),
     maxNetworkAngularVelocity_(DEFAULT_MAX_NETWORK_ANGULAR_VELOCITY),
     interpolation_(true),
+    internalEdge_(true),
     applyingTransforms_(false),
     debugRenderer_(0),
     debugMode_(btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawConstraints | btIDebugDraw::DBG_DrawConstraintLimits)
@@ -179,6 +180,7 @@ void PhysicsWorld::RegisterObject(Context* context)
     ACCESSOR_ATTRIBUTE(PhysicsWorld, VAR_INT, "Solver Iterations", GetNumIterations, SetNumIterations, int, 10, AM_DEFAULT);
     ATTRIBUTE(PhysicsWorld, VAR_FLOAT, "Net Max Angular Vel.", maxNetworkAngularVelocity_, DEFAULT_MAX_NETWORK_ANGULAR_VELOCITY, AM_DEFAULT);
     ATTRIBUTE(PhysicsWorld, VAR_BOOL, "Interpolation", interpolation_, true, AM_FILE);
+    ATTRIBUTE(PhysicsWorld, VAR_BOOL, "Internal Edge Utility", internalEdge_, true, AM_DEFAULT);
     ACCESSOR_ATTRIBUTE(PhysicsWorld, VAR_BOOL, "Split Impulse", GetSplitImpulse, SetSplitImpulse, bool, false, AM_DEFAULT);
 }
 
@@ -286,6 +288,13 @@ void PhysicsWorld::SetInterpolation(bool enable)
     interpolation_ = enable;
 }
 
+void PhysicsWorld::SetInternalEdge(bool enable)
+{
+    internalEdge_ = enable;
+    
+    MarkNetworkUpdate();
+}
+
 void PhysicsWorld::SetSplitImpulse(bool enable)
 {
     world_->getSolverInfo().m_splitImpulse = enable;

+ 6 - 0
Engine/Physics/PhysicsWorld.h

@@ -129,6 +129,8 @@ public:
     void SetNumIterations(int num);
     /// Set whether to interpolate between simulation steps.
     void SetInterpolation(bool enable);
+    /// Set whether to use Bullet's internal edge utility for trimesh collisions. Disabled by default.
+    void SetInternalEdge(bool enable);
     /// Set split impulse collision mode. This is more accurate, but slower. Disabled by default.
     void SetSplitImpulse(bool enable);
     /// Set maximum angular velocity for network replication.
@@ -152,6 +154,8 @@ public:
     int GetNumIterations() const;
     /// Return whether interpolation between simulation steps is enabled.
     bool GetInterpolation() const { return interpolation_; }
+    /// Return whether Bullet's internal edge utility for trimesh collisions is enabled.
+    bool GetInternalEdge() const { return internalEdge_; }
     /// Return whether split impulse collision mode is enabled.
     bool GetSplitImpulse() const;
     /// Return simulation steps per second.
@@ -239,6 +243,8 @@ private:
     float maxNetworkAngularVelocity_;
     /// Interpolation flag.
     bool interpolation_;
+    /// Use internal edge utility flag.
+    bool internalEdge_;
     /// Applying transforms flag.
     bool applyingTransforms_;
     /// Debug renderer.

+ 2 - 1
Engine/Physics/RigidBody.cpp

@@ -776,7 +776,8 @@ void RigidBody::UpdateMass()
         body_->setCollisionShape(useCompound ? shiftedCompoundShape_ : shiftedCompoundShape_->getChildShape(0));
         
         // If we have one shape and this is a triangle mesh, we use a custom material callback in order to adjust internal edges
-        if (!useCompound && body_->getCollisionShape()->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
+        if (!useCompound && body_->getCollisionShape()->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE &&
+            physicsWorld_->GetInternalEdge())
             body_->setCollisionFlags(body_->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
         else
             body_->setCollisionFlags(body_->getCollisionFlags() & ~btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);

+ 2 - 0
Engine/Script/PhysicsAPI.cpp

@@ -292,6 +292,8 @@ static void RegisterPhysicsWorld(asIScriptEngine* engine)
     engine->RegisterObjectMethod("PhysicsWorld", "int get_fps() const", asMETHOD(PhysicsWorld, GetFps), asCALL_THISCALL);
     engine->RegisterObjectMethod("PhysicsWorld", "void set_interpolation(bool)", asMETHOD(PhysicsWorld, SetInterpolation), asCALL_THISCALL);
     engine->RegisterObjectMethod("PhysicsWorld", "bool get_interpolation() const", asMETHOD(PhysicsWorld, GetInterpolation), asCALL_THISCALL);
+    engine->RegisterObjectMethod("PhysicsWorld", "void set_internalEdge(bool)", asMETHOD(PhysicsWorld, SetInternalEdge), asCALL_THISCALL);
+    engine->RegisterObjectMethod("PhysicsWorld", "bool get_internalEdge() const", asMETHOD(PhysicsWorld, GetInternalEdge), asCALL_THISCALL);
     engine->RegisterObjectMethod("PhysicsWorld", "void set_splitImpulse(bool)", asMETHOD(PhysicsWorld, SetSplitImpulse), asCALL_THISCALL);
     engine->RegisterObjectMethod("PhysicsWorld", "bool get_splitImpulse() const", asMETHOD(PhysicsWorld, GetSplitImpulse), asCALL_THISCALL);
     engine->RegisterObjectMethod("Scene", "PhysicsWorld@+ get_physicsWorld() const", asFUNCTION(SceneGetPhysicsWorld), asCALL_CDECL_OBJLAST);