Repository navigation
Conversation
* wip procedural meshes * wip procedural mesh * wip procedural mesh * wip procedural mesh * wip procedural mesh * fix procedural meshes * fix procedural meshes * cleanup * fix rest pose fix... * cleanup * cleanup * cleanup * cleanup * cleanup * sierpinski * sierpinski normals * sierpinski winding fix * fix race condition
* wip procedural meshes * wip procedural mesh * wip procedural mesh * wip procedural mesh * wip procedural mesh * fix procedural meshes * fix procedural meshes * cleanup * fix rest pose fix... * cleanup * cleanup * cleanup * cleanup * cleanup * sierpinski * sierpinski normals * sierpinski winding fix * fix race condition
* Tr2VoxelData wip * Simplify interface * Add persistence * Async read support * Add some comments * Add "on data changed" event; address PR comments
Implementation of a texture that converts a voxeldata channel to a 3d texture. It implements ITr2TextureProvider so it can be used in Tr2RuntimeTextureProvider shader resource.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical defects can cause undersized allocations, out-of-bounds writes, undefined behavior, and data races that violate snapshot immutability.
12 open issues
Scale normalized integer values in double precision · New Prevent overflow in voxel storage size and index calculations · New Enforce the 64-channel limit or expand the modification mask · New Keep snapshot checks and voxel writes atomic under the mutex · New Validate persisted payload descriptors before use · New Avoid taking ownership of borrowed dictionary values · New Include texture depth in Metal staging-buffer reservations · New Declare the Blue class traits for Tr2VoxelTexture · New Release the destination snapshot before move assignment · New Transfer iterator ownership without incrementing its reference · New Notify listeners when a batch partially commits before an error · New Recreate the voxel texture after device reset · New
What changed in this PR
Adds voxel-backed 3D textures to Trinity’s texture-provider system and extends mesh rendering to support procedural geometry through a shared geometry-provider abstraction.
Changes:
- Adds voxel storage, typed texture uploads, change notifications, and Python bindings.
- Introduces shared geometry-provider infrastructure, asynchronous procedural builds, and cube/Sierpinski generators.
- Updates rendering consumers and build registration, and adds voxel-data tests.
| File | Description |
|---|---|
| trinity/Tr2VoxelTexture.h | Declares the voxel texture provider. |
| trinity/Tr2VoxelTexture.cpp | Implements format mapping and texture uploads. |
| trinity/Tr2VoxelTexture_Blue.cpp | Exposes voxel texture properties. |
| trinity/Tr2VoxelData.h | Defines voxel channels, snapshots, and bit helpers. |
| trinity/Tr2VoxelData.cpp | Implements voxel storage, editing, and persistence. |
| trinity/Tr2VoxelData_Blue.cpp | Exposes voxel data and test accessors. |
| trinity/Tr2SkinnedModel.cpp | Uses the shared geometry-provider type. |
| trinity/Tr2Model.cpp | Uses the shared geometry-provider type. |
| trinity/Tr2MeshProcedural.h | Declares procedural mesh support. |
| trinity/Tr2MeshProcedural.cpp | Connects procedural geometry and resource notifications. |
| trinity/Tr2MeshProcedural_Blue.cpp | Exposes procedural mesh geometry. |
| trinity/Tr2MeshBase.h | Generalizes geometry access and morph defaults. |
| trinity/Tr2MeshBase.cpp | Implements shared mesh defaults and area count. |
| trinity/Tr2MeshBase_Blue.cpp | Exposes common loading and area APIs. |
| trinity/Tr2Mesh.h | Adopts the shared geometry interface. |
| trinity/Tr2Mesh.cpp | Updates geometry access and inherits area count. |
| trinity/Tr2Mesh_Blue.cpp | Moves common bindings to the mesh base. |
| trinity/Tr2InstancedMesh.cpp | Accepts geometry providers for vertex declarations. |
| trinity/Tr2BackgroundWorker.h | Declares the background task service. |
| trinity/Tr2BackgroundWorker.cpp | Initializes the procedural-build worker. |
| trinity/tests/Python/tests/test_voxeldata.py | Tests voxel editing, persistence, and snapshots. |
| trinity/Resources/TriGeometryRes.h | Derives file-backed geometry from the shared provider. |
| trinity/Resources/TriGeometryRes_Blue.cpp | Inherits shared geometry bindings. |
| trinity/Resources/Tr2ProceduralSierpinski.h | Declares the Sierpinski generator. |
| trinity/Resources/Tr2ProceduralSierpinski.cpp | Builds fractal geometry and tangent data. |
| trinity/Resources/Tr2ProceduralSierpinski_Blue.cpp | Exposes fractal size and depth. |
| trinity/Resources/Tr2ProceduralGeometryProvider.h | Defines procedural build and lifecycle interfaces. |
| trinity/Resources/Tr2ProceduralGeometryProvider.cpp | Implements build scheduling, cancellation, and preparation. |
| trinity/Resources/Tr2ProceduralGeometryProvider_Blue.cpp | Exposes rebuild and synchronous execution controls. |
| trinity/Resources/Tr2ProceduralCube.h | Declares the cube generator. |
| trinity/Resources/Tr2ProceduralCube.cpp | Builds cube geometry in memory. |
| trinity/Resources/Tr2ProceduralCube_Blue.cpp | Exposes cube extent. |
| trinity/Resources/Tr2GeometryProvider.h | Defines shared geometry structures and APIs. |
| trinity/Resources/Tr2GeometryProvider.cpp | Implements shared rendering and geometry operations. |
| trinity/Resources/Tr2GeometryProvider_Blue.cpp | Exposes shared geometry APIs and utilities. |
| trinity/Resources/Tr2CmfContent.h | Declares in-memory CMF loading. |
| trinity/Resources/Tr2CmfContent.cpp | Shares initialization between stream and memory inputs. |
| trinity/Raytracing/Tr2RaytracingGeometry.h | Stores shared geometry-provider references. |
| trinity/Raytracing/Tr2RaytracingGeometry.cpp | Accepts geometry providers for raytracing updates. |
| trinity/Interior/Tr2IntSkinnedObject.cpp | Uses geometry providers for render batches. |
| trinity/Eve/SpaceObject/EveSwarm.cpp | Generalizes decal and shadow geometry access. |
| trinity/Eve/SpaceObject/EveSpaceObject2.h | Generalizes cached and occlusion geometry references. |
| trinity/Eve/SpaceObject/EveSpaceObject2.cpp | Adapts rendering and animation geometry access. |
| trinity/Eve/SpaceObject/Children/EveSpaceObjectChild.h | Generalizes child geometry references. |
| trinity/Eve/SpaceObject/Children/EveChildTurret.h | Generalizes turret geometry interfaces. |
| trinity/Eve/SpaceObject/Children/EveChildTurret.cpp | Updates turret geometry access and caching. |
| trinity/Eve/SpaceObject/Children/EveChildMesh.cpp | Adapts animation, debug, and rest-pose handling. |
| trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h | Accepts shared geometry providers for decals. |
| trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.cpp | Updates decal geometry implementations. |
| trinity/CMakeLists.txt | Registers the new source files. |
Review effort: Balanced
Comment on lines
+82
to
+86
| return T( std::round( std::clamp( float( value ), -1.0f, 1.0f ) * float( std::numeric_limits<T>::max() ) ) ); | ||
| } | ||
| else | ||
| { | ||
| return T( std::round( std::clamp( float( value ), 0.0f, 1.0f ) * float( std::numeric_limits<T>::max() ) ) ); |
Comment on lines
+185
to
+187
| return ( dimensions.width * dimensions.height * dimensions.depth * elementCount + 7 ) / 8; | ||
| } | ||
| return dimensions.width * dimensions.height * dimensions.depth * GetBytesPerValue(); |
|
|
||
| void Tr2VoxelData::ModifiedChannels::MarkChannelModified( size_t channelIndex ) | ||
| { | ||
| m_modifiedChannelsBitmask |= ( 1ull << channelIndex ); |
Comment on lines
+379
to
+380
| } | ||
| } |
| { | ||
| break; | ||
| } | ||
| PayloadType payloadType = *reinterpret_cast<PayloadType*>( buffer ); |
| /** | ||
| * @brief Texture composed from voxel data. Reacts to changes in data and updates the texture accordingly. | ||
| */ | ||
| class Tr2VoxelTexture : public ITr2TextureProvider, |
| { | ||
| if( this != &other ) | ||
| { | ||
| m_voxelData = other.m_voxelData; |
|
|
||
| BluePy Tr2VoxelData::SetVoxels( PyObject* set ) | ||
| { | ||
| auto setIter = BluePy( PyObject_GetIter( set ), true ); |
Comment on lines
+397
to
+400
| if( !IsWithinBounds( coord ) ) | ||
| { | ||
| PyErr_SetString( PyExc_ValueError, "SetVoxels coordinates out of bounds" ); | ||
| return {}; |
Comment on lines
+10
to
+11
| class Tr2VoxelTexture : public ITr2TextureProvider, | ||
| public INotify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Tr2VoxelTexture: expose a voxel data channel as a 3D texture
Adds
Tr2VoxelTexture, anITr2TextureProviderthat turns one payload channel of aTr2VoxelDatainto a 3D texture. Shaders index it withtex[uint3(x, y, z)], and it can be bound with e.g.Tr2RuntimeTextureParameter.*_FLOAT,*_UINT,*_SINT), and normalized 8/16-bit channels use*_UNORM/*_SNORM. Boolean channels are unpacked to one byte per element (R8*_UINT).voxelDataorchannelrebuilds the texture. Edits throughSetVoxelsto the selected channel are re-uploaded in place.Tr2VoxelDataTypeName()for logging, plusGetPackedBit/SetPackedBitso the Boolean bit layout is defined in one place.AI assistance
AI assisted with code review and some small code tweaks