Small modifications
This commit is contained in:
parent
d353407cd9
commit
bd4a26d5c7
|
@ -90,10 +90,10 @@ class CollisionCallback {
|
||||||
const Vector3& getWorldNormal() const;
|
const Vector3& getWorldNormal() const;
|
||||||
|
|
||||||
/// Return the contact point on the first collider in the local-space of the first collider
|
/// 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
|
/// 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 -------------------- //
|
// -------------------- 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
|
* @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();
|
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
|
* @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();
|
return mContactPoint.getLocalPointOnShape2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,6 @@ class EventListener : public CollisionCallback {
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
enum class ErrorType {
|
|
||||||
Warning,
|
|
||||||
InvalidParameter,
|
|
||||||
InvalidOperation,
|
|
||||||
InternalError
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------- Methods ---------- //
|
// ---------- Methods ---------- //
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
|
|
@ -458,7 +458,7 @@ void DebugRenderer::onContact(const CollisionCallback::CallbackData& callbackDat
|
||||||
|
|
||||||
CollisionCallback::ContactPoint contactPoint = contactPair.getContactPoint(c);
|
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)) {
|
if (getIsDebugItemDisplayed(DebugItem::CONTACT_POINT)) {
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ class WorldCollisionCallback : public CollisionCallback
|
||||||
|
|
||||||
ContactPoint contactPoint = contactPair.getContactPoint(c);
|
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);
|
contactPairData.contactPoints.push_back(collisionPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,7 @@ Capsule::~Capsule() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the sphere at the correct position and with the correct orientation
|
// Render the sphere at the correct position and with the correct orientation
|
||||||
void Capsule::render(openglframework::Shader& shader,
|
void Capsule::render(openglframework::Shader& shader, const openglframework::Matrix4& worldToCameraMatrix) {
|
||||||
const openglframework::Matrix4& worldToCameraMatrix) {
|
|
||||||
|
|
||||||
// Bind the shader
|
// Bind the shader
|
||||||
shader.bind();
|
shader.bind();
|
||||||
|
|
|
@ -341,13 +341,13 @@ void ContactManager::onContact(const CallbackData& callbackData) {
|
||||||
rp3d::Vector3 normal = contactPoint.getWorldNormal();
|
rp3d::Vector3 normal = contactPoint.getWorldNormal();
|
||||||
openglframework::Vector3 contactNormal(normal.x, normal.y, normal.z);
|
openglframework::Vector3 contactNormal(normal.x, normal.y, normal.z);
|
||||||
|
|
||||||
rp3d::Vector3 point1 = contactPoint.getLocalPointOnShape1();
|
rp3d::Vector3 point1 = contactPoint.getLocalPointOnCollider1();
|
||||||
point1 = contactPair.getCollider1()->getLocalToWorldTransform() * point1;
|
point1 = contactPair.getCollider1()->getLocalToWorldTransform() * point1;
|
||||||
|
|
||||||
openglframework::Vector3 position1(point1.x, point1.y, point1.z);
|
openglframework::Vector3 position1(point1.x, point1.y, point1.z);
|
||||||
mContactPoints.push_back(SceneContactPoint(position1, contactNormal, openglframework::Color::red()));
|
mContactPoints.push_back(SceneContactPoint(position1, contactNormal, openglframework::Color::red()));
|
||||||
|
|
||||||
rp3d::Vector3 point2 = contactPoint.getLocalPointOnShape2();
|
rp3d::Vector3 point2 = contactPoint.getLocalPointOnCollider2();
|
||||||
point2 = contactPair.getCollider2()->getLocalToWorldTransform() * point2;
|
point2 = contactPair.getCollider2()->getLocalToWorldTransform() * point2;
|
||||||
openglframework::Vector3 position2(point2.x, point2.y, point2.z);
|
openglframework::Vector3 position2(point2.x, point2.y, point2.z);
|
||||||
mContactPoints.push_back(SceneContactPoint(position2, contactNormal, openglframework::Color::blue()));
|
mContactPoints.push_back(SceneContactPoint(position2, contactNormal, openglframework::Color::blue()));
|
||||||
|
|
|
@ -42,11 +42,11 @@ namespace collisionshapesscene {
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const float SCENE_RADIUS = 30.0f;
|
const float SCENE_RADIUS = 30.0f;
|
||||||
const int NB_BOXES = 2;
|
const int NB_BOXES = 10;
|
||||||
const int NB_SPHERES = 2;
|
const int NB_SPHERES = 5;
|
||||||
const int NB_CAPSULES = 2;
|
const int NB_CAPSULES = 5;
|
||||||
const int NB_MESHES = 2;
|
const int NB_MESHES = 5;
|
||||||
const int NB_COMPOUND_SHAPES = 1;
|
const int NB_COMPOUND_SHAPES = 5;
|
||||||
const openglframework::Vector3 BOX_SIZE(2, 2, 2);
|
const openglframework::Vector3 BOX_SIZE(2, 2, 2);
|
||||||
const float SPHERE_RADIUS = 1.5f;
|
const float SPHERE_RADIUS = 1.5f;
|
||||||
const float CONE_RADIUS = 2.0f;
|
const float CONE_RADIUS = 2.0f;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace cubesscene {
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const float SCENE_RADIUS = 30.0f; // Radius of the scene in meters
|
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 BOX_SIZE(2, 2, 2); // Box dimensions in meters
|
||||||
const openglframework::Vector3 FLOOR_SIZE(50, 1, 50); // Floor dimensions in meters
|
const openglframework::Vector3 FLOOR_SIZE(50, 1, 50); // Floor dimensions in meters
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
using namespace openglframework;
|
using namespace openglframework;
|
||||||
|
|
||||||
int SceneDemo::shadowMapTextureLevel = 0;
|
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::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::mSleepingColorDemo = Color(1.0f, 0.25f, 0.25f, 1.0f);
|
||||||
openglframework::Color SceneDemo::mSelectedObjectColorDemo = Color(0.09f, 0.59f, 0.88f, 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
|
// Destructor
|
||||||
SceneDemo::~SceneDemo() {
|
SceneDemo::~SceneDemo() {
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < NB_SHADOW_MAPS; i++) {
|
for (int i = 0; i < NB_SHADOW_MAPS; i++) {
|
||||||
mShadowMapTexture[i].destroy();
|
mShadowMapTexture[i].destroy();
|
||||||
mFBOShadowMap[i].destroy();
|
mFBOShadowMap[i].destroy();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user