mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
make sphere entities use sphere shape for better collisions
This commit is contained in:
parent
9cd76983a2
commit
2f0a9b517f
3 changed files with 16 additions and 4 deletions
|
@ -105,14 +105,13 @@ void EntityCollisionSystem::updateCollisionWithVoxels(EntityItem* entity) {
|
|||
}
|
||||
|
||||
void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
|
||||
glm::vec3 center = entityA->getPosition() * (float)(TREE_SCALE);
|
||||
float radius = entityA->getRadius() * (float)(TREE_SCALE);
|
||||
glm::vec3 penetration;
|
||||
EntityItem* entityB = NULL;
|
||||
|
||||
const float MAX_COLLISIONS_PER_ENTITY = 32;
|
||||
CollisionList collisions(MAX_COLLISIONS_PER_ENTITY);
|
||||
bool shapeCollisionsAccurate = false;
|
||||
|
||||
bool shapeCollisions = _entities->findShapeCollisions(&entityA->getCollisionShapeInMeters(),
|
||||
collisions, Octree::NoLock, &shapeCollisionsAccurate);
|
||||
|
||||
|
|
|
@ -88,4 +88,11 @@ void SphereEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBi
|
|||
|
||||
bool successPropertyFits = true;
|
||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor());
|
||||
}
|
||||
}
|
||||
|
||||
void SphereEntityItem::recalculateCollisionShape() {
|
||||
_sphereShape.setTranslation(getCenterInMeters());
|
||||
glm::vec3 dimensionsInMeters = getDimensionsInMeters();
|
||||
float largestDiameter = glm::max(dimensionsInMeters.x, dimensionsInMeters.y, dimensionsInMeters.z);
|
||||
_sphereShape.setRadius(largestDiameter / 2.0f);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#ifndef hifi_SphereEntityItem_h
|
||||
#define hifi_SphereEntityItem_h
|
||||
|
||||
#include "EntityItem.h"
|
||||
#include <SphereShape.h>
|
||||
#include "EntityItem.h"
|
||||
|
||||
class SphereEntityItem : public EntityItem {
|
||||
public:
|
||||
|
@ -49,9 +50,14 @@ public:
|
|||
_color[GREEN_INDEX] = value.green;
|
||||
_color[BLUE_INDEX] = value.blue;
|
||||
}
|
||||
|
||||
virtual const Shape& getCollisionShapeInMeters() const { return _sphereShape; }
|
||||
|
||||
protected:
|
||||
virtual void recalculateCollisionShape();
|
||||
|
||||
rgbColor _color;
|
||||
SphereShape _sphereShape;
|
||||
};
|
||||
|
||||
#endif // hifi_SphereEntityItem_h
|
||||
|
|
Loading…
Reference in a new issue