Showing the changes to libraries/entities/src/EntityCollisionSystem.cpp (1 of 10 files). Show all
Unified · Split
| @@ -13,8 +13,10 @@ · 12 unmodified lines | |||
| 13 | #include <AbstractAudioInterface.h> | 13 | #include <AbstractAudioInterface.h> |
| 14 | #include <VoxelTree.h> | 14 | #include <VoxelTree.h> |
| 15 | #include <AvatarData.h> | 15 | #include <AvatarData.h> |
| 16 | #include <CollisionInfo.h> | ||
| 16 | #include <HeadData.h> | 17 | #include <HeadData.h> |
| 17 | #include <HandData.h> | 18 | #include <HandData.h> |
| 19 | #include <SphereShape.h> | ||
| 18 | 20 | ||
| 19 | #include "EntityItem.h" | 21 | #include "EntityItem.h" |
| 20 | #include "EntityCollisionSystem.h" | 22 | #include "EntityCollisionSystem.h" |
| @@ -106,8 +108,26 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) { · 85 unmodified lines | |||
| 106 | glm::vec3 center = entityA->getPosition() * (float)(TREE_SCALE); | 108 | glm::vec3 center = entityA->getPosition() * (float)(TREE_SCALE); |
| 107 | float radius = entityA->getRadius() * (float)(TREE_SCALE); | 109 | float radius = entityA->getRadius() * (float)(TREE_SCALE); |
| 108 | glm::vec3 penetration; | 110 | glm::vec3 penetration; |
| 109 | EntityItem* entityB; | 111 | EntityItem* entityB = NULL; |
| 110 | if (_entities->findSpherePenetration(center, radius, penetration, (void**)&entityB, Octree::NoLock)) { | 112 | |
| 113 | const float MAX_COLLISIONS_PER_ENTITY = 32; | ||
| 114 | CollisionList collisions(MAX_COLLISIONS_PER_ENTITY); | ||
| 115 | bool shapeCollisionsAccurate = false; | ||
| 116 | bool shapeCollisions = _entities->findShapeCollisions(&entityA->getCollisionShapeInMeters(), | ||
| 117 | collisions, Octree::NoLock, &shapeCollisionsAccurate); | ||
| 118 | |||
| 119 | if (shapeCollisions) { | ||
| 120 | for(int i = 0; i < collisions.size(); i++) { | ||
| 121 | CollisionInfo* collision = collisions[i]; | ||
| 122 | penetration = collision->_penetration; | ||
| 123 | entityB = static_cast<EntityItem*>(collision->_extraData); | ||
| 124 | |||
| 125 | // TODO: how to handle multiple collisions? | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | if (shapeCollisions) { | ||
| 111 | // NOTE: 'penetration' is the depth that 'entityA' overlaps 'entityB'. It points from A into B. | 131 | // NOTE: 'penetration' is the depth that 'entityA' overlaps 'entityB'. It points from A into B. |
| 112 | glm::vec3 penetrationInTreeUnits = penetration / (float)(TREE_SCALE); | 132 | glm::vec3 penetrationInTreeUnits = penetration / (float)(TREE_SCALE); |
| 113 | 133 | ||