67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
#include <UnitTest++.h>
|
|
|
|
#include "Logging.h"
|
|
#include "PhysicsBase.h"
|
|
#include "ModelBase.h"
|
|
#include "EntityBase.h"
|
|
|
|
using namespace std;
|
|
using namespace Engine;
|
|
|
|
struct PhysicsFixture {
|
|
PhysicsFixture () {
|
|
LoggingModule.Init (0, NULL);
|
|
LoggingModule.SetLogPrintLevel (LogLevelMessage);
|
|
PhysicsModule.Init (0, NULL);
|
|
|
|
dummy_entity = CreateEntityPhysicState (EntityBaseTypeNone, 0);
|
|
particle_entity = CreateEntityPhysicState (EntityBaseTypeParticle, 1);
|
|
block_entity = CreateEntityPhysicState (EntityBaseTypeBlock, 2);
|
|
actor_entity = CreateEntityPhysicState (EntityBaseTypeActor, 3);
|
|
|
|
PhysicsModule.RegisterEntity (dummy_entity);
|
|
PhysicsModule.RegisterEntity (particle_entity);
|
|
PhysicsModule.RegisterEntity (block_entity);
|
|
PhysicsModule.RegisterEntity (actor_entity);
|
|
}
|
|
|
|
~PhysicsFixture () {
|
|
PhysicsModule.UnregisterEntity (0);
|
|
PhysicsModule.UnregisterEntity (1);
|
|
PhysicsModule.UnregisterEntity (2);
|
|
PhysicsModule.UnregisterEntity (3);
|
|
|
|
PhysicsModule.Destroy ();
|
|
LoggingModule.Destroy ();
|
|
}
|
|
|
|
Logging LoggingModule;
|
|
PhysicsBase PhysicsModule;
|
|
|
|
EntityPhysicState* dummy_entity;
|
|
EntityPhysicState* particle_entity;
|
|
EntityPhysicState* block_entity;
|
|
EntityPhysicState* actor_entity;
|
|
};
|
|
|
|
TEST_FIXTURE ( PhysicsFixture, PhysicsModuleActorActorCollision ) {
|
|
int result = -1;
|
|
|
|
EntityPhysicState* actor_2_entity = CreateEntityPhysicState (EntityBaseTypeActor, 4);
|
|
assert (actor_2_entity->mShape);
|
|
assert (actor_entity->mShape);
|
|
|
|
PhysicsModule.RegisterEntity (actor_2_entity);
|
|
|
|
actor_entity->mPosition = vector3d (0., 0., 0.);
|
|
actor_entity->mVelocity = vector3d (1., 0., 0.);
|
|
|
|
actor_2_entity->mPosition = vector3d (1.5, 0., 0.1);
|
|
actor_2_entity->mVelocity = vector3d (-1., 0., 0.);
|
|
|
|
result = PhysicsModule.Simulate (1000.);
|
|
CHECK_EQUAL (0, result);
|
|
|
|
PhysicsModule.UnregisterEntity (actor_2_entity->mId);
|
|
}
|