mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 16:55:07 +02:00
Reimplements "contains" for sphere and particles
This commit is contained in:
parent
dbf40afa47
commit
8db9f80779
4 changed files with 19 additions and 2 deletions
|
@ -236,6 +236,14 @@ void ParticleEffectEntityItem::appendSubclassData(OctreePacketData* packetData,
|
|||
APPEND_ENTITY_PROPERTY(PROP_PARTICLE_RADIUS, appendValue, getParticleRadius());
|
||||
}
|
||||
|
||||
bool ParticleEffectEntityItem::contains(const glm::vec3& point) const {
|
||||
// Transform point to be in a space where the elipsoide is a perfect sphere centered on the origin.
|
||||
glm::vec3 transformedPoint = (point - getPosition()) / (getDimensions() / 2.0f);
|
||||
|
||||
// Return whether said point is inside the sphere.
|
||||
return glm::length(transformedPoint) <= 1.0f;
|
||||
}
|
||||
|
||||
bool ParticleEffectEntityItem::isAnimatingSomething() const {
|
||||
return getAnimationIsPlaying() &&
|
||||
getAnimationFPS() != 0.0f;
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
_color[GREEN_INDEX] = value.green;
|
||||
_color[BLUE_INDEX] = value.blue;
|
||||
}
|
||||
|
||||
virtual bool contains(const glm::vec3& point) const;
|
||||
|
||||
void updateShapeType(ShapeType type);
|
||||
virtual ShapeType getShapeType() const { return _shapeType; }
|
||||
|
|
|
@ -92,6 +92,14 @@ void SphereEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBi
|
|||
APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor());
|
||||
}
|
||||
|
||||
bool SphereEntityItem::contains(const glm::vec3& point) const {
|
||||
// Transform point to be in a space where the elipsoide is a perfect sphere centered on the origin.
|
||||
glm::vec3 transformedPoint = (point - getPosition()) / (getDimensions() / 2.0f);
|
||||
|
||||
// Return whether said point is inside the sphere.
|
||||
return glm::length(transformedPoint) <= 1.0f;
|
||||
}
|
||||
|
||||
bool SphereEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
|
||||
void** intersectedObject, bool precisionPicking) const {
|
||||
|
|
|
@ -50,8 +50,7 @@ public:
|
|||
_color[BLUE_INDEX] = value.blue;
|
||||
}
|
||||
|
||||
// TODO: implement proper contains for 3D ellipsoid
|
||||
//virtual bool contains(const glm::vec3& point) const;
|
||||
virtual bool contains(const glm::vec3& point) const;
|
||||
|
||||
virtual ShapeType getShapeType() const { return SHAPE_TYPE_SPHERE; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue