reporting now collision normal and collision point when collisions occur
This commit is contained in:
+1
-1
@@ -144,7 +144,7 @@ struct EntityBase {
|
||||
* \returns true if it was able to react for this type of entity, false
|
||||
* false otherwise
|
||||
*/
|
||||
virtual bool CollisionEvent (EntityBase* entity_state) {
|
||||
virtual bool CollisionEvent (EntityBase* entity_state, vector3d point, vector3d normal) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
+3
-6
@@ -5,15 +5,10 @@
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include "mathlib.h"
|
||||
|
||||
namespace Engine {
|
||||
|
||||
class Module;
|
||||
|
||||
/** \brief Contains all information relevant to the Event */
|
||||
struct EventBase {
|
||||
int mEventType;
|
||||
@@ -23,6 +18,8 @@ struct EventBase {
|
||||
float mEventFloat;
|
||||
int mEventInt;
|
||||
unsigned int mEventUnsignedInt;
|
||||
vector3d mVector3d;
|
||||
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<EventBase> EventBasePtr;
|
||||
|
||||
+3
-3
@@ -215,7 +215,7 @@ void ModelBase::SetPlayerEntityId(unsigned int entity_id) {
|
||||
* \param collision_time The time when the collision occured relative to the start of the simulation frame
|
||||
*/
|
||||
void ModelBase::SendEntityCollisionEvent (const unsigned int reference_entity_id,
|
||||
const unsigned int incidence_entity_id, float collision_time, vector3d normal) {
|
||||
const unsigned int incidence_entity_id, float collision_time, vector3d point, vector3d normal) {
|
||||
// Check whether we report the same contact over and over
|
||||
static unsigned int last_reference_entity_id = 0;
|
||||
static unsigned int last_incidence_entity_id = 0;
|
||||
@@ -248,10 +248,10 @@ void ModelBase::SendEntityCollisionEvent (const unsigned int reference_entity_id
|
||||
|
||||
// If the incidence entity accepted the collision we can return, otherwise
|
||||
// we perform the symmetric collision event.
|
||||
if (incidence_entity->CollisionEvent (reference_entity))
|
||||
if (incidence_entity->CollisionEvent (reference_entity, point, normal))
|
||||
return;
|
||||
|
||||
reference_entity->CollisionEvent (incidence_entity);
|
||||
reference_entity->CollisionEvent (incidence_entity, point, normal * -1.);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class ModelBase : public Module {
|
||||
|
||||
/** Notifies the gamelogic of a collision event */
|
||||
void SendEntityCollisionEvent (const unsigned int reference_entity_id,
|
||||
const unsigned int incidence_entity_id, float collision_time, vector3d normal);
|
||||
const unsigned int incidence_entity_id, float collision_time, vector3d point, vector3d normal);
|
||||
|
||||
virtual void SetGameState (const unsigned int &state) {
|
||||
mLastGameState = mGameState;
|
||||
|
||||
@@ -100,7 +100,7 @@ int PhysicsBase::Simulate (float msec, ModelBase* model) {
|
||||
ResolveCollision (0., entity_a_id, entity_b_id, info);
|
||||
// Send the collision event to the Model (if we have one)
|
||||
if (model) {
|
||||
model->SendEntityCollisionEvent (entity_a_id, entity_b_id, info.time, info.normal);
|
||||
model->SendEntityCollisionEvent (entity_a_id, entity_b_id, info.time, info.point, info.normal);
|
||||
}
|
||||
// collision_remaining_step -= 1.0e-4;
|
||||
} else {
|
||||
@@ -109,7 +109,7 @@ int PhysicsBase::Simulate (float msec, ModelBase* model) {
|
||||
ResolveCollision (info.time * (1 - alpha), entity_a_id, entity_b_id, info);
|
||||
// Send the collision event to the Model (if we have one)
|
||||
if (model) {
|
||||
model->SendEntityCollisionEvent (entity_a_id, entity_b_id, info.time, info.normal);
|
||||
model->SendEntityCollisionEvent (entity_a_id, entity_b_id, info.time, info.point, info.normal);
|
||||
}
|
||||
collision_remaining_step -= info.time * (1 - alpha);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user