# ogre_slice.cpp `src/ogre_slice.cpp` implements the `OgreSlice` class and the two `ToOgre()` conversion helpers declared in `ogre_slice.h`. ## Constants - `kManualObjectPrefix = "ManualObjectSubmap"` — prefix for manual object names. - `kSubmapSourceMaterialName = "cartographer_ros/Submap"` — the source material defined by `submap.material`. - `kSubmapMaterialPrefix = "SubmapMaterial"`, `kSubmapTexturePrefix = "SubmapTexture"` — prefixes for per-slice cloned materials and textures. - `GetSliceIdentifier()` builds a unique `"--"` string used to name the material, texture, and manual object. ## ToOgre helpers - `ToOgre(Vector3d)` copies x/y/z into an `Ogre::Vector3`. - `ToOgre(Quaterniond)` copies w/x/y/z into an `Ogre::Quaternion`. ## Constructor Creates a child scene node under the submap node and a `ManualObject` named after the slice identifier. It clones the source `cartographer_ros/Submap` material per slice, and configures it: no shadow receiving, no lighting, no culling, a depth bias of `(-1, 0)` (pulls the slice toward the camera so it draws over other geometry), and depth writes disabled so submaps blend correctly. ## Destructor Removes the cloned material and texture from their OGRE managers, then destroys the slice scene node and the manual object. ## Update Given new `SubmapTexture` data: 1. Positions and orients the slice node from the slice pose. 2. Builds an RGB pixel buffer from the intensity/alpha channels (blue always 0), since OGRE `loadRawData` does not handle RG textures. 3. Rebuilds the manual object as a textured triangle strip quad. The quad is sized from `resolution * width/height`, with the width extending along `-Y` and the height along `-X`. 4. Uploads the pixels with `loadRawData` as a 2D `PF_BYTE_RGB` texture (removing any previous texture). 5. Configures the pass with additive-ish scene blending (`SBF_ONE`, `SBF_ONE_MINUS_SOURCE_ALPHA`) for the pre-multiplied alpha, binds the new texture unit, and disables texture filtering (nearest). ## SetAlpha Sets the `u_alpha` fragment-program constant on the material, driving opacity of the slice. ## Visibility `SetVisibility` stores the local flag; `UpdateOgreNodeVisibility(submap_visibility)` makes the node visible only when both the parent submap and this slice are visible.