Broken
This commit is contained in:
@@ -11,7 +11,7 @@ struct Physics : Component
|
|||||||
Physics()
|
Physics()
|
||||||
: Mass(1.f), Static(false), Phantom(false), CalculateCenterOfMass(true), CenterOfMass(glm::vec3(0)), InitialLinearVelocity(glm::vec3(0)), InitialAngularVelocity(glm::vec3(0)),
|
: Mass(1.f), Static(false), Phantom(false), CalculateCenterOfMass(true), CenterOfMass(glm::vec3(0)), InitialLinearVelocity(glm::vec3(0)), InitialAngularVelocity(glm::vec3(0)),
|
||||||
LinearDamping(0.f), AngularDamping(0.05f), GravityFactor(1.f), Friction(0.5f), Restitution(0.4f), MaxLinearVelocity(200.f), MaxAngularVelocity(200.f),
|
LinearDamping(0.f), AngularDamping(0.05f), GravityFactor(1.f), Friction(0.5f), Restitution(0.4f), MaxLinearVelocity(200.f), MaxAngularVelocity(200.f),
|
||||||
CollisionLayer(0), CollisionSystemGroup(0), CollisionSubSystemId(0), CollisionSubSystemDontCollideWith(0){}
|
CollisionLayer(0), CollisionSystemGroup(0), CollisionSubSystemId(0), CollisionSubSystemDontCollideWith(0), CollisionEvent(false){}
|
||||||
|
|
||||||
float Mass;
|
float Mass;
|
||||||
bool Static;
|
bool Static;
|
||||||
@@ -34,6 +34,7 @@ struct Physics : Component
|
|||||||
int CollisionSubSystemId;
|
int CollisionSubSystemId;
|
||||||
int CollisionSubSystemDontCollideWith;
|
int CollisionSubSystemDontCollideWith;
|
||||||
|
|
||||||
|
bool CollisionEvent;
|
||||||
|
|
||||||
virtual Physics* Clone() const override { return new Physics(*this); }
|
virtual Physics* Clone() const override { return new Physics(*this); }
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-2
@@ -101,7 +101,7 @@ void GameWorld::Initialize()
|
|||||||
auto physics = AddComponent<Components::Physics>(ground);
|
auto physics = AddComponent<Components::Physics>(ground);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->Static = true;
|
||||||
physics->CollisionLayer = 0;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground);
|
auto groundshape = CreateEntity(ground);
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
@@ -316,6 +316,7 @@ void GameWorld::Initialize()
|
|||||||
auto physics = AddComponent<Components::Physics>(shot);
|
auto physics = AddComponent<Components::Physics>(shot);
|
||||||
physics->Mass = 25.f;
|
physics->Mass = 25.f;
|
||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
|
physics->CollisionEvent = true;
|
||||||
auto modelComponent = AddComponent<Components::Model>(shot);
|
auto modelComponent = AddComponent<Components::Model>(shot);
|
||||||
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
||||||
auto tankShellComponent = AddComponent<Components::TankShell>(shot);
|
auto tankShellComponent = AddComponent<Components::TankShell>(shot);
|
||||||
@@ -678,7 +679,7 @@ void GameWorld::Initialize()
|
|||||||
auto physics = AddComponent<Components::Physics>(tank);
|
auto physics = AddComponent<Components::Physics>(tank);
|
||||||
physics->Mass = 63000 - 16000;
|
physics->Mass = 63000 - 16000;
|
||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 3;
|
||||||
auto vehicle = AddComponent<Components::Vehicle>(tank);
|
auto vehicle = AddComponent<Components::Vehicle>(tank);
|
||||||
vehicle->MaxTorque = 36000.f;
|
vehicle->MaxTorque = 36000.f;
|
||||||
vehicle->MaxSteeringAngle = 90.f;
|
vehicle->MaxSteeringAngle = 90.f;
|
||||||
@@ -739,6 +740,7 @@ void GameWorld::Initialize()
|
|||||||
auto physics = AddComponent<Components::Physics>(shot);
|
auto physics = AddComponent<Components::Physics>(shot);
|
||||||
physics->Mass = 25.f;
|
physics->Mass = 25.f;
|
||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
|
physics->CollisionEvent = true;
|
||||||
auto modelComponent = AddComponent<Components::Model>(shot);
|
auto modelComponent = AddComponent<Components::Model>(shot);
|
||||||
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
||||||
auto tankShellComponent = AddComponent<Components::TankShell>(shot);
|
auto tankShellComponent = AddComponent<Components::TankShell>(shot);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
|
|
||||||
bool tempSpawnedExplosions;
|
bool tempSpawnedExplosions;
|
||||||
|
|
||||||
EventRelay<Events::KeyUp> m_EKeyUp;
|
EventRelay<ParticleSystem, Events::KeyUp> m_EKeyUp;
|
||||||
bool OnKeyUp(const Events::KeyUp &e);
|
bool OnKeyUp(const Events::KeyUp &e);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+115
-26
@@ -110,14 +110,61 @@ void Systems::PhysicsSystem::Initialize()
|
|||||||
m_PhysicsWorld->unmarkForWrite();
|
m_PhysicsWorld->unmarkForWrite();
|
||||||
|
|
||||||
m_collisionResolution = new MyCollisionResolution(this);
|
m_collisionResolution = new MyCollisionResolution(this);
|
||||||
|
|
||||||
|
hkpBoxShape* shape = new hkpBoxShape(hkVector4(5, 5, 5), 0);
|
||||||
|
|
||||||
|
PhantomCallbackShape* phantom = new PhantomCallbackShape(this);
|
||||||
|
hkpBvShape* phantomShape = new hkpBvShape(shape, phantom);
|
||||||
|
|
||||||
|
hkMassProperties massProperties;
|
||||||
|
hkpInertiaTensorComputer::computeBoxVolumeMassProperties(hkVector4(5, 5, 5),1, massProperties);
|
||||||
|
|
||||||
|
hkpRigidBodyCinfo rigidBodyInfo;
|
||||||
|
{
|
||||||
|
rigidBodyInfo.m_shape = shape;
|
||||||
|
rigidBodyInfo.m_motionType = hkpMotion::MOTION_FIXED;
|
||||||
|
rigidBodyInfo.m_position = hkVector4(0, 0, 0);
|
||||||
|
|
||||||
|
rigidBodyInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
|
||||||
|
rigidBodyInfo.m_centerOfMass = massProperties.m_centerOfMass;
|
||||||
|
rigidBodyInfo.m_mass = massProperties.m_mass;
|
||||||
|
}
|
||||||
|
// Create RigidBody
|
||||||
|
|
||||||
|
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||||
|
m_PhysicsWorld->markForWrite();
|
||||||
|
m_PhysicsWorld->addEntity(rigidBody);
|
||||||
|
m_PhysicsWorld->unmarkForWrite();
|
||||||
|
|
||||||
|
shape->removeReference();
|
||||||
|
rigidBody->removeReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GROUND_LAYER = 1,
|
||||||
|
VEHICLE1_LAYER = 2,
|
||||||
|
VEHICLE2_LAYER = 3,
|
||||||
|
EXPLOSION_LAYER = 4,
|
||||||
|
};
|
||||||
{
|
{
|
||||||
Events::DisableCollisions e;
|
Events::DisableCollisions e;
|
||||||
e.Layer1 = 1;
|
e.Layer1 = GROUND_LAYER;
|
||||||
e.Layer2 = 2;
|
e.Layer2 = EXPLOSION_LAYER;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
/*{
|
||||||
|
Events::DisableCollisions e;
|
||||||
|
e.Layer1 = VEHICLE1_LAYER;
|
||||||
|
e.Layer2 = EXPLOSION_LAYER;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::DisableCollisions e;
|
||||||
|
e.Layer1 = VEHICLE2_LAYER;
|
||||||
|
e.Layer2 = EXPLOSION_LAYER;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::PhysicsSystem::RegisterComponents(ComponentFactory* cf)
|
void Systems::PhysicsSystem::RegisterComponents(ComponentFactory* cf)
|
||||||
@@ -277,7 +324,20 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
hkArray<hkpShape*> shapeArray;
|
hkArray<hkpShape*> shapeArray;
|
||||||
for (auto &shapeData : m_Shapes[entity])
|
for (auto &shapeData : m_Shapes[entity])
|
||||||
{
|
{
|
||||||
shapeArray.pushBack(shapeData.Shape);
|
auto childTransformComponent = m_World->GetComponent<Components::Transform>(shapeData.Entity);
|
||||||
|
hkpShape* shape;
|
||||||
|
|
||||||
|
if(shapeData.ConvexShape != nullptr)
|
||||||
|
{
|
||||||
|
hkQsTransform transform( GLMVEC3_TO_HKVECTOR4(childTransformComponent->Position), GLMQUAT_TO_HKQUATERNION(childTransformComponent->Orientation), GLMVEC3_TO_HKVECTOR4(childTransformComponent->Scale));
|
||||||
|
hkpConvexTransformShape* transformedBoxShape = new hkpConvexTransformShape( shapeData.ConvexShape, transform );
|
||||||
|
shapeArray.pushBack(transformedBoxShape);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(shapeData.Shape != nullptr)
|
||||||
|
{
|
||||||
|
shapeArray.pushBack(shapeData.Shape);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -285,15 +345,26 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
hkpListShape* listShape = new hkpListShape(shapeArray.begin(), shapeArray.getSize(), hkpShapeContainer::REFERENCE_POLICY_INCREMENT);
|
hkpListShape* listShape = new hkpListShape(shapeArray.begin(), shapeArray.getSize(), hkpShapeContainer::REFERENCE_POLICY_INCREMENT);
|
||||||
// Save the listShape for further use
|
// Save the listShape for further use
|
||||||
m_ListShapes[entity] = listShape;
|
m_ListShapes[entity] = listShape;
|
||||||
//shape = listShape;
|
hkMassProperties massProperties;
|
||||||
hkpBoxShape* box = new hkpBoxShape(listShape->m_aabbHalfExtents, 0.0f);
|
if(physicsComponent->Phantom)
|
||||||
shape = new hkpBvShape(listShape, box);
|
{
|
||||||
|
PhantomCallbackShape* phantom = new PhantomCallbackShape(this);
|
||||||
|
shape = new hkpBvShape(listShape, phantom);
|
||||||
|
hkpInertiaTensorComputer::computeSphereVolumeMassProperties(1, physicsComponent->Mass, massProperties);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hkpBoxShape* box = new hkpBoxShape(listShape->m_aabbHalfExtents, 0.0f);
|
||||||
|
shape = new hkpBvShape(listShape, box);
|
||||||
|
hkpInertiaTensorComputer::computeShapeVolumeMassProperties(shape, physicsComponent->Mass, massProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Clean up for less memory usage
|
// Clean up for less memory usage
|
||||||
m_Shapes.erase(entity);
|
m_Shapes.erase(entity);
|
||||||
|
|
||||||
hkMassProperties massProperties;
|
|
||||||
hkpInertiaTensorComputer::computeShapeVolumeMassProperties(shape, physicsComponent->Mass, massProperties);
|
|
||||||
|
|
||||||
hkpRigidBodyCinfo rigidBodyInfo;
|
hkpRigidBodyCinfo rigidBodyInfo;
|
||||||
{
|
{
|
||||||
@@ -344,7 +415,10 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
vehicleSetup.buildVehicle(m_World, m_PhysicsWorld, *m_Vehicles[entity], entity, m_Wheels);
|
vehicleSetup.buildVehicle(m_World, m_PhysicsWorld, *m_Vehicles[entity], entity, m_Wheels);
|
||||||
// Add the vehicle's entities and phantoms to the world
|
// Add the vehicle's entities and phantoms to the world
|
||||||
rigidBody->addContactListener( m_collisionResolution );
|
if(physicsComponent->CollisionEvent)
|
||||||
|
{
|
||||||
|
rigidBody->addContactListener( m_collisionResolution );
|
||||||
|
}
|
||||||
m_Vehicles[entity]->addToWorld(m_PhysicsWorld);
|
m_Vehicles[entity]->addToWorld(m_PhysicsWorld);
|
||||||
m_RigidBodies[entity] = rigidBody;
|
m_RigidBodies[entity] = rigidBody;
|
||||||
m_RigidBodyEntities[rigidBody] = entity;
|
m_RigidBodyEntities[rigidBody] = entity;
|
||||||
@@ -362,7 +436,10 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
rigidBody->addContactListener( m_collisionResolution );
|
if(physicsComponent->CollisionEvent)
|
||||||
|
{
|
||||||
|
rigidBody->addContactListener( m_collisionResolution );
|
||||||
|
}
|
||||||
m_PhysicsWorld->addEntity(rigidBody);
|
m_PhysicsWorld->addEntity(rigidBody);
|
||||||
m_RigidBodies[entity] = rigidBody;
|
m_RigidBodies[entity] = rigidBody;
|
||||||
m_RigidBodyEntities[rigidBody] = entity;
|
m_RigidBodyEntities[rigidBody] = entity;
|
||||||
@@ -388,15 +465,35 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
hkVector4 scale = GLMVEC3_TO_HKVECTOR4(childTransformComponent->Scale);
|
hkVector4 scale = GLMVEC3_TO_HKVECTOR4(childTransformComponent->Scale);
|
||||||
hkQsTransform transform(position, rotation, scale);
|
hkQsTransform transform(position, rotation, scale);
|
||||||
|
|
||||||
staticCompoundShape->addInstance(shapeData.Shape, transform);
|
if(shapeData.ConvexShape != nullptr)
|
||||||
|
{
|
||||||
|
staticCompoundShape->addInstance(shapeData.ConvexShape, transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(shapeData.Shape != nullptr)
|
||||||
|
{
|
||||||
|
staticCompoundShape->addInstance(shapeData.Shape, transform);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This must be called after adding the instances and before using the shape.
|
// This must be called after adding the instances and before using the shape.
|
||||||
staticCompoundShape->bake();
|
staticCompoundShape->bake();
|
||||||
shape = staticCompoundShape;
|
shape = staticCompoundShape;
|
||||||
m_Shapes.erase(entity);
|
|
||||||
hkMassProperties massProperties;
|
hkMassProperties massProperties;
|
||||||
hkpInertiaTensorComputer::computeShapeVolumeMassProperties(shape, physicsComponent->Mass, massProperties);
|
if(physicsComponent->Phantom)
|
||||||
|
{
|
||||||
|
PhantomCallbackShape* phantom = new PhantomCallbackShape(this);
|
||||||
|
shape = new hkpBvShape(shape, phantom);
|
||||||
|
hkpInertiaTensorComputer::computeSphereVolumeMassProperties(1, physicsComponent->Mass, massProperties);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hkpInertiaTensorComputer::computeShapeVolumeMassProperties(shape, physicsComponent->Mass, massProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Shapes.erase(entity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hkpRigidBodyCinfo rigidBodyInfo;
|
hkpRigidBodyCinfo rigidBodyInfo;
|
||||||
{
|
{
|
||||||
@@ -424,7 +521,6 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
||||||
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
||||||
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
||||||
|
|
||||||
}
|
}
|
||||||
// Create RigidBody
|
// Create RigidBody
|
||||||
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||||
@@ -447,24 +543,17 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
if(sphereComponent)
|
if(sphereComponent)
|
||||||
{
|
{
|
||||||
hkpSphereShape* sphereShape = new hkpSphereShape(sphereComponent->Radius);
|
hkpSphereShape* sphereShape = new hkpSphereShape(sphereComponent->Radius);
|
||||||
|
m_Shapes[entityParent].push_back(ShapeArrayData(entity, sphereShape, nullptr));
|
||||||
|
|
||||||
hkQsTransform transform( GLMVEC3_TO_HKVECTOR4(transformComponent->Position), GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation), GLMVEC3_TO_HKVECTOR4(transformComponent->Scale));
|
//sphereShape->removeReference();
|
||||||
hkpConvexTransformShape* transformedSphereShape = new hkpConvexTransformShape( sphereShape, transform );
|
|
||||||
|
|
||||||
m_Shapes[entityParent].push_back(ShapeArrayData(entity, transformedSphereShape));
|
|
||||||
|
|
||||||
sphereShape->removeReference();
|
|
||||||
}
|
}
|
||||||
//TODO: COMMENT THIS SECTION
|
//TODO: COMMENT THIS SECTION
|
||||||
else if(boxComponent)
|
else if(boxComponent)
|
||||||
{
|
{
|
||||||
hkReal thickness = 0.05;
|
hkReal thickness = 0.05;
|
||||||
hkpBoxShape* boxShape = new hkpBoxShape(hkVector4(boxComponent->Width- thickness, boxComponent->Height -thickness, boxComponent->Depth - thickness), thickness);
|
hkpBoxShape* boxShape = new hkpBoxShape(hkVector4(boxComponent->Width- thickness, boxComponent->Height -thickness, boxComponent->Depth - thickness), thickness);
|
||||||
|
m_Shapes[entityParent].push_back(ShapeArrayData(entity, boxShape, nullptr));
|
||||||
hkQsTransform transform( GLMVEC3_TO_HKVECTOR4(transformComponent->Position), GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation), GLMVEC3_TO_HKVECTOR4(transformComponent->Scale));
|
//boxShape->removeReference();
|
||||||
hkpConvexTransformShape* transformedBoxShape = new hkpConvexTransformShape( boxShape, transform );
|
|
||||||
m_Shapes[entityParent].push_back(ShapeArrayData(entity, transformedBoxShape));
|
|
||||||
boxShape->removeReference();
|
|
||||||
}
|
}
|
||||||
else if(meshShapeComponent)
|
else if(meshShapeComponent)
|
||||||
{
|
{
|
||||||
@@ -513,7 +602,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
|
|
||||||
m_ExtendedMeshShapes[entity].Code = code;
|
m_ExtendedMeshShapes[entity].Code = code;
|
||||||
m_ExtendedMeshShapes[entity].MoppShape = moppShape;
|
m_ExtendedMeshShapes[entity].MoppShape = moppShape;
|
||||||
m_Shapes[entityParent].push_back(ShapeArrayData(entity, moppShape)); //HACK: Should maybe have transform, not sure yet
|
m_Shapes[entityParent].push_back(ShapeArrayData(entity, nullptr, moppShape));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-12
@@ -76,6 +76,8 @@
|
|||||||
|
|
||||||
#include <Physics2012/Dynamics/Collide/ContactListener/hkpContactListener.h>
|
#include <Physics2012/Dynamics/Collide/ContactListener/hkpContactListener.h>
|
||||||
|
|
||||||
|
#include <Physics2012/Collide/Agent/CompoundAgent/BvTree/hkpBvTreeAgent.h>
|
||||||
|
|
||||||
#include "Components/TankShell.h"
|
#include "Components/TankShell.h"
|
||||||
#include <Physics2012/Collide/Shape/Misc/PhantomCallback/hkpPhantomCallbackShape.h>
|
#include <Physics2012/Collide/Shape/Misc/PhantomCallback/hkpPhantomCallbackShape.h>
|
||||||
#include "Events/EnableCollisions.h"
|
#include "Events/EnableCollisions.h"
|
||||||
@@ -101,7 +103,7 @@ public:
|
|||||||
Events::Collision e;
|
Events::Collision e;
|
||||||
e.Entity1 = entity1;
|
e.Entity1 = entity1;
|
||||||
e.Entity2 = entity2;
|
e.Entity2 = entity2;
|
||||||
//m_PhysicsSystem->EventBroker->Publish(e);
|
m_PhysicsSystem->EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -118,20 +120,14 @@ public:
|
|||||||
|
|
||||||
virtual void phantomEnterEvent( const hkpCollidable* collidableA, const hkpCollidable* collidableB, const hkpCollisionInput& env )
|
virtual void phantomEnterEvent( const hkpCollidable* collidableA, const hkpCollidable* collidableB, const hkpCollisionInput& env )
|
||||||
{
|
{
|
||||||
Events::ApplyPointImpulse e;
|
|
||||||
e.Entity = m_PhysicsSystem->m_RigidBodyEntities[hkpGetRigidBody(collidableB)];
|
|
||||||
e.Position = HKVECTOR4_TO_GLMVEC3(hkpGetRigidBody(collidableB)->getPosition());
|
|
||||||
|
|
||||||
glm::vec3 impulse;
|
LOG_INFO("AAAAAAAAAAAAAAAAAAAAAAAAAH!");
|
||||||
impulse = HKVECTOR4_TO_GLMVEC3(hkpGetRigidBody(collidableA)->getPosition()) - HKVECTOR4_TO_GLMVEC3(hkpGetRigidBody(collidableB)->getPosition());
|
|
||||||
e.Impulse = impulse;
|
|
||||||
|
|
||||||
m_PhysicsSystem->EventBroker->Publish(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void phantomLeaveEvent( const hkpCollidable* collidableA, const hkpCollidable* collidableB )
|
virtual void phantomLeaveEvent( const hkpCollidable* collidableA, const hkpCollidable* collidableB )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
LOG_INFO("AAAAAAAAAAAAAAAAAAAAAAAAAH!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -167,9 +163,9 @@ private:
|
|||||||
EventRelay<PhysicsSystem, Events::ApplyPointImpulse> m_EApplyPointImpulse;
|
EventRelay<PhysicsSystem, Events::ApplyPointImpulse> m_EApplyPointImpulse;
|
||||||
bool OnApplyPointImpulse(const Events::ApplyPointImpulse &event);
|
bool OnApplyPointImpulse(const Events::ApplyPointImpulse &event);
|
||||||
|
|
||||||
EventRelay<Events::EnableCollisions> m_EEnableCollisions;
|
EventRelay<PhysicsSystem, Events::EnableCollisions> m_EEnableCollisions;
|
||||||
bool OnEnableCollisions(const Events::EnableCollisions &e);
|
bool OnEnableCollisions(const Events::EnableCollisions &e);
|
||||||
EventRelay<Events::DisableCollisions> m_EDisableCollisions;
|
EventRelay<PhysicsSystem, Events::DisableCollisions> m_EDisableCollisions;
|
||||||
bool OnDisableCollisions(const Events::DisableCollisions &e);
|
bool OnDisableCollisions(const Events::DisableCollisions &e);
|
||||||
|
|
||||||
|
|
||||||
@@ -198,12 +194,14 @@ private:
|
|||||||
|
|
||||||
struct ShapeArrayData
|
struct ShapeArrayData
|
||||||
{
|
{
|
||||||
ShapeArrayData(EntityID entity, hkpShape* shape)
|
ShapeArrayData(EntityID entity, hkpConvexShape* convexShape, hkpShape* shape)
|
||||||
{
|
{
|
||||||
Entity = entity;
|
Entity = entity;
|
||||||
|
ConvexShape = convexShape;
|
||||||
Shape = shape;
|
Shape = shape;
|
||||||
}
|
}
|
||||||
EntityID Entity;
|
EntityID Entity;
|
||||||
|
hkpConvexShape* ConvexShape;
|
||||||
hkpShape* Shape;
|
hkpShape* Shape;
|
||||||
};
|
};
|
||||||
std::unordered_map<EntityID, std::list<ShapeArrayData>> m_Shapes;
|
std::unordered_map<EntityID, std::list<ShapeArrayData>> m_Shapes;
|
||||||
|
|||||||
@@ -120,8 +120,9 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
|||||||
transformHit->Position = transform->Position;
|
transformHit->Position = transform->Position;
|
||||||
|
|
||||||
auto physics = m_World->AddComponent<Components::Physics>(hitSphere);
|
auto physics = m_World->AddComponent<Components::Physics>(hitSphere);
|
||||||
physics->Static = false;
|
physics->Static = true;
|
||||||
physics->Phantom = true;
|
physics->Phantom = false;
|
||||||
|
physics->CollisionLayer = 4;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = m_World->CreateEntity(hitSphere);
|
auto shape = m_World->CreateEntity(hitSphere);
|
||||||
@@ -153,8 +154,9 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
|||||||
transformHit->Position = transform->Position;
|
transformHit->Position = transform->Position;
|
||||||
|
|
||||||
auto physics = m_World->AddComponent<Components::Physics>(hitSphere);
|
auto physics = m_World->AddComponent<Components::Physics>(hitSphere);
|
||||||
physics->Static = false;
|
physics->Static = true;
|
||||||
physics->Phantom = true;
|
physics->Phantom = false;
|
||||||
|
physics->CollisionLayer = 4;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = m_World->CreateEntity(hitSphere);
|
auto shape = m_World->CreateEntity(hitSphere);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace Systems
|
|||||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRelay<Events::Collision> m_ECollision;
|
EventRelay<TankSteeringSystem, Events::Collision> m_ECollision;
|
||||||
bool OnCollision(const Events::Collision &e);
|
bool OnCollision(const Events::Collision &e);
|
||||||
|
|
||||||
class TankSteeringInputController;
|
class TankSteeringInputController;
|
||||||
|
|||||||
Reference in New Issue
Block a user