Skip to content

Commit f02097b

Browse files
Add feature to bake down from SceneGraph to FlatScene.
A EvaluationObjects object was added to store all required nodes for evaluation, rather than using 'rust::Vec' in C++ because it appears it wont link to the library. Link against 'Bcrypt' library because from Rust 1.57+ it's now required. rust-lang/rust#91974 Issue #114.
1 parent b7b573a commit f02097b

27 files changed

+1136
-98
lines changed

src/mmscenegraph/cppbind/include/mmscenegraph/_cxxbridge.h

+46
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ namespace mmscenegraph {
816816
struct MarkerNode;
817817
struct ShimAttrDataBlock;
818818
struct ShimSceneGraph;
819+
struct ShimFlatScene;
820+
struct ShimEvaluationObjects;
819821
struct Camera;
820822
}
821823

@@ -1082,6 +1084,7 @@ struct ShimSceneGraph final : public ::rust::Opaque {
10821084
MMSCENEGRAPH_API_EXPORT ::mmscenegraph::MarkerNode create_marker_node(::mmscenegraph::MarkerAttrIds marker_attrs) noexcept;
10831085
MMSCENEGRAPH_API_EXPORT bool link_marker_to_camera(::mmscenegraph::NodeId mkr_node_id, ::mmscenegraph::NodeId cam_node_id) noexcept;
10841086
MMSCENEGRAPH_API_EXPORT bool link_marker_to_bundle(::mmscenegraph::NodeId mkr_node_id, ::mmscenegraph::NodeId bnd_node_id) noexcept;
1087+
MMSCENEGRAPH_API_EXPORT bool set_node_parent(::mmscenegraph::NodeId child_node_id, ::mmscenegraph::NodeId parent_node_id) noexcept;
10851088
~ShimSceneGraph() = delete;
10861089

10871090
private:
@@ -1093,6 +1096,45 @@ struct ShimSceneGraph final : public ::rust::Opaque {
10931096
};
10941097
#endif // CXXBRIDGE1_STRUCT_mmscenegraph$ShimSceneGraph
10951098

1099+
#ifndef CXXBRIDGE1_STRUCT_mmscenegraph$ShimFlatScene
1100+
#define CXXBRIDGE1_STRUCT_mmscenegraph$ShimFlatScene
1101+
struct ShimFlatScene final : public ::rust::Opaque {
1102+
MMSCENEGRAPH_API_EXPORT void evaluate(const ::mmscenegraph::ShimAttrDataBlock &attrdb, ::rust::Slice<const ::std::uint32_t> frame_list) noexcept;
1103+
~ShimFlatScene() = delete;
1104+
1105+
private:
1106+
friend ::rust::layout;
1107+
struct layout {
1108+
static ::std::size_t size() noexcept;
1109+
static ::std::size_t align() noexcept;
1110+
};
1111+
};
1112+
#endif // CXXBRIDGE1_STRUCT_mmscenegraph$ShimFlatScene
1113+
1114+
#ifndef CXXBRIDGE1_STRUCT_mmscenegraph$ShimEvaluationObjects
1115+
#define CXXBRIDGE1_STRUCT_mmscenegraph$ShimEvaluationObjects
1116+
struct ShimEvaluationObjects final : public ::rust::Opaque {
1117+
MMSCENEGRAPH_API_EXPORT void clear_all() noexcept;
1118+
MMSCENEGRAPH_API_EXPORT void clear_bundles() noexcept;
1119+
MMSCENEGRAPH_API_EXPORT void clear_markers() noexcept;
1120+
MMSCENEGRAPH_API_EXPORT void clear_cameras() noexcept;
1121+
MMSCENEGRAPH_API_EXPORT ::std::size_t num_bundles() const noexcept;
1122+
MMSCENEGRAPH_API_EXPORT ::std::size_t num_markers() const noexcept;
1123+
MMSCENEGRAPH_API_EXPORT ::std::size_t num_cameras() const noexcept;
1124+
MMSCENEGRAPH_API_EXPORT void add_bundle(const ::mmscenegraph::BundleNode &bnd_node) noexcept;
1125+
MMSCENEGRAPH_API_EXPORT void add_camera(const ::mmscenegraph::CameraNode &cam_node) noexcept;
1126+
MMSCENEGRAPH_API_EXPORT void add_marker(const ::mmscenegraph::MarkerNode &mkr_node) noexcept;
1127+
~ShimEvaluationObjects() = delete;
1128+
1129+
private:
1130+
friend ::rust::layout;
1131+
struct layout {
1132+
static ::std::size_t size() noexcept;
1133+
static ::std::size_t align() noexcept;
1134+
};
1135+
};
1136+
#endif // CXXBRIDGE1_STRUCT_mmscenegraph$ShimEvaluationObjects
1137+
10961138
#ifndef CXXBRIDGE1_STRUCT_mmscenegraph$Camera
10971139
#define CXXBRIDGE1_STRUCT_mmscenegraph$Camera
10981140
struct Camera final {
@@ -1113,6 +1155,10 @@ MMSCENEGRAPH_API_EXPORT ::rust::Box<::mmscenegraph::ShimAttrDataBlock> shim_crea
11131155

11141156
MMSCENEGRAPH_API_EXPORT ::rust::Box<::mmscenegraph::ShimSceneGraph> shim_create_scene_graph_box() noexcept;
11151157

1158+
MMSCENEGRAPH_API_EXPORT ::rust::Box<::mmscenegraph::ShimFlatScene> shim_bake_scene_graph(const ::rust::Box<::mmscenegraph::ShimSceneGraph> &sg, const ::rust::Box<::mmscenegraph::ShimEvaluationObjects> &eval_objects) noexcept;
1159+
1160+
MMSCENEGRAPH_API_EXPORT ::rust::Box<::mmscenegraph::ShimEvaluationObjects> shim_create_evaluation_objects_box() noexcept;
1161+
11161162
MMSCENEGRAPH_API_EXPORT void foo(::std::uint32_t number) noexcept;
11171163

11181164
MMSCENEGRAPH_API_EXPORT ::std::uint32_t foobar(::std::uint32_t number) noexcept;

src/mmscenegraph/cppbind/include/mmscenegraph/attrdatablock.h

+16-3
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,26 @@ class AttrDataBlock {
4444
AttrId create_attr_static(Real value) noexcept;
4545

4646
MMSCENEGRAPH_API_EXPORT
47-
AttrId create_attr_anim_dense(rust::Vec<Real> values, FrameValue frame_start) noexcept;
47+
AttrId
48+
create_attr_anim_dense(
49+
rust::Vec<Real> values,
50+
FrameValue frame_start
51+
) noexcept;
4852

4953
MMSCENEGRAPH_API_EXPORT
50-
Real get_attr_value(AttrId attr_id, FrameValue frame) const noexcept;
54+
Real
55+
get_attr_value(
56+
AttrId attr_id,
57+
FrameValue frame
58+
) const noexcept;
5159

5260
MMSCENEGRAPH_API_EXPORT
53-
void set_attr_value(AttrId attr_id, FrameValue frame, Real value) noexcept;
61+
void
62+
set_attr_value(
63+
AttrId attr_id,
64+
FrameValue frame,
65+
Real value
66+
) noexcept;
5467

5568
private:
5669
rust::Box<ShimAttrDataBlock> inner_;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (C) 2020, 2021 David Cattermole.
3+
*
4+
* This file is part of mmSolver.
5+
*
6+
* mmSolver is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* mmSolver is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with mmSolver. If not, see <https://www.gnu.org/licenses/>.
18+
* ====================================================================
19+
*
20+
*/
21+
22+
#pragma once
23+
24+
#include <memory>
25+
#include <string>
26+
27+
#include "_cxx.h"
28+
#include "_cxxbridge.h"
29+
#include "_symbol_export.h"
30+
31+
namespace mmscenegraph {
32+
33+
class EvaluationObjects {
34+
public:
35+
36+
MMSCENEGRAPH_API_EXPORT
37+
EvaluationObjects() noexcept;
38+
39+
MMSCENEGRAPH_API_EXPORT
40+
rust::Box<ShimEvaluationObjects> get_inner() noexcept;
41+
42+
MMSCENEGRAPH_API_EXPORT
43+
size_t num_bundles() const noexcept;
44+
45+
MMSCENEGRAPH_API_EXPORT
46+
size_t num_cameras() const noexcept;
47+
48+
MMSCENEGRAPH_API_EXPORT
49+
size_t num_markers() const noexcept;
50+
51+
MMSCENEGRAPH_API_EXPORT
52+
void clear_all() noexcept;
53+
54+
MMSCENEGRAPH_API_EXPORT
55+
void clear_bundles() noexcept;
56+
57+
MMSCENEGRAPH_API_EXPORT
58+
void clear_cameras() noexcept;
59+
60+
MMSCENEGRAPH_API_EXPORT
61+
void clear_markers() noexcept;
62+
63+
MMSCENEGRAPH_API_EXPORT
64+
void add_bundle(BundleNode &bnd_node) noexcept;
65+
66+
MMSCENEGRAPH_API_EXPORT
67+
void add_camera(CameraNode &cam_node) noexcept;
68+
69+
MMSCENEGRAPH_API_EXPORT
70+
void add_marker(MarkerNode &mkr_node) noexcept;
71+
72+
private:
73+
rust::Box<ShimEvaluationObjects> inner_;
74+
};
75+
76+
} // namespace mmscenegraph
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2020, 2021 David Cattermole.
3+
*
4+
* This file is part of mmSolver.
5+
*
6+
* mmSolver is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* mmSolver is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with mmSolver. If not, see <https://www.gnu.org/licenses/>.
18+
* ====================================================================
19+
*
20+
*/
21+
22+
#pragma once
23+
24+
#include <memory>
25+
#include <string>
26+
27+
#include "_cxx.h"
28+
#include "_cxxbridge.h"
29+
#include "_symbol_export.h"
30+
31+
namespace mmscenegraph {
32+
33+
class FlatScene {
34+
public:
35+
36+
MMSCENEGRAPH_API_EXPORT
37+
FlatScene(rust::Box<ShimFlatScene> flat_scene) noexcept;
38+
39+
private:
40+
rust::Box<ShimFlatScene> inner_;
41+
};
42+
43+
} // namespace mmscenegraph

src/mmscenegraph/cppbind/include/mmscenegraph/mmscenegraph.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
* You should have received a copy of the GNU Lesser General Public License
1717
* along with mmSolver. If not, see <https://www.gnu.org/licenses/>.
1818
* ====================================================================
19+
*
1920
*/
2021

2122
#pragma once
2223

2324
#include "_cxx.h"
2425
#include "_cxxbridge.h"
2526
#include "_types.h"
26-
#include "scenegraph.h"
2727
#include "attrdatablock.h"
28+
#include "flatscene.h"
29+
#include "scenebake.h"
30+
#include "scenegraph.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2020, 2021 David Cattermole.
3+
*
4+
* This file is part of mmSolver.
5+
*
6+
* mmSolver is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* mmSolver is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with mmSolver. If not, see <https://www.gnu.org/licenses/>.
18+
* ====================================================================
19+
*
20+
*/
21+
22+
#pragma once
23+
24+
#include <memory>
25+
26+
#include "_cxx.h"
27+
#include "_cxxbridge.h"
28+
#include "_symbol_export.h"
29+
#include "scenebake.h"
30+
#include "flatscene.h"
31+
#include "scenegraph.h"
32+
#include "evaluationobjects.h"
33+
34+
namespace mmscenegraph {
35+
36+
MMSCENEGRAPH_API_EXPORT
37+
FlatScene
38+
bake_scene_graph(
39+
SceneGraph &sg,
40+
EvaluationObjects &solve_objects
41+
) noexcept;
42+
43+
} // namespace mmscenegraph

src/mmscenegraph/cppbind/include/mmscenegraph/scenegraph.h

+33-7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class SceneGraph {
3636
MMSCENEGRAPH_API_EXPORT
3737
SceneGraph() noexcept;
3838

39+
MMSCENEGRAPH_API_EXPORT
40+
rust::Box<ShimSceneGraph>
41+
get_inner() noexcept;
42+
43+
MMSCENEGRAPH_API_EXPORT
44+
void
45+
SceneGraph::set_inner(rust::Box<ShimSceneGraph> value) noexcept;
46+
3947
MMSCENEGRAPH_API_EXPORT
4048
void clear() noexcept;
4149

@@ -61,15 +69,17 @@ class SceneGraph {
6169
Translate3DAttrIds translate_attrs,
6270
Rotate3DAttrIds rotate_attrs,
6371
Scale3DAttrIds scale_attrs,
64-
RotateOrder rotate_order) noexcept;
72+
RotateOrder rotate_order
73+
) noexcept;
6574

6675
MMSCENEGRAPH_API_EXPORT
6776
BundleNode
6877
create_bundle_node(
6978
Translate3DAttrIds translate_attrs,
7079
Rotate3DAttrIds rotate_attrs,
7180
Scale3DAttrIds scale_attrs,
72-
RotateOrder rotate_order) noexcept;
81+
RotateOrder rotate_order
82+
) noexcept;
7383

7484
MMSCENEGRAPH_API_EXPORT
7585
CameraNode
@@ -78,20 +88,36 @@ class SceneGraph {
7888
Rotate3DAttrIds rotate_attrs,
7989
Scale3DAttrIds scale_attrs,
8090
CameraAttrIds camera_attrs,
81-
RotateOrder rotate_order) noexcept;
91+
RotateOrder rotate_order
92+
) noexcept;
8293

8394
MMSCENEGRAPH_API_EXPORT
8495
MarkerNode
85-
create_marker_node(MarkerAttrIds marker_attrs) noexcept;
96+
create_marker_node(
97+
MarkerAttrIds marker_attrs
98+
) noexcept;
8699

87100
MMSCENEGRAPH_API_EXPORT
88101
bool
89-
link_marker_to_camera(NodeId mkr_node_id, NodeId cam_node_id) noexcept;
102+
link_marker_to_camera(
103+
NodeId mkr_node_id,
104+
NodeId cam_node_id
105+
) noexcept;
90106

91107
MMSCENEGRAPH_API_EXPORT
92108
bool
93-
link_marker_to_bundle(NodeId mkr_node_id, NodeId bnd_node_id) noexcept;
94-
109+
link_marker_to_bundle(
110+
NodeId mkr_node_id,
111+
NodeId bnd_node_id
112+
) noexcept;
113+
114+
MMSCENEGRAPH_API_EXPORT
115+
bool
116+
set_node_parent(
117+
NodeId child_node_id,
118+
NodeId parent_node_id
119+
) noexcept;
120+
95121
private:
96122
rust::Box<ShimSceneGraph> inner_;
97123
};

0 commit comments

Comments
 (0)