@@ -75,7 +75,7 @@ class SparseVolumeGrid : public Structure {
7575 // Corner c = dx*4 + dy*2 + dz maps cell[i] -> index in canonical node order
7676 render::ManagedBuffer<uint32_t > cornerNodeInds[8 ];
7777
78- uint64_t nNodes ();
78+ uint64_t nNodes (); // NOTE: not populated until nodes are enabled (use ensureHaveCornerNodeIndices() to force this)
7979 const std::vector<glm::ivec3>& getCanonicalNodeInds ();
8080 void ensureHaveCornerNodeIndices ();
8181
@@ -148,6 +148,18 @@ class SparseVolumeGrid : public Structure {
148148 SparseVolumeGrid* setCubeSizeFactor (double newVal);
149149 double getCubeSizeFactor ();
150150
151+ // Render mode (gridcube or wireframe)
152+ SparseVolumeGrid* setRenderMode (SparseVolumeGridRenderMode mode);
153+ SparseVolumeGridRenderMode getRenderMode ();
154+
155+ // Wireframe radius as a node-relative value. 1.0 is a reasonable default size.
156+ SparseVolumeGrid* setWireframeRadius (double newVal);
157+ double getWireframeRadius ();
158+
159+ // Color used for wireframe rendering
160+ SparseVolumeGrid* setWireframeColor (glm::vec3 val);
161+ glm::vec3 getWireframeColor ();
162+
151163private:
152164 // Field data
153165 glm::vec3 origin;
@@ -171,6 +183,9 @@ class SparseVolumeGrid : public Structure {
171183 PersistentValue<glm::vec3> edgeColor;
172184 PersistentValue<std::string> material;
173185 PersistentValue<float > cubeSizeFactor;
186+ PersistentValue<SparseVolumeGridRenderMode> renderMode;
187+ PersistentValue<float > wireframeRadius;
188+ PersistentValue<glm::vec3> wireframeColor;
174189
175190 // Compute cell positions and GPU indices from occupiedCellsData
176191 void computeCellPositions ();
@@ -187,6 +202,13 @@ class SparseVolumeGrid : public Structure {
187202 std::shared_ptr<render::ShaderProgram> program;
188203 std::shared_ptr<render::ShaderProgram> pickProgram;
189204
205+ // Wireframe render mode
206+ std::shared_ptr<render::ShaderProgram> wireframeNodeProgram;
207+ std::shared_ptr<render::ShaderProgram> wireframeEdgeProgram;
208+ void ensureWireframeProgramsPrepared ();
209+ void buildWireframeGeometry (std::vector<glm::vec3>& nodePositions, std::vector<glm::vec3>& edgeTailPositions,
210+ std::vector<glm::vec3>& edgeTipPositions);
211+
190212 // === Helpers
191213 void checkForDuplicateCells ();
192214 size_t findCellFlatIndex (glm::ivec3 cellInd3);
0 commit comments