Rename BodyComponents class to CollisionBodyComponents

This commit is contained in:
Daniel Chappuis 2019-07-15 17:44:45 +02:00
parent 569964e365
commit b93ba5c476
8 changed files with 37 additions and 37 deletions

View File

@ -141,7 +141,7 @@ SET (REACTPHYSICS3D_HEADERS
"src/engine/Timer.h"
"src/systems/BroadPhaseSystem.h"
"src/components/Components.h"
"src/components/BodyComponents.h"
"src/components/CollisionBodyComponents.h"
"src/components/TransformComponents.h"
"src/components/ProxyShapeComponents.h"
"src/components/DynamicsComponents.h"
@ -232,7 +232,7 @@ SET (REACTPHYSICS3D_SOURCES
"src/engine/EntityManager.cpp"
"src/systems/BroadPhaseSystem.cpp"
"src/components/Components.cpp"
"src/components/BodyComponents.cpp"
"src/components/CollisionBodyComponents.cpp"
"src/components/TransformComponents.cpp"
"src/components/ProxyShapeComponents.cpp"
"src/components/DynamicsComponents.cpp"

View File

@ -24,7 +24,7 @@
********************************************************************************/
// Libraries
#include "BodyComponents.h"
#include "CollisionBodyComponents.h"
#include "engine/EntityManager.h"
#include <cassert>
#include <random>
@ -33,7 +33,7 @@
using namespace reactphysics3d;
// Constructor
BodyComponents::BodyComponents(MemoryAllocator& allocator)
CollisionBodyComponents::CollisionBodyComponents(MemoryAllocator& allocator)
:Components(allocator, sizeof(Entity) + sizeof(CollisionBody*) + sizeof(List<Entity>) +
sizeof(bool) + sizeof(bool) + sizeof(bool) + sizeof(decimal) +
sizeof(void*)) {
@ -43,7 +43,7 @@ BodyComponents::BodyComponents(MemoryAllocator& allocator)
}
// Allocate memory for a given number of components
void BodyComponents::allocate(uint32 nbComponentsToAllocate) {
void CollisionBodyComponents::allocate(uint32 nbComponentsToAllocate) {
assert(nbComponentsToAllocate > mNbAllocatedComponents);
@ -94,7 +94,7 @@ void BodyComponents::allocate(uint32 nbComponentsToAllocate) {
}
// Add a component
void BodyComponents::addComponent(Entity bodyEntity, bool isSleeping, const BodyComponent& component) {
void CollisionBodyComponents::addComponent(Entity bodyEntity, bool isSleeping, const BodyComponent& component) {
// Prepare to add new component (allocate memory if necessary and compute insertion index)
uint32 index = prepareAddComponent(isSleeping);
@ -120,7 +120,7 @@ void BodyComponents::addComponent(Entity bodyEntity, bool isSleeping, const Body
// Move a component from a source to a destination index in the components array
// The destination location must contain a constructed object
void BodyComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) {
void CollisionBodyComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) {
const Entity entity = mBodiesEntities[srcIndex];
@ -146,7 +146,7 @@ void BodyComponents::moveComponentToIndex(uint32 srcIndex, uint32 destIndex) {
}
// Swap two components in the array
void BodyComponents::swapComponents(uint32 index1, uint32 index2) {
void CollisionBodyComponents::swapComponents(uint32 index1, uint32 index2) {
// Copy component 1 data
Entity entity1(mBodiesEntities[index1]);
@ -181,7 +181,7 @@ void BodyComponents::swapComponents(uint32 index1, uint32 index2) {
}
// Destroy a component at a given index
void BodyComponents::destroyComponent(uint32 index) {
void CollisionBodyComponents::destroyComponent(uint32 index) {
Components::destroyComponent(index);

View File

@ -40,12 +40,12 @@ class MemoryAllocator;
class EntityManager;
class CollisionBody;
// Class BodyComponents
// Class CollisionBodyComponents
/**
* This class represent the component of the ECS that contains data about a physics body.
* This class represent the component of the ECS that contains data about a collision body.
* The components of the sleeping entities (bodies) are always stored at the end of the array.
*/
class BodyComponents : public Components {
class CollisionBodyComponents : public Components {
private:
@ -105,10 +105,10 @@ class BodyComponents : public Components {
// -------------------- Methods -------------------- //
/// Constructor
BodyComponents(MemoryAllocator& allocator);
CollisionBodyComponents(MemoryAllocator& allocator);
/// Destructor
virtual ~BodyComponents() override = default;
virtual ~CollisionBodyComponents() override = default;
/// Add a component
void addComponent(Entity bodyEntity, bool isSleeping, const BodyComponent& component);
@ -157,7 +157,7 @@ class BodyComponents : public Components {
};
// Add a proxy-shape to a body component
inline void BodyComponents::addProxyShapeToBody(Entity bodyEntity, Entity proxyShapeEntity) {
inline void CollisionBodyComponents::addProxyShapeToBody(Entity bodyEntity, Entity proxyShapeEntity) {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -165,7 +165,7 @@ inline void BodyComponents::addProxyShapeToBody(Entity bodyEntity, Entity proxyS
}
// Set the transform of an entity
inline void BodyComponents::removeProxyShapeFromBody(Entity bodyEntity, Entity proxyShapeEntity) {
inline void CollisionBodyComponents::removeProxyShapeFromBody(Entity bodyEntity, Entity proxyShapeEntity) {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -173,7 +173,7 @@ inline void BodyComponents::removeProxyShapeFromBody(Entity bodyEntity, Entity p
}
// Return a pointer to a body
inline CollisionBody *BodyComponents::getBody(Entity bodyEntity) {
inline CollisionBody *CollisionBodyComponents::getBody(Entity bodyEntity) {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -181,7 +181,7 @@ inline CollisionBody *BodyComponents::getBody(Entity bodyEntity) {
}
// Return the list of proxy-shapes of a body
inline const List<Entity>& BodyComponents::getProxyShapes(Entity bodyEntity) const {
inline const List<Entity>& CollisionBodyComponents::getProxyShapes(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -189,7 +189,7 @@ inline const List<Entity>& BodyComponents::getProxyShapes(Entity bodyEntity) con
}
// Return true if the body is allowed to sleep
inline bool BodyComponents::getIsAllowedToSleep(Entity bodyEntity) const {
inline bool CollisionBodyComponents::getIsAllowedToSleep(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -197,7 +197,7 @@ inline bool BodyComponents::getIsAllowedToSleep(Entity bodyEntity) const {
}
// Set the value to know if the body is allowed to sleep
inline void BodyComponents::setIsAllowedToSleep(Entity bodyEntity, bool isAllowedToSleep) const {
inline void CollisionBodyComponents::setIsAllowedToSleep(Entity bodyEntity, bool isAllowedToSleep) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -205,7 +205,7 @@ inline void BodyComponents::setIsAllowedToSleep(Entity bodyEntity, bool isAllowe
}
// Return true if the body is active
inline bool BodyComponents::getIsActive(Entity bodyEntity) const {
inline bool CollisionBodyComponents::getIsActive(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -213,7 +213,7 @@ inline bool BodyComponents::getIsActive(Entity bodyEntity) const {
}
// Set the value to know if the body is active
inline void BodyComponents::setIsActive(Entity bodyEntity, bool isActive) const {
inline void CollisionBodyComponents::setIsActive(Entity bodyEntity, bool isActive) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -221,7 +221,7 @@ inline void BodyComponents::setIsActive(Entity bodyEntity, bool isActive) const
}
// Return true if the body is sleeping
inline bool BodyComponents::getIsSleeping(Entity bodyEntity) const {
inline bool CollisionBodyComponents::getIsSleeping(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -229,7 +229,7 @@ inline bool BodyComponents::getIsSleeping(Entity bodyEntity) const {
}
// Set the value to know if the body is sleeping
inline void BodyComponents::setIsSleeping(Entity bodyEntity, bool isSleeping) const {
inline void CollisionBodyComponents::setIsSleeping(Entity bodyEntity, bool isSleeping) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -237,7 +237,7 @@ inline void BodyComponents::setIsSleeping(Entity bodyEntity, bool isSleeping) co
}
// Return the sleep time
inline decimal BodyComponents::getSleepTime(Entity bodyEntity) const {
inline decimal CollisionBodyComponents::getSleepTime(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -245,7 +245,7 @@ inline decimal BodyComponents::getSleepTime(Entity bodyEntity) const {
}
// Set the sleep time
inline void BodyComponents::setSleepTime(Entity bodyEntity, decimal sleepTime) const {
inline void CollisionBodyComponents::setSleepTime(Entity bodyEntity, decimal sleepTime) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -253,7 +253,7 @@ inline void BodyComponents::setSleepTime(Entity bodyEntity, decimal sleepTime) c
}
// Return the user data associated with the body
inline void* BodyComponents::getUserData(Entity bodyEntity) const {
inline void* CollisionBodyComponents::getUserData(Entity bodyEntity) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));
@ -261,7 +261,7 @@ inline void* BodyComponents::getUserData(Entity bodyEntity) const {
}
// Set the user data associated with the body
inline void BodyComponents::setUserData(Entity bodyEntity, void* userData) const {
inline void CollisionBodyComponents::setUserData(Entity bodyEntity, void* userData) const {
assert(mMapEntityToComponentIndex.containsKey(bodyEntity));

View File

@ -157,7 +157,7 @@ CollisionBody* CollisionWorld::createCollisionBody(const Transform& transform) {
assert(collisionBody != nullptr);
// Add the components
BodyComponents::BodyComponent bodyComponent(collisionBody);
CollisionBodyComponents::BodyComponent bodyComponent(collisionBody);
mBodyComponents.addComponent(entity, false, bodyComponent);
// Add the collision body to the world

View File

@ -33,7 +33,7 @@
#include "constraint/Joint.h"
#include "memory/MemoryManager.h"
#include "engine/EntityManager.h"
#include "components/BodyComponents.h"
#include "components/CollisionBodyComponents.h"
#include "components/TransformComponents.h"
#include "components/ProxyShapeComponents.h"
#include "components/DynamicsComponents.h"
@ -77,7 +77,7 @@ class CollisionWorld {
EntityManager mEntityManager;
/// Body Components
BodyComponents mBodyComponents;
CollisionBodyComponents mBodyComponents;
/// Transform Components
TransformComponents mTransformComponents;

View File

@ -30,7 +30,7 @@
#include "constraint/ContactPoint.h"
#include "utils/Profiler.h"
#include "engine/Island.h"
#include "components/BodyComponents.h"
#include "components/CollisionBodyComponents.h"
#include "components/DynamicsComponents.h"
#include "components/ProxyShapeComponents.h"
#include "collision/ContactManifold.h"
@ -44,7 +44,7 @@ const decimal ContactSolver::BETA_SPLIT_IMPULSE = decimal(0.2);
const decimal ContactSolver::SLOP = decimal(0.01);
// Constructor
ContactSolver::ContactSolver(MemoryManager& memoryManager, Islands& islands, BodyComponents& bodyComponents, DynamicsComponents& dynamicsComponents,
ContactSolver::ContactSolver(MemoryManager& memoryManager, Islands& islands, CollisionBodyComponents& bodyComponents, DynamicsComponents& dynamicsComponents,
ProxyShapeComponents& proxyShapeComponents, const WorldSettings& worldSettings)
:mMemoryManager(memoryManager), mContactConstraints(nullptr), mContactPoints(nullptr),
mIslands(islands), mAllContactManifolds(nullptr), mAllContactPoints(nullptr), mBodyComponents(bodyComponents),

View File

@ -43,7 +43,7 @@ class MemoryManager;
class Profiler;
class Island;
class RigidBody;
class BodyComponents;
class CollisionBodyComponents;
class DynamicsComponents;
class ProxyShapeComponents;
@ -310,7 +310,7 @@ class ContactSolver {
List<ContactPoint>* mAllContactPoints;
/// Reference to the body components
BodyComponents& mBodyComponents;
CollisionBodyComponents& mBodyComponents;
/// Reference to the dynamics components
DynamicsComponents& mDynamicsComponents;
@ -359,7 +359,7 @@ class ContactSolver {
// -------------------- Methods -------------------- //
/// Constructor
ContactSolver(MemoryManager& memoryManager, Islands& islands, BodyComponents& bodyComponents,
ContactSolver(MemoryManager& memoryManager, Islands& islands, CollisionBodyComponents& bodyComponents,
DynamicsComponents& dynamicsComponents, ProxyShapeComponents& proxyShapeComponents,
const WorldSettings& worldSettings);

View File

@ -384,7 +384,7 @@ RigidBody* DynamicsWorld::createRigidBody(const Transform& transform) {
sizeof(RigidBody))) RigidBody(transform, *this, entity);
assert(rigidBody != nullptr);
BodyComponents::BodyComponent bodyComponent(rigidBody);
CollisionBodyComponents::BodyComponent bodyComponent(rigidBody);
mBodyComponents.addComponent(entity, false, bodyComponent);
// Add the rigid body to the physics world