Skip to content

Commit 101a96e

Browse files
simplify non-pickable entity logic
1 parent 8899967 commit 101a96e

File tree

8 files changed

+16
-49
lines changed

8 files changed

+16
-49
lines changed

libraries/entities/src/EntityTreeElement.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ EntityItemID EntityTreeElement::evalDetailedRayIntersection(const glm::vec3& ori
197197
// only called if we do intersect our bounding cube, but find if we actually intersect with entities...
198198
EntityItemID entityID;
199199
forEachEntity([&](EntityItemPointer entity) {
200+
EntityTypes::EntityType type = entity->getType();
201+
if (type == EntityTypes::ParticleEffect || type == EntityTypes::ProceduralParticleEffect || type == EntityTypes::Line ||
202+
type == EntityTypes::PolyLine || type == EntityTypes::Sound || type == EntityTypes::Script || type == EntityTypes::Empty ||
203+
(type == EntityTypes::Material && !entity->getParentID().isNull())) {
204+
return;
205+
}
206+
200207
if (entity->getIgnorePickIntersection() && !searchFilter.bypassIgnore()) {
201208
return;
202209
}
@@ -257,9 +264,7 @@ EntityItemID EntityTreeElement::evalDetailedRayIntersection(const glm::vec3& ori
257264
}
258265
} else {
259266
// if the entity type doesn't support a detailed intersection, then just return the non-AABox results
260-
// Never intersect with particle or sound entities
261-
if (localDistance < distance && (entity->getType() != EntityTypes::ParticleEffect && entity->getType() != EntityTypes::ProceduralParticleEffect &&
262-
entity->getType() != EntityTypes::Sound && entity->getType() != EntityTypes::Script)) {
267+
if (localDistance < distance) {
263268
distance = localDistance;
264269
face = localFace;
265270
surfaceNormal = glm::vec3(rotation * glm::vec4(localSurfaceNormal, 0.0f));
@@ -344,6 +349,13 @@ EntityItemID EntityTreeElement::evalDetailedParabolaIntersection(const glm::vec3
344349
// only called if we do intersect our bounding cube, but find if we actually intersect with entities...
345350
EntityItemID entityID;
346351
forEachEntity([&](EntityItemPointer entity) {
352+
EntityTypes::EntityType type = entity->getType();
353+
if (type == EntityTypes::ParticleEffect || type == EntityTypes::ProceduralParticleEffect || type == EntityTypes::Line ||
354+
type == EntityTypes::PolyLine || type == EntityTypes::Sound || type == EntityTypes::Script ||
355+
type == EntityTypes::Empty || (type == EntityTypes::Material && !entity->getParentID().isNull())) {
356+
return;
357+
}
358+
347359
if (entity->getIgnorePickIntersection() && !searchFilter.bypassIgnore()) {
348360
return;
349361
}
@@ -410,9 +422,7 @@ EntityItemID EntityTreeElement::evalDetailedParabolaIntersection(const glm::vec3
410422
}
411423
} else {
412424
// if the entity type doesn't support a detailed intersection, then just return the non-AABox results
413-
// Never intersect with particle or sound entities
414-
if (localDistance < parabolicDistance && (entity->getType() != EntityTypes::ParticleEffect && entity->getType() != EntityTypes::ProceduralParticleEffect &&
415-
entity->getType() != EntityTypes::Sound && entity->getType() != EntityTypes::Script)) {
425+
if (localDistance < parabolicDistance) {
416426
parabolicDistance = localDistance;
417427
face = localFace;
418428
surfaceNormal = glm::vec3(rotation * glm::vec4(localSurfaceNormal, 0.0f));

libraries/entities/src/LineEntityItem.h.in

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@ class LineEntityItem : public EntityItem {
2525

2626
bool appendPoint(const glm::vec3& point);
2727

28-
// never have a ray intersection pick a LineEntityItem.
29-
virtual bool supportsDetailedIntersection() const override { return true; }
30-
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
31-
const glm::vec3& viewFrustumPos, OctreeElementPointer& element, float& distance,
32-
BoxFace& face, glm::vec3& surfaceNormal,
33-
QVariantMap& extraInfo,
34-
bool precisionPicking) const override { return false; }
35-
virtual bool findDetailedParabolaIntersection(const glm::vec3& origin, const glm::vec3& velocity,
36-
const glm::vec3& acceleration, const glm::vec3& viewFrustumPos, OctreeElementPointer& element,
37-
float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal,
38-
QVariantMap& extraInfo,
39-
bool precisionPicking) const override { return false; }
40-
4128
static const int MAX_POINTS_PER_LINE;
4229

4330
QVector<glm::vec3> getLinePoints() const;

libraries/entities/src/ParticleEffectEntityItem.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ public:
217217

218218
void computeAndUpdateDimensions();
219219

220-
virtual bool supportsDetailedIntersection() const override { return false; }
221-
222220
ShapeType getShapeType() const override;
223221
void setShapeType(ShapeType type) override;
224222

libraries/entities/src/PolyLineEntityItem.h.in

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@ public:
3737
void resetTexturesChanged() { _texturesChanged = false; }
3838
void resetPolyLineChanged() { _colorsChanged = _widthsChanged = _normalsChanged = _pointsChanged = false; }
3939

40-
// never have a ray intersection pick a PolyLineEntityItem.
41-
virtual bool supportsDetailedIntersection() const override { return true; }
42-
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
43-
const glm::vec3& viewFrustumPos, OctreeElementPointer& element, float& distance,
44-
BoxFace& face, glm::vec3& surfaceNormal,
45-
QVariantMap& extraInfo, bool precisionPicking) const override { return false; }
46-
virtual bool findDetailedParabolaIntersection(const glm::vec3& origin, const glm::vec3& velocity,
47-
const glm::vec3& acceleration, const glm::vec3& viewFrustumPos, OctreeElementPointer& element,
48-
float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal,
49-
QVariantMap& extraInfo, bool precisionPicking) const override { return false; }
50-
5140
void computeTightLocalBoundingBox(AABox& box) const;
5241
private:
5342
void computeAndUpdateDimensions();

libraries/entities/src/PolyVoxEntityItem.h.in

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ public:
2323
ALLOW_INSTANTIATION // This class can be instantiated
2424
ENTITY_PROPERTY_SUBCLASS_METHODS
2525

26-
// never have a ray intersection pick a PolyVoxEntityItem.
27-
virtual bool supportsDetailedIntersection() const override { return true; }
28-
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
29-
const glm::vec3& viewFrustumPos, OctreeElementPointer& element, float& distance,
30-
BoxFace& face, glm::vec3& surfaceNormal,
31-
QVariantMap& extraInfo, bool precisionPicking) const override { return false; }
32-
virtual bool findDetailedParabolaIntersection(const glm::vec3& origin, const glm::vec3& velocity,
33-
const glm::vec3& acceleration, const glm::vec3& viewFrustumPos, OctreeElementPointer& element,
34-
float& parabolicDistance, BoxFace& face, glm::vec3& surfaceNormal,
35-
QVariantMap& extraInfo, bool precisionPicking) const override { return false; }
36-
3726
virtual int getOnCount() const { return 0; }
3827

3928
/*@jsdoc

libraries/entities/src/ProceduralParticleEffectEntityItem.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public:
3636

3737
bool shouldBePhysical() const override { return false; }
3838

39-
virtual bool supportsDetailedIntersection() const override { return false; }
40-
4139
protected:
4240

4341
@ProceduralParticleEffect_ENTITY_PROPS@

libraries/entities/src/ScriptEntityItem.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public:
2323

2424
bool shouldBePhysical() const override { return false; }
2525

26-
virtual bool supportsDetailedIntersection() const override { return false; }
27-
2826
AACube calculateInitialQueryAACube(bool& success) override;
2927

3028
virtual void update(const quint64& now) override;

libraries/entities/src/SoundEntityItem.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public:
2626

2727
bool shouldBePhysical() const override { return false; }
2828

29-
virtual bool supportsDetailedIntersection() const override { return false; }
30-
3129
virtual void update(const quint64& now) override;
3230
bool needsToCallUpdate() const override { return _updateNeeded; }
3331

0 commit comments

Comments
 (0)