Small modifs in ECS

This commit is contained in:
Daniel Chappuis 2019-01-18 17:46:19 +01:00
parent c5c7e81260
commit 827b14f1b0
4 changed files with 6 additions and 28 deletions

View File

@ -278,7 +278,6 @@ void ContactManifoldSet::clearObsoleteManifoldsAndContactPoints() {
} }
} }
// Remove some contact manifolds and contact points if there are too many of them // Remove some contact manifolds and contact points if there are too many of them
void ContactManifoldSet::reduce() { void ContactManifoldSet::reduce() {

View File

@ -148,8 +148,7 @@ void BroadPhaseAlgorithm::computeOverlappingPairs(MemoryManager& memoryManager)
LinkedList<int> overlappingNodes(memoryManager.getPoolAllocator()); LinkedList<int> overlappingNodes(memoryManager.getPoolAllocator());
// For all collision shapes that have moved (or have been created) during the // For all collision shapes that have moved (or have been created) during the last simulation step
// last simulation step
for (auto it = mMovedShapes.begin(); it != mMovedShapes.end(); ++it) { for (auto it = mMovedShapes.begin(); it != mMovedShapes.end(); ++it) {
int shapeID = *it; int shapeID = *it;
@ -224,7 +223,7 @@ void BroadPhaseAlgorithm::addOverlappingNodes(int referenceNodeId, const LinkedL
LinkedList<int>::ListElement* elem = overlappingNodes.getListHead(); LinkedList<int>::ListElement* elem = overlappingNodes.getListHead();
while (elem != nullptr) { while (elem != nullptr) {
// If both the nodes are the same, we do not create store the overlapping pair // If both the nodes are the same, we do not create the overlapping pair
if (referenceNodeId != elem->data) { if (referenceNodeId != elem->data) {
// Add the new potential pair into the array of potential overlapping pairs // Add the new potential pair into the array of potential overlapping pairs

View File

@ -35,8 +35,8 @@ using namespace reactphysics3d;
// Constructor // Constructor
ProxyShapesComponents::ProxyShapesComponents(MemoryAllocator& allocator) ProxyShapesComponents::ProxyShapesComponents(MemoryAllocator& allocator)
:mMemoryAllocator(allocator), mNbComponents(0), mNbAllocatedComponents(0), :Components(allocator),
mSleepingStartIndex(0), mBuffer(nullptr), mMapEntityToComponentIndex(allocator), mSleepingStartIndex(0),
mMapProxyShapeToComponentIndex(allocator) { mMapProxyShapeToComponentIndex(allocator) {
// Allocate memory for the components data // Allocate memory for the components data

View File

@ -31,6 +31,7 @@
#include "engine/Entity.h" #include "engine/Entity.h"
#include "containers/Map.h" #include "containers/Map.h"
#include "collision/shapes/AABB.h" #include "collision/shapes/AABB.h"
#include "components/Components.h"
// ReactPhysics3D namespace // ReactPhysics3D namespace
namespace reactphysics3d { namespace reactphysics3d {
@ -50,42 +51,21 @@ class ProxyShape;
* link information to quickly know all the proxy shapes of a given entity (body). We also make * link information to quickly know all the proxy shapes of a given entity (body). We also make
* sure that proxy shapes of sleeping entities (bodies) are always stored at the end of the array. * sure that proxy shapes of sleeping entities (bodies) are always stored at the end of the array.
*/ */
class ProxyShapesComponents { class ProxyShapesComponents : public Components {
private: private:
// -------------------- Constants -------------------- // // -------------------- Constants -------------------- //
/// Number of components to allocated at the beginning
const uint32 INIT_ALLOCATED_COMPONENTS = 10;
/// Number of valid entities to hit before stopping garbage collection
const uint32 GARBAGE_COLLECTION_MAX_VALID_ENTITIES = 5;
const size_t COMPONENT_DATA_SIZE = sizeof(Entity) + sizeof(ProxyShape*) + sizeof(int) + sizeof(AABB) + const size_t COMPONENT_DATA_SIZE = sizeof(Entity) + sizeof(ProxyShape*) + sizeof(int) + sizeof(AABB) +
sizeof(Transform) + sizeof(CollisionShape*) + sizeof(decimal) + sizeof(uint32) + sizeof(Transform) + sizeof(CollisionShape*) + sizeof(decimal) + sizeof(uint32) +
sizeof(uint32) + sizeof(unsigned short) + sizeof(unsigned short); sizeof(uint32) + sizeof(unsigned short) + sizeof(unsigned short);
// -------------------- Attributes -------------------- // // -------------------- Attributes -------------------- //
/// Memory allocator
MemoryAllocator& mMemoryAllocator;
/// Current number of components
uint32 mNbComponents;
/// Number of allocated components
uint32 mNbAllocatedComponents;
/// Index of the first component of a sleeping entity (sleeping components are stored at the end) /// Index of the first component of a sleeping entity (sleeping components are stored at the end)
uint32 mSleepingStartIndex; uint32 mSleepingStartIndex;
/// Allocated memory for all the data of the components
void* mBuffer;
/// Map an entity to the index of its component in the array
Map<Entity, uint32> mMapEntityToComponentIndex;
/// Map a proxy shape to the index of the corresponding component in the array /// Map a proxy shape to the index of the corresponding component in the array
Map<const ProxyShape*, uint32> mMapProxyShapeToComponentIndex; Map<const ProxyShape*, uint32> mMapProxyShapeToComponentIndex;