From bd4a26d5c7f0a1920511bd66223adad0327adfb1 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Sun, 24 May 2020 16:13:44 +0200 Subject: [PATCH] Small modifications --- include/reactphysics3d/collision/CollisionCallback.h | 8 ++++---- include/reactphysics3d/engine/EventListener.h | 7 ------- src/utils/DebugRenderer.cpp | 2 +- test/tests/collision/TestCollisionWorld.h | 2 +- testbed/common/Capsule.cpp | 3 +-- .../collisiondetection/CollisionDetectionScene.cpp | 4 ++-- testbed/scenes/collisionshapes/CollisionShapesScene.h | 10 +++++----- testbed/scenes/cubes/CubesScene.h | 2 +- testbed/src/SceneDemo.cpp | 4 ++-- 9 files changed, 17 insertions(+), 25 deletions(-) diff --git a/include/reactphysics3d/collision/CollisionCallback.h b/include/reactphysics3d/collision/CollisionCallback.h index ef99e631..fb17675d 100644 --- a/include/reactphysics3d/collision/CollisionCallback.h +++ b/include/reactphysics3d/collision/CollisionCallback.h @@ -90,10 +90,10 @@ class CollisionCallback { const Vector3& getWorldNormal() const; /// Return the contact point on the first collider in the local-space of the first collider - const Vector3& getLocalPointOnShape1() const; + const Vector3& getLocalPointOnCollider1() const; /// Return the contact point on the second collider in the local-space of the second collider - const Vector3& getLocalPointOnShape2() const; + const Vector3& getLocalPointOnCollider2() const; // -------------------- Friendship -------------------- // @@ -288,7 +288,7 @@ inline const Vector3& CollisionCallback::ContactPoint::getWorldNormal() const { /** * @return The contact point in the local-space of the first collider (from body1) in contact */ -inline const Vector3& CollisionCallback::ContactPoint::getLocalPointOnShape1() const { +inline const Vector3& CollisionCallback::ContactPoint::getLocalPointOnCollider1() const { return mContactPoint.getLocalPointOnShape1(); } @@ -296,7 +296,7 @@ inline const Vector3& CollisionCallback::ContactPoint::getLocalPointOnShape1() c /** * @return The contact point in the local-space of the second collider (from body2) in contact */ -inline const Vector3& CollisionCallback::ContactPoint::getLocalPointOnShape2() const { +inline const Vector3& CollisionCallback::ContactPoint::getLocalPointOnCollider2() const { return mContactPoint.getLocalPointOnShape2(); } diff --git a/include/reactphysics3d/engine/EventListener.h b/include/reactphysics3d/engine/EventListener.h index 2f59894f..2f05c3e6 100644 --- a/include/reactphysics3d/engine/EventListener.h +++ b/include/reactphysics3d/engine/EventListener.h @@ -44,13 +44,6 @@ class EventListener : public CollisionCallback { public : - enum class ErrorType { - Warning, - InvalidParameter, - InvalidOperation, - InternalError - }; - // ---------- Methods ---------- // /// Constructor diff --git a/src/utils/DebugRenderer.cpp b/src/utils/DebugRenderer.cpp index 4a811cbb..a36c45e8 100644 --- a/src/utils/DebugRenderer.cpp +++ b/src/utils/DebugRenderer.cpp @@ -458,7 +458,7 @@ void DebugRenderer::onContact(const CollisionCallback::CallbackData& callbackDat CollisionCallback::ContactPoint contactPoint = contactPair.getContactPoint(c); - Vector3 point = contactPair.getCollider1()->getLocalToWorldTransform() * contactPoint.getLocalPointOnShape1(); + Vector3 point = contactPair.getCollider1()->getLocalToWorldTransform() * contactPoint.getLocalPointOnCollider1(); if (getIsDebugItemDisplayed(DebugItem::CONTACT_POINT)) { diff --git a/test/tests/collision/TestCollisionWorld.h b/test/tests/collision/TestCollisionWorld.h index d5e337f7..4c02d49c 100644 --- a/test/tests/collision/TestCollisionWorld.h +++ b/test/tests/collision/TestCollisionWorld.h @@ -202,7 +202,7 @@ class WorldCollisionCallback : public CollisionCallback ContactPoint contactPoint = contactPair.getContactPoint(c); - CollisionPointData collisionPoint(contactPoint.getLocalPointOnShape1(), contactPoint.getLocalPointOnShape2(), contactPoint.getPenetrationDepth()); + CollisionPointData collisionPoint(contactPoint.getLocalPointOnCollider1(), contactPoint.getLocalPointOnCollider2(), contactPoint.getPenetrationDepth()); contactPairData.contactPoints.push_back(collisionPoint); } diff --git a/testbed/common/Capsule.cpp b/testbed/common/Capsule.cpp index a5131ac2..2c3b4358 100644 --- a/testbed/common/Capsule.cpp +++ b/testbed/common/Capsule.cpp @@ -96,8 +96,7 @@ Capsule::~Capsule() { } // Render the sphere at the correct position and with the correct orientation -void Capsule::render(openglframework::Shader& shader, - const openglframework::Matrix4& worldToCameraMatrix) { +void Capsule::render(openglframework::Shader& shader, const openglframework::Matrix4& worldToCameraMatrix) { // Bind the shader shader.bind(); diff --git a/testbed/scenes/collisiondetection/CollisionDetectionScene.cpp b/testbed/scenes/collisiondetection/CollisionDetectionScene.cpp index 06b809f1..908e1336 100644 --- a/testbed/scenes/collisiondetection/CollisionDetectionScene.cpp +++ b/testbed/scenes/collisiondetection/CollisionDetectionScene.cpp @@ -341,13 +341,13 @@ void ContactManager::onContact(const CallbackData& callbackData) { rp3d::Vector3 normal = contactPoint.getWorldNormal(); openglframework::Vector3 contactNormal(normal.x, normal.y, normal.z); - rp3d::Vector3 point1 = contactPoint.getLocalPointOnShape1(); + rp3d::Vector3 point1 = contactPoint.getLocalPointOnCollider1(); point1 = contactPair.getCollider1()->getLocalToWorldTransform() * point1; openglframework::Vector3 position1(point1.x, point1.y, point1.z); mContactPoints.push_back(SceneContactPoint(position1, contactNormal, openglframework::Color::red())); - rp3d::Vector3 point2 = contactPoint.getLocalPointOnShape2(); + rp3d::Vector3 point2 = contactPoint.getLocalPointOnCollider2(); point2 = contactPair.getCollider2()->getLocalToWorldTransform() * point2; openglframework::Vector3 position2(point2.x, point2.y, point2.z); mContactPoints.push_back(SceneContactPoint(position2, contactNormal, openglframework::Color::blue())); diff --git a/testbed/scenes/collisionshapes/CollisionShapesScene.h b/testbed/scenes/collisionshapes/CollisionShapesScene.h index 8b8fc2e4..e836111e 100644 --- a/testbed/scenes/collisionshapes/CollisionShapesScene.h +++ b/testbed/scenes/collisionshapes/CollisionShapesScene.h @@ -42,11 +42,11 @@ namespace collisionshapesscene { // Constants const float SCENE_RADIUS = 30.0f; -const int NB_BOXES = 2; -const int NB_SPHERES = 2; -const int NB_CAPSULES = 2; -const int NB_MESHES = 2; -const int NB_COMPOUND_SHAPES = 1; +const int NB_BOXES = 10; +const int NB_SPHERES = 5; +const int NB_CAPSULES = 5; +const int NB_MESHES = 5; +const int NB_COMPOUND_SHAPES = 5; const openglframework::Vector3 BOX_SIZE(2, 2, 2); const float SPHERE_RADIUS = 1.5f; const float CONE_RADIUS = 2.0f; diff --git a/testbed/scenes/cubes/CubesScene.h b/testbed/scenes/cubes/CubesScene.h index 6bee4cc5..ae845452 100755 --- a/testbed/scenes/cubes/CubesScene.h +++ b/testbed/scenes/cubes/CubesScene.h @@ -36,7 +36,7 @@ namespace cubesscene { // Constants const float SCENE_RADIUS = 30.0f; // Radius of the scene in meters -const int NB_CUBES = 1; // Number of boxes in the scene +const int NB_CUBES = 40; // Number of boxes in the scene const openglframework::Vector3 BOX_SIZE(2, 2, 2); // Box dimensions in meters const openglframework::Vector3 FLOOR_SIZE(50, 1, 50); // Floor dimensions in meters diff --git a/testbed/src/SceneDemo.cpp b/testbed/src/SceneDemo.cpp index 1464322c..19bf4466 100644 --- a/testbed/src/SceneDemo.cpp +++ b/testbed/src/SceneDemo.cpp @@ -33,7 +33,8 @@ using namespace openglframework; int SceneDemo::shadowMapTextureLevel = 0; -openglframework::Color SceneDemo::mObjectColorDemo = Color(0.76f, 0.67f, 0.47f, 1.0f); +//openglframework::Color SceneDemo::mObjectColorDemo = Color(0.76f, 0.67f, 0.47f, 1.0f); +openglframework::Color SceneDemo::mObjectColorDemo = Color(0.35f, 0.65f, 0.78f, 1.0f); openglframework::Color SceneDemo::mFloorColorDemo = Color(0.47f, 0.48f, 0.49f, 1.0f); openglframework::Color SceneDemo::mSleepingColorDemo = Color(1.0f, 0.25f, 0.25f, 1.0f); openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.59f, 0.88f, 1.0f); @@ -102,7 +103,6 @@ SceneDemo::SceneDemo(const std::string& name, EngineSettings& settings, bool isP // Destructor SceneDemo::~SceneDemo() { - for (int i = 0; i < NB_SHADOW_MAPS; i++) { mShadowMapTexture[i].destroy(); mFBOShadowMap[i].destroy();