Repository navigation
Split MeshData into shared MeshGeometry, MeshInstance and BasicShading - #25
Merged
Merged
Conversation
MeshData mixed render-agnostic mesh data with one fixed render setup. - MeshGeometry (feature): named, typed attributes plus triangle/edge topology; version() bumps on any geometry change. No roles. - BasicShading (feature on the same Object): position/normal/scalar role assignments and the MeshRenderState. Bindings are resolved lazily against the Object's MeshGeometry whenever its version changes: replaced attributes are followed, removed ones dropped, magnitudes recomputed, and roles not set explicitly bind vertex_positions / vertex_normals. version() bumps on role changes only. - MeshAttribute and RoleBinding move to their own headers; RoleBinding gains whole/component/magnitude factories. - VulkanMeshDrawable re-uploads when either version changes; MeshScene, the Qt/ImGui scene widgets, the control panels (PanelContext gets active_geometry()/active_shading()), normalize_to_unit_box (takes the shading) and to_mesh_geometry follow. - AbstractFeature::is_attached(). - magnitude_of uses colwise() on the cast expression directly now that zipper#42 is fixed.
- MeshGeometry::copy_from: deep copy of attributes (new instances) and topology. - BasicShading::copy_from: render state plus role assignments, re-targeted by attribute name to this shading's geometry; explicitly cleared roles stay cleared. - ImGui Duplicate uses both and ensures drawables on the copy and its descendants (previously duplicates had empty geometry and were never drawn); deep_duplicate drops its unused MeshScene parameter.
With zipper#42 fixed the norms no longer need a hand-allocated buffer and span view; eval() the expression and build the attribute from its mdspan.
- Triangles and edges are uint32 attributes on the Face/Edge domains: .face_vertices (3 x F) and .edge_vertices (2 x E, derived from the triangles unless set explicitly). Names starting with '.' are reserved: add_attribute/remove_attribute reject them, and Edge/Face attributes whose count differs from the edge/face count get a warning. - triangle_indices()/edge_indices() return column-major mdspan<const uint32_t, extents<K, dyn>> views; counts are extent(1). - Index input in either orientation is converted with zipper (cast, plus transpose for N x K) instead of a hand-written copy; a static extent of K decides the orientation, rows win when both are dynamic. - Role pickers in the controls skip reserved attributes.
Geometry is data that Objects refer to, not a component of one Object: - MeshGeometry no longer derives from AbstractFeature (and is no longer copyable; copy_from makes deep copies). - New MeshInstance feature holds std::shared_ptr<MeshGeometry>, so several Objects can show one geometry, each with its own shading. - BasicShading reads the geometry through the Object's MeshInstance and re-resolves when it shows different geometry. - MeshScene/Qt add an Object with a MeshInstance showing new geometry; ImGui Duplicate shares the source's geometry and copies its shading; VulkanMeshDrawable, panels and tools read geometry via the instance.
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.
MeshDatacombined render-agnostic mesh data with one specific render setup: the position/normal/scalar roles and render state of the built-in lit, colour-mapped shader. This PR separates the two: geometry becomes a shared resource, and how an object renders it becomes a feature. Other shading contexts (textured, points, volumes, …) can later use the same geometry, and several objects can show one geometry.New types
MeshGeometry(a plain class, not a feature) holds named, typed attributes on vertices/edges/faces. Itsversion()bumps on any geometry change. It knows nothing about rendering.owns(handle)is public so shadings can check that an attribute belongs to it..face_vertices(Face domain,uint32, 3 × F) and.edge_vertices(Edge domain, 2 × E, derived from the triangles unless set explicitly). The face and edge counts are those attributes' counts, so face/edge attributes have a single source for their element count; a mismatch is kept but logged as a warning..are reserved. The publicadd_attribute/remove_attributereject them, so topology changes only throughset_triangle_indices/set_edge_indices.triangle_indices()/edge_indices()return column-majormdspan<const uint32_t, extents<K, dyn>>views (one column per element), so the shape is in the type.copy_frommakes a deep copy.MeshInstance(feature) holds astd::shared_ptr<MeshGeometry>: the geometry anObjectshows. Several objects can show the same geometry, and the geometry outlives them.set_geometryswitches it.BasicShading(feature) holds the position/normal/scalar role assignments andMeshRenderState. It reads its geometry through theObject'sMeshInstance(geometry()).MeshDatadid when attributes were added or removed.vertex_positions/vertex_normalsautomatically. A role you explicitly cleared stays cleared when the geometry changes.version()bumps only on role changes. Geometry changes are covered byMeshGeometry::version().MeshInstance, an instance with no geometry, or not attached to anObjectyet), all roles are unbound and assignments fail.MeshAttribute/MeshAttributeHandleandRoleBindingmove to their own headers.RoleBindinggainswhole/component/magnitudefactories.Callers
VulkanMeshDrawablere-uploads buffers when either version changes, and reads render state fromBasicShading.MeshScene::add_meshcreates anObjectwith aMeshInstance(showing a new, empty geometry), aBasicShadingand a drawable.ensure_drawableapplies to objects with aMeshInstance, and adds aBasicShadingif one is missing.PanelContext::active_mesh_data()is replaced byactive_geometry()/active_shading().to_mesh_databecomesto_mesh_geometry.normalize_to_unit_boxtakes theBasicShading.BasicShading::copy_from. That copies the render state and role assignments; each assigned role points at the same-named attribute of the copy's geometry, and explicitly cleared roles stay cleared.MeshScene::ensure_drawable.MeshGeometry::copy_from(a deep copy with new attribute instances) is available when an independent copy is wanted.AbstractFeature::is_attached().magnitude_ofevaluatescolwise().norm()directly into an owning vector now that colwise()/rowwise() don't work on temporary expressions zipper#42 is fixed.Tests
MeshGeometry. Role tests use anObjectwith both features.Objectlaterdoublepositionscopy_fromproduces independent attributes, re-targets roles by name, and keeps cleared roles clearedmeson test: 13/13 suites pass.test_scene_graph: 547 assertions in 62 test cases.