Skip to content

Commit 494489f

Browse files
authored
[core] Revamp SSAO, depth and shadow map pass classes - add move constructors, assignment op, and destructors (#60)
* [bindings/python] expose MeshData, don't know how I'll use it * core : Revamp depth and shadow map pass classes + make them RAII + add destructors * core/Texture : do not store pointer to Device but raw SDLGPU device handle * posteffects :: SSAO : add move ctor and a dtor * Update CHANGELOG
1 parent a33f8e7 commit 494489f

File tree

15 files changed

+332
-207
lines changed

15 files changed

+332
-207
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- multibody/RobotScene : early return if pipeline is nullptr (https://github.com/Simple-Robotics/candlewick/pull/58)
2222
- multibody/RobotScene : reorganize pipelines (accomodate for transparent PBR shader)
2323
- shaders : refactor basic PBR shader (move some functions to new `pbr_lighting.glsl`) (https://github.com/Simple-Robotics/candlewick/pull/58)
24-
- interleave debug scene render between robot render system opaque and transparent passes
24+
- interleave debug scene render between robot render system opaque and transparent passes (https://github.com/Simple-Robotics/candlewick/pull/59)
25+
- revamp depth and shadow map pass classes (https://github.com/Simple-Robotics/candlewick/pull/60)
26+
- core/Texture : do not store pointer to `Device` but raw `SDL_GPUDevice *` handle (https://github.com/Simple-Robotics/candlewick/pull/60)
2527

2628
## [0.0.6] - 2025-05-14
2729

bindings/python/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ endif(GENERATE_PYTHON_STUBS)
55

66
find_package(eigenpy 3.2.0 REQUIRED)
77

8-
set(pycandlewick_SOURCES src/expose-renderer.cpp src/module.cpp)
8+
set(
9+
pycandlewick_SOURCES
10+
src/expose-mesh-data.cpp
11+
src/expose-renderer.cpp
12+
src/module.cpp
13+
)
914

1015
set(PYLIB_INSTALL_DIR ${PYTHON_SITELIB}/${PROJECT_NAME})
1116

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "fwd.hpp"
2+
#include "candlewick/utils/MeshData.h"
3+
4+
using namespace candlewick;
5+
6+
void exposeMeshData() {
7+
8+
bp::class_<MeshLayout>("MeshLayout", bp::no_init);
9+
10+
bp::class_<MeshData, boost::noncopyable>("MeshData", bp::no_init)
11+
.def_readonly("layout", &MeshData::layout)
12+
.add_property("numVertices", &MeshData::numVertices,
13+
"Number of vertices.")
14+
.add_property("vertexSize", &MeshData::vertexSize)
15+
.add_property("vertexBytes", &MeshData::vertexBytes,
16+
"Number of bytes in the vertex data.")
17+
.add_property("numIndices", &MeshData::numIndices, "Number of indices.")
18+
.add_property("isIndexed", &MeshData::isIndexed,
19+
"Whether the mesh is indexed.")
20+
21+
;
22+
}

bindings/python/src/expose-visualizer.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,32 @@
1010

1111
using namespace candlewick::multibody;
1212

13+
#define DEF_PROP_PROXY(name) \
14+
add_property(#name, bp::make_function( \
15+
+[](Visualizer &v) -> auto & { return v.name(); }, \
16+
bp::return_internal_reference<>()))
17+
1318
void exposeVisualizer() {
1419
eigenpy::OptionalConverter<ConstVectorRef, std::optional>::registration();
1520
bp::class_<Visualizer::Config>("VisualizerConfig", bp::init<>())
1621
.def_readwrite("width", &Visualizer::Config::width)
1722
.def_readwrite("height", &Visualizer::Config::height);
1823

19-
auto cl =
20-
bp::class_<Visualizer, boost::noncopyable>("Visualizer", bp::no_init)
21-
.def(bp::init<Visualizer::Config, const pin::Model &,
22-
const pin::GeometryModel &>(
23-
("self"_a, "config", "model", "geomModel")))
24-
.def(pinocchio::python::VisualizerPythonVisitor<Visualizer>{})
25-
.def_readonly("renderer", &Visualizer::renderer)
26-
.add_property("shouldExit", &Visualizer::shouldExit);
27-
24+
bp::class_<Visualizer, boost::noncopyable>("Visualizer", bp::no_init)
25+
.def(bp::init<Visualizer::Config, const pin::Model &,
26+
const pin::GeometryModel &>(
27+
("self"_a, "config", "model", "geomModel")))
28+
.def(pinocchio::python::VisualizerPythonVisitor<Visualizer>{})
29+
.def_readonly("renderer", &Visualizer::renderer)
2830
// fix for Pinocchio 3.5.0
2931
#if PINOCCHIO_VERSION_AT_MOST(3, 5, 0)
30-
#define DEF_PROP_PROXY(name) \
31-
add_property(#name, bp::make_function( \
32-
+[](Visualizer &v) -> auto & { return v.name(); }, \
33-
bp::return_internal_reference<>()))
34-
cl //
3532
.DEF_PROP_PROXY(model)
3633
.DEF_PROP_PROXY(visualModel)
3734
.DEF_PROP_PROXY(collisionModel)
3835
.DEF_PROP_PROXY(data)
3936
.DEF_PROP_PROXY(visualData)
40-
.DEF_PROP_PROXY(collisionData);
41-
#undef DEF_PROP_PROXY
37+
.DEF_PROP_PROXY(collisionData)
4238
#endif
39+
.add_property("shouldExit", &Visualizer::shouldExit);
4340
}
41+
#undef DEF_PROP_PROXY

bindings/python/src/module.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
using namespace candlewick;
88

9+
void exposeMeshData();
10+
void exposeRenderer();
911
#ifdef CANDLEWICK_PYTHON_PINOCCHIO_SUPPORT
1012
void exposeVisualizer();
1113
#endif
12-
void exposeRenderer();
1314

1415
BOOST_PYTHON_MODULE(pycandlewick) {
1516
bp::import("eigenpy");
@@ -26,6 +27,7 @@ BOOST_PYTHON_MODULE(pycandlewick) {
2627
// Register SDL_Quit() as a function to call when interpreter exits.
2728
Py_AtExit(SDL_Quit);
2829

30+
exposeMeshData();
2931
exposeRenderer();
3032
#ifdef CANDLEWICK_PYTHON_PINOCCHIO_SUPPORT
3133
{

examples/Ur5WithSystems.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ int main(int argc, char **argv) {
300300
robot_debug.addFrameTriad(debug_scene, ee_frame_id);
301301
robot_debug.addFrameVelocityArrow(debug_scene, ee_frame_id);
302302

303-
auto depthPassInfo =
304-
DepthPassInfo::create(renderer, plane_obj.mesh.layout(), NULL,
305-
{SDL_GPU_CULLMODE_NONE, 0.05f, 0.f, true, false});
303+
DepthPass depthPass(renderer.device, plane_obj.mesh.layout(),
304+
renderer.depth_texture,
305+
{SDL_GPU_CULLMODE_NONE, 0.05f, 0.f, true, false});
306306
auto &shadowPassInfo = robot_scene.shadowPass;
307307
auto shadowDebugPass =
308-
DepthDebugPass::create(renderer, shadowPassInfo.depthTexture);
308+
DepthDebugPass::create(renderer, shadowPassInfo.shadowMap);
309309

310310
auto depthDebugPass =
311311
DepthDebugPass::create(renderer, renderer.depth_texture);
@@ -464,7 +464,7 @@ int main(int argc, char **argv) {
464464
auto &castables = robot_scene.castables();
465465
renderShadowPassFromAABB(command_buffer, shadowPassInfo, sceneLight,
466466
castables, worldSpaceBounds);
467-
renderDepthOnlyPass(command_buffer, depthPassInfo, viewProj, castables);
467+
depthPass.render(command_buffer, viewProj, castables);
468468
switch (g_showDebugViz) {
469469
case FULL_RENDER:
470470
robot_scene.renderOpaque(command_buffer, g_camera);
@@ -501,7 +501,7 @@ int main(int argc, char **argv) {
501501

502502
SDL_WaitForGPUIdle(renderer.device);
503503
frustumBoundsDebug.release();
504-
depthPassInfo.release();
504+
depthPass.release();
505505
shadowDebugPass.release(renderer.device);
506506
depthDebugPass.release(renderer.device);
507507
robot_scene.release();

src/candlewick/core/Core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace candlewick {
99
struct Camera;
1010
class CommandBuffer;
1111
struct Device;
12-
struct Texture;
12+
class Texture;
1313
class Mesh;
1414
class MeshView;
1515
class MeshLayout;

0 commit comments

Comments
 (0)