Skip to content

Commit

Permalink
Renamed some voxel defs for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
afritz1 committed Jan 1, 2025
1 parent a6d331f commit 3fc104d
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 128 deletions.
8 changes: 4 additions & 4 deletions OpenTESArena/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,10 @@ SET(TES_VOXELS
"${SRC_ROOT}/Voxels/ArenaChasmUtils.h"
"${SRC_ROOT}/Voxels/ArenaVoxelUtils.cpp"
"${SRC_ROOT}/Voxels/ArenaVoxelUtils.h"
"${SRC_ROOT}/Voxels/ChasmDefinition.cpp"
"${SRC_ROOT}/Voxels/ChasmDefinition.h"
"${SRC_ROOT}/Voxels/DoorDefinition.cpp"
"${SRC_ROOT}/Voxels/DoorDefinition.h"
"${SRC_ROOT}/Voxels/DoorUtils.cpp"
"${SRC_ROOT}/Voxels/DoorUtils.h"
"${SRC_ROOT}/Voxels/VoxelChasmDefinition.cpp"
"${SRC_ROOT}/Voxels/VoxelChasmDefinition.h"
"${SRC_ROOT}/Voxels/VoxelChasmWallInstance.cpp"
"${SRC_ROOT}/Voxels/VoxelChasmWallInstance.h"
"${SRC_ROOT}/Voxels/VoxelChunk.cpp"
Expand All @@ -575,6 +573,8 @@ SET(TES_VOXELS
"${SRC_ROOT}/Voxels/VoxelDirtyType.h"
"${SRC_ROOT}/Voxels/VoxelDoorAnimationInstance.cpp"
"${SRC_ROOT}/Voxels/VoxelDoorAnimationInstance.h"
"${SRC_ROOT}/Voxels/VoxelDoorDefinition.cpp"
"${SRC_ROOT}/Voxels/VoxelDoorDefinition.h"
"${SRC_ROOT}/Voxels/VoxelDoorVisibilityInstance.cpp"
"${SRC_ROOT}/Voxels/VoxelDoorVisibilityInstance.h"
"${SRC_ROOT}/Voxels/VoxelFacing2D.h"
Expand Down
4 changes: 2 additions & 2 deletions OpenTESArena/src/Player/PlayerLogicController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,8 @@ void PlayerLogicController::handleScreenToWorldInteraction(Game &game, const Int
DebugCrash("Expected door def ID to exist.");
}

const DoorDefinition &doorDef = chunk.getDoorDef(doorDefID);
const DoorDefinition::OpenSoundDef &openSoundDef = doorDef.getOpenSound();
const VoxelDoorDefinition &doorDef = chunk.getDoorDef(doorDefID);
const VoxelDoorDefinition::OpenSoundDef &openSoundDef = doorDef.getOpenSound();

auto &audioManager = game.audioManager;
const std::string &soundFilename = openSoundDef.soundFilename;
Expand Down
34 changes: 17 additions & 17 deletions OpenTESArena/src/Rendering/RenderVoxelChunkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ namespace
}
}

bool LoadedChasmFloorComparer(const RenderVoxelChunkManager::LoadedChasmFloorTextureList &textureList, const ChasmDefinition &chasmDef)
bool LoadedChasmFloorComparer(const RenderVoxelChunkManager::LoadedChasmFloorTextureList &textureList, const VoxelChasmDefinition &chasmDef)
{
if (textureList.animType != chasmDef.animType)
{
return false;
}

if (textureList.animType == ChasmDefinition::AnimationType::SolidColor)
if (textureList.animType == VoxelChasmDefinition::AnimationType::SolidColor)
{
return textureList.paletteIndex == chasmDef.solidColor.paletteIndex;
}
else if (textureList.animType == ChasmDefinition::AnimationType::Animated)
else if (textureList.animType == VoxelChasmDefinition::AnimationType::Animated)
{
const int textureAssetCount = static_cast<int>(textureList.textureAssets.size());
const ChasmDefinition::Animated &chasmDefAnimated = chasmDef.animated;
const VoxelChasmDefinition::Animated &chasmDefAnimated = chasmDef.animated;

if (textureAssetCount != chasmDefAnimated.textureAssets.getCount())
{
Expand Down Expand Up @@ -108,7 +108,7 @@ namespace
TextureManager &textureManager, Renderer &renderer)
{
const ChunkInt2 chunkPos = voxelChunk.getPosition();
const ChasmDefinition &chasmDef = voxelChunk.getChasmDef(chasmDefID);
const VoxelChasmDefinition &chasmDef = voxelChunk.getChasmDef(chasmDefID);

// Check if this chasm already has a mapping (i.e. have we seen this chunk before?).
const auto keyIter = std::find_if(chasmTextureKeys.begin(), chasmTextureKeys.end(),
Expand Down Expand Up @@ -138,7 +138,7 @@ namespace
{
// Load the required textures and add a key for them.
RenderVoxelChunkManager::LoadedChasmFloorTextureList newTextureList;
if (chasmDef.animType == ChasmDefinition::AnimationType::SolidColor)
if (chasmDef.animType == VoxelChasmDefinition::AnimationType::SolidColor)
{
// Dry chasms are a single color, no texture asset.
ObjectTextureID dryChasmTextureID;
Expand Down Expand Up @@ -166,7 +166,7 @@ namespace
newTextureList.initColor(paletteIndex, std::move(dryChasmTextureRef));
chasmFloorTextureLists.emplace_back(std::move(newTextureList));
}
else if (chasmDef.animType == ChasmDefinition::AnimationType::Animated)
else if (chasmDef.animType == VoxelChasmDefinition::AnimationType::Animated)
{
std::vector<TextureAsset> newTextureAssets;
std::vector<ScopedObjectTextureRef> newObjectTextureRefs;
Expand Down Expand Up @@ -289,22 +289,22 @@ void RenderVoxelChunkManager::LoadedTexture::init(const TextureAsset &textureAss

RenderVoxelChunkManager::LoadedChasmFloorTextureList::LoadedChasmFloorTextureList()
{
this->animType = static_cast<ChasmDefinition::AnimationType>(-1);
this->animType = static_cast<VoxelChasmDefinition::AnimationType>(-1);
this->paletteIndex = 0;
}

void RenderVoxelChunkManager::LoadedChasmFloorTextureList::initColor(uint8_t paletteIndex,
ScopedObjectTextureRef &&objectTextureRef)
{
this->animType = ChasmDefinition::AnimationType::SolidColor;
this->animType = VoxelChasmDefinition::AnimationType::SolidColor;
this->paletteIndex = paletteIndex;
this->objectTextureRefs.emplace_back(std::move(objectTextureRef));
}

void RenderVoxelChunkManager::LoadedChasmFloorTextureList::initTextured(std::vector<TextureAsset> &&textureAssets,
std::vector<ScopedObjectTextureRef> &&objectTextureRefs)
{
this->animType = ChasmDefinition::AnimationType::Animated;
this->animType = VoxelChasmDefinition::AnimationType::Animated;
this->textureAssets = std::move(textureAssets);
this->objectTextureRefs = std::move(objectTextureRefs);
}
Expand All @@ -314,11 +314,11 @@ int RenderVoxelChunkManager::LoadedChasmFloorTextureList::getTextureIndex(double
const int textureCount = static_cast<int>(this->objectTextureRefs.size());
DebugAssert(textureCount >= 1);

if (this->animType == ChasmDefinition::AnimationType::SolidColor)
if (this->animType == VoxelChasmDefinition::AnimationType::SolidColor)
{
return 0;
}
else if (this->animType == ChasmDefinition::AnimationType::Animated)
else if (this->animType == VoxelChasmDefinition::AnimationType::Animated)
{
const int index = std::clamp(static_cast<int>(static_cast<double>(textureCount) * chasmAnimPercent), 0, textureCount - 1);
return index;
Expand Down Expand Up @@ -684,7 +684,7 @@ void RenderVoxelChunkManager::loadTransforms(RenderVoxelChunk &renderChunk, cons
if (voxelChunk.tryGetDoorDefID(x, y, z, &doorDefID))
{
// Door transform uniform buffers. These are separate because each voxel has a RenderTransform per door face.
const DoorDefinition &doorDef = voxelChunk.getDoorDef(doorDefID);
const VoxelDoorDefinition &doorDef = voxelChunk.getDoorDef(doorDefID);
const ArenaTypes::DoorType doorType = doorDef.getType();
DebugAssert(renderChunk.doorTransformBuffers.find(voxel) == renderChunk.doorTransformBuffers.end());

Expand Down Expand Up @@ -758,7 +758,7 @@ void RenderVoxelChunkManager::updateChunkDrawCalls(RenderVoxelChunk &renderChunk

VoxelChunk::DoorDefID doorDefID;
const bool isDoor = voxelChunk.tryGetDoorDefID(voxel.x, voxel.y, voxel.z, &doorDefID);
const DoorDefinition *doorDef = isDoor ? &voxelChunk.getDoorDef(doorDefID) : nullptr;
const VoxelDoorDefinition *doorDef = isDoor ? &voxelChunk.getDoorDef(doorDefID) : nullptr;

double doorAnimPercent = 0.0;
if (isDoor)
Expand All @@ -775,15 +775,15 @@ void RenderVoxelChunkManager::updateChunkDrawCalls(RenderVoxelChunk &renderChunk
VoxelChunk::ChasmDefID chasmDefID;
const bool isChasm = voxelChunk.tryGetChasmDefID(voxel.x, voxel.y, voxel.z, &chasmDefID);

const ChasmDefinition *chasmDef = nullptr;
const VoxelChasmDefinition *chasmDef = nullptr;
bool isAnimatingChasm = false;
bool isEmissiveChasm = false;
bool hasChasmWall = false;
IndexBufferID chasmWallIndexBufferID = -1;
if (isChasm)
{
chasmDef = &voxelChunk.getChasmDef(chasmDefID);
isAnimatingChasm = chasmDef->animType == ChasmDefinition::AnimationType::Animated;
isAnimatingChasm = chasmDef->animType == VoxelChasmDefinition::AnimationType::Animated;
isEmissiveChasm = chasmDef->isEmissive;

const auto chasmWallIndexBufferIdIter = renderChunk.chasmWallIndexBufferIDsMap.find(voxel);
Expand Down Expand Up @@ -1374,7 +1374,7 @@ void RenderVoxelChunkManager::update(BufferView<const ChunkInt2> activeChunkPosi
continue;
}

const DoorDefinition &doorDef = voxelChunk.getDoorDef(doorDefID);
const VoxelDoorDefinition &doorDef = voxelChunk.getDoorDef(doorDefID);
const ArenaTypes::DoorType doorType = doorDef.getType();
const WorldDouble3 worldPosition = MakeVoxelWorldPosition(voxelChunk.getPosition(), doorVoxel, ceilingScale);
const double doorAnimPercent = DoorUtils::getAnimPercentOrZero(doorVoxel.x, doorVoxel.y, doorVoxel.z, voxelChunk);
Expand Down
2 changes: 1 addition & 1 deletion OpenTESArena/src/Rendering/RenderVoxelChunkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RenderVoxelChunkManager final : public SpecializedChunkManager<RenderVoxel
// The draw call and pixel shader need two textures in order to support chasm wall rendering.
struct LoadedChasmFloorTextureList
{
ChasmDefinition::AnimationType animType;
VoxelChasmDefinition::AnimationType animType;

uint8_t paletteIndex;
std::vector<TextureAsset> textureAssets;
Expand Down
40 changes: 0 additions & 40 deletions OpenTESArena/src/Voxels/DoorDefinition.cpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
#include <algorithm>

#include "ArenaChasmUtils.h"
#include "ChasmDefinition.h"
#include "VoxelChasmDefinition.h"
#include "../Rendering/ArenaRenderUtils.h"

ChasmDefinition::SolidColor::SolidColor()
VoxelChasmDefinition::SolidColor::SolidColor()
{
this->paletteIndex = 0;
}

void ChasmDefinition::SolidColor::init(uint8_t paletteIndex)
void VoxelChasmDefinition::SolidColor::init(uint8_t paletteIndex)
{
this->paletteIndex = paletteIndex;
}

void ChasmDefinition::Animated::init(Buffer<TextureAsset> &&textureAssets)
void VoxelChasmDefinition::Animated::init(Buffer<TextureAsset> &&textureAssets)
{
this->textureAssets = std::move(textureAssets);
}

ChasmDefinition::ChasmDefinition()
VoxelChasmDefinition::VoxelChasmDefinition()
{
this->allowsSwimming = false;
this->isDamaging = false;
this->isEmissive = false;
this->animType = static_cast<AnimationType>(-1);
}

ChasmDefinition::ChasmDefinition(const ChasmDefinition &other)
VoxelChasmDefinition::VoxelChasmDefinition(const VoxelChasmDefinition &other)
{
this->allowsSwimming = other.allowsSwimming;
this->isDamaging = other.isDamaging;
Expand All @@ -52,7 +52,7 @@ ChasmDefinition::ChasmDefinition(const ChasmDefinition &other)
}
}

void ChasmDefinition::initClassic(ArenaTypes::ChasmType chasmType, const TextureAsset &wallTextureAsset,
void VoxelChasmDefinition::initClassic(ArenaTypes::ChasmType chasmType, const TextureAsset &wallTextureAsset,
TextureManager &textureManager)
{
this->allowsSwimming = ArenaChasmUtils::allowsSwimming(chasmType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class TextureManager;

struct ChasmDefinition
struct VoxelChasmDefinition
{
enum class AnimationType
{
Expand Down Expand Up @@ -43,8 +43,8 @@ struct ChasmDefinition
SolidColor solidColor;
Animated animated;

ChasmDefinition();
ChasmDefinition(const ChasmDefinition &other);
VoxelChasmDefinition();
VoxelChasmDefinition(const VoxelChasmDefinition &other);

void initClassic(ArenaTypes::ChasmType chasmType, const TextureAsset &wallTextureAsset, TextureManager &textureManager);
};
Expand Down
20 changes: 10 additions & 10 deletions OpenTESArena/src/Voxels/VoxelChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ const std::string &VoxelChunk::getBuildingName(BuildingNameID id) const
return this->buildingNames[id];
}

const DoorDefinition &VoxelChunk::getDoorDef(DoorDefID id) const
const VoxelDoorDefinition &VoxelChunk::getDoorDef(DoorDefID id) const
{
DebugAssertIndex(this->doorDefs, id);
return this->doorDefs[id];
}

const ChasmDefinition &VoxelChunk::getChasmDef(ChasmDefID id) const
const VoxelChasmDefinition &VoxelChunk::getChasmDef(ChasmDefID id) const
{
DebugAssertIndex(this->chasmDefs, id);
return this->chasmDefs[id];
Expand Down Expand Up @@ -502,14 +502,14 @@ VoxelChunk::BuildingNameID VoxelChunk::addBuildingName(std::string &&buildingNam
return id;
}

VoxelChunk::DoorDefID VoxelChunk::addDoorDef(DoorDefinition &&door)
VoxelChunk::DoorDefID VoxelChunk::addDoorDef(VoxelDoorDefinition &&door)
{
const DoorDefID id = static_cast<int>(this->doorDefs.size());
this->doorDefs.emplace_back(std::move(door));
return id;
}

VoxelChunk::ChasmDefID VoxelChunk::addChasmDef(ChasmDefinition &&chasm)
VoxelChunk::ChasmDefID VoxelChunk::addChasmDef(VoxelChasmDefinition &&chasm)
{
const ChasmDefID id = static_cast<int>(this->chasmDefs.size());
this->chasmDefs.emplace_back(std::move(chasm));
Expand Down Expand Up @@ -676,9 +676,9 @@ void VoxelChunk::update(double dt, const CoordDouble3 &playerCoord, double ceili
DebugCrash("Expected door def ID to exist.");
}

const DoorDefinition &doorDef = this->getDoorDef(doorDefID);
const DoorDefinition::CloseSoundDef &closeSoundDef = doorDef.getCloseSound();
if (closeSoundDef.closeType == DoorDefinition::CloseType::OnClosing)
const VoxelDoorDefinition &doorDef = this->getDoorDef(doorDefID);
const VoxelDoorDefinition::CloseSoundDef &closeSoundDef = doorDef.getCloseSound();
if (closeSoundDef.closeType == VoxelDoorDefinition::CloseType::OnClosing)
{
const WorldDouble3 absoluteSoundPosition = VoxelUtils::coordToWorldPoint(voxelCoord);
audioManager.playSound(closeSoundDef.soundFilename.c_str(), absoluteSoundPosition);
Expand All @@ -695,9 +695,9 @@ void VoxelChunk::update(double dt, const CoordDouble3 &playerCoord, double ceili
DebugCrash("Expected door def ID to exist.");
}

const DoorDefinition &doorDef = this->getDoorDef(doorDefID);
const DoorDefinition::CloseSoundDef &closeSoundDef = doorDef.getCloseSound();
if (closeSoundDef.closeType == DoorDefinition::CloseType::OnClosed)
const VoxelDoorDefinition &doorDef = this->getDoorDef(doorDefID);
const VoxelDoorDefinition::CloseSoundDef &closeSoundDef = doorDef.getCloseSound();
if (closeSoundDef.closeType == VoxelDoorDefinition::CloseType::OnClosed)
{
const CoordDouble3 soundCoord(chunkPos, VoxelUtils::getVoxelCenter(voxel, ceilingScale));
const WorldDouble3 absoluteSoundPosition = VoxelUtils::coordToWorldPoint(soundCoord);
Expand Down
16 changes: 8 additions & 8 deletions OpenTESArena/src/Voxels/VoxelChunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include <unordered_map>
#include <vector>

#include "ChasmDefinition.h"
#include "DoorDefinition.h"
#include "VoxelChasmDefinition.h"
#include "VoxelChasmWallInstance.h"
#include "VoxelDirtyType.h"
#include "VoxelDoorAnimationInstance.h"
#include "VoxelDoorDefinition.h"
#include "VoxelDoorVisibilityInstance.h"
#include "VoxelFadeAnimationInstance.h"
#include "VoxelShapeDefinition.h"
Expand Down Expand Up @@ -55,8 +55,8 @@ class VoxelChunk final : public Chunk
std::vector<VoxelTriggerDefinition> triggerDefs;
std::vector<LockDefinition> lockDefs;
std::vector<std::string> buildingNames;
std::vector<DoorDefinition> doorDefs;
std::vector<ChasmDefinition> chasmDefs;
std::vector<VoxelDoorDefinition> doorDefs;
std::vector<VoxelChasmDefinition> chasmDefs;

// Indices into definitions for actual voxels in-game.
Buffer3D<VoxelShapeDefID> shapeDefIDs;
Expand Down Expand Up @@ -141,8 +141,8 @@ class VoxelChunk final : public Chunk
const VoxelTriggerDefinition &getTriggerDef(TriggerDefID id) const;
const LockDefinition &getLockDef(LockDefID id) const;
const std::string &getBuildingName(BuildingNameID id) const;
const DoorDefinition &getDoorDef(DoorDefID id) const;
const ChasmDefinition &getChasmDef(ChasmDefID id) const;
const VoxelDoorDefinition &getDoorDef(DoorDefID id) const;
const VoxelChasmDefinition &getChasmDef(ChasmDefID id) const;

VoxelShapeDefID getShapeDefID(SNInt x, int y, WEInt z) const;
VoxelTextureDefID getTextureDefID(SNInt x, int y, WEInt z) const;
Expand Down Expand Up @@ -192,8 +192,8 @@ class VoxelChunk final : public Chunk
TriggerDefID addTriggerDef(VoxelTriggerDefinition &&trigger);
LockDefID addLockDef(LockDefinition &&lock);
BuildingNameID addBuildingName(std::string &&buildingName);
DoorDefID addDoorDef(DoorDefinition &&door);
ChasmDefID addChasmDef(ChasmDefinition &&chasm);
DoorDefID addDoorDef(VoxelDoorDefinition &&door);
ChasmDefID addChasmDef(VoxelChasmDefinition &&chasm);

void addTransitionDefPosition(TransitionDefID id, const VoxelInt3 &voxel);
void addTriggerDefPosition(TriggerDefID id, const VoxelInt3 &voxel);
Expand Down
Loading

0 comments on commit 3fc104d

Please sign in to comment.