mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 00:24:13 +02:00
support for spherical entities
This commit is contained in:
parent
fb7a5e64cf
commit
85e7c6166b
7 changed files with 23 additions and 14 deletions
libraries
|
@ -96,16 +96,8 @@ void BoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
|
|||
APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor());
|
||||
}
|
||||
|
||||
/*
|
||||
#ifdef USE_BULLET_PHYSICS
|
||||
EntityMotionState* BoxEntityItem::createMotionState() {
|
||||
if (!_motionState) {
|
||||
_motionState = new EntityMotionState(this);
|
||||
glm::vec3 extents = getDimensionsInMeters();
|
||||
_motionState->setVolume(extents.x * extents.y * extents.z);
|
||||
}
|
||||
return _motionState;
|
||||
void BoxEntityItem::computeShapeInfo(ShapeInfo& info) const {
|
||||
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
|
||||
info.setBox(halfExtents);
|
||||
}
|
||||
#endif // USE_BULLET_PHYSICS
|
||||
*/
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
_color[GREEN_INDEX] = value.green;
|
||||
_color[BLUE_INDEX] = value.blue;
|
||||
}
|
||||
|
||||
void computeShapeInfo(ShapeInfo& info) const;
|
||||
|
||||
protected:
|
||||
rgbColor _color;
|
||||
|
|
|
@ -946,6 +946,10 @@ float EntityItem::getRadius() const {
|
|||
return radius;
|
||||
}
|
||||
|
||||
void EntityItem::computeShapeInfo(ShapeInfo& info) const {
|
||||
info.clear();
|
||||
}
|
||||
|
||||
void EntityItem::recalculateCollisionShape() {
|
||||
AACube entityAACube = getMinimumAACube();
|
||||
entityAACube.scale(TREE_SCALE); // scale to meters
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <Octree.h> // for EncodeBitstreamParams class
|
||||
#include <OctreeElement.h> // for OctreeElement::AppendState
|
||||
#include <OctreePacketData.h>
|
||||
#include <ShapeInfo.h>
|
||||
#include <VoxelDetail.h>
|
||||
|
||||
#include "EntityItemID.h"
|
||||
|
@ -279,6 +280,7 @@ public:
|
|||
void applyHardCollision(const CollisionInfo& collisionInfo);
|
||||
virtual const Shape& getCollisionShapeInMeters() const { return _collisionShape; }
|
||||
virtual bool contains(const glm::vec3& point) const { return getAABox().contains(point); }
|
||||
virtual void computeShapeInfo(ShapeInfo& info) const;
|
||||
|
||||
// updateFoo() methods to be used when changes need to be accumulated in the _updateFlags
|
||||
void updatePosition(const glm::vec3& value);
|
||||
|
@ -348,6 +350,9 @@ protected:
|
|||
void setRadius(float value);
|
||||
|
||||
AACubeShape _collisionShape;
|
||||
|
||||
// _physicsInfo is a hook reserved for use by the EntitySimulation, which is guaranteed to set _physicsInfo
|
||||
// to a non-NULL value when the EntityItem has a representation in the physics engine.
|
||||
void* _physicsInfo; // only set by EntitySimulation
|
||||
SimulationState _simulationState; // only set by EntitySimulation
|
||||
|
||||
|
|
|
@ -93,3 +93,9 @@ void SphereEntityItem::recalculateCollisionShape() {
|
|||
float largestDiameter = glm::max(dimensionsInMeters.x, dimensionsInMeters.y, dimensionsInMeters.z);
|
||||
_sphereShape.setRadius(largestDiameter / 2.0f);
|
||||
}
|
||||
|
||||
void SphereEntityItem::computeShapeInfo(ShapeInfo& info) const {
|
||||
glm::vec3 halfExtents = 0.5f * getDimensionsInMeters();
|
||||
// TODO: support ellipsoid shapes
|
||||
info.setSphere(halfExtents.x);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
|
||||
// TODO: implement proper contains for 3D ellipsoid
|
||||
//virtual bool contains(const glm::vec3& point) const;
|
||||
|
||||
void computeShapeInfo(ShapeInfo& info) const;
|
||||
|
||||
protected:
|
||||
virtual void recalculateCollisionShape();
|
||||
|
|
|
@ -107,9 +107,7 @@ void EntityMotionState::applyGravity() const {
|
|||
}
|
||||
|
||||
void EntityMotionState::computeShapeInfo(ShapeInfo& info) {
|
||||
// HACK: for now we make everything a box.
|
||||
glm::vec3 halfExtents = 0.5f * _entity->getDimensionsInMeters();
|
||||
info.setBox(halfExtents);
|
||||
_entity->computeShapeInfo(info);
|
||||
}
|
||||
|
||||
void EntityMotionState::getBoundingCubes(AACube& oldCube, AACube& newCube) {
|
||||
|
|
Loading…
Reference in a new issue