Skip to content

Commit

Permalink
Improved sensor collider validation.
Browse files Browse the repository at this point in the history
Some lore triggers in the original map data have empty text fields, meaning the player can activate them, but they show nothing on-screen. These shouldn't influence voxel colliders like the key platform in the starter dungeon.
  • Loading branch information
afritz1 committed Jan 10, 2025
1 parent ef1d050 commit 63b3332
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions OpenTESArena/src/Collision/CollisionChunkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ void CollisionChunkManager::populateChunk(int index, double ceilingScale, const
const bool voxelHasCollision = voxelTraitsDef.hasCollision();
collisionChunk.enabledColliders.set(x, y, z, voxelHasCollision);

bool isTriggerVoxel = false;
VoxelTriggerDefID triggerDefID;
const bool isTriggerVoxel = voxelChunk.tryGetTriggerDefID(x, y, z, &triggerDefID);
if (voxelChunk.tryGetTriggerDefID(x, y, z, &triggerDefID))
{
const VoxelTriggerDefinition &voxelTriggerDef = voxelChunk.getTriggerDef(triggerDefID);
isTriggerVoxel = voxelTriggerDef.hasValidDef();
}

bool isInteriorLevelChangeVoxel = false;
VoxelTransitionDefID transitionDefID;
Expand Down Expand Up @@ -170,8 +175,13 @@ void CollisionChunkManager::updateDirtyVoxels(const ChunkInt2 &chunkPos, double
collisionChunk.physicsBodyIDs.set(x, y, z, Physics::INVALID_BODY_ID);
}

bool isTriggerVoxel = false;
VoxelTriggerDefID triggerDefID;
const bool isTriggerVoxel = voxelChunk.tryGetTriggerDefID(x, y, z, &triggerDefID);
if (voxelChunk.tryGetTriggerDefID(x, y, z, &triggerDefID))
{
const VoxelTriggerDefinition &voxelTriggerDef = voxelChunk.getTriggerDef(triggerDefID);
isTriggerVoxel = voxelTriggerDef.hasValidDef();
}

bool isInteriorLevelChangeVoxel = false;
VoxelTransitionDefID transitionDefID;
Expand Down
5 changes: 5 additions & 0 deletions OpenTESArena/src/Voxels/VoxelTriggerDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ bool VoxelTriggerDefinition::hasTextDef() const
{
return !this->text.text.empty();
}

bool VoxelTriggerDefinition::hasValidDef() const
{
return this->hasSoundDef() || this->hasTextDef();
}
1 change: 1 addition & 0 deletions OpenTESArena/src/Voxels/VoxelTriggerDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct VoxelTriggerDefinition

bool hasSoundDef() const;
bool hasTextDef() const;
bool hasValidDef() const;
};

#endif

0 comments on commit 63b3332

Please sign in to comment.