Skip to content

Commit 11f17dd

Browse files
committed
Update frame and transform getters
1 parent 9ae4c95 commit 11f17dd

29 files changed

+110
-53
lines changed

demos/rlCollisionDemo/BodyModel.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ BodyModel::data(const QModelIndex& index, int role) const
6060
return QVariant();
6161
}
6262

63-
rl::math::Transform transform;
64-
this->collision->getFrame(transform);
63+
rl::math::Transform transform = this->collision->getFrame();
6564
rl::math::Transform::TranslationPart position = transform.translation();
6665
rl::math::Vector3 orientation = transform.rotation().eulerAngles(2, 1, 0).reverse();
6766

@@ -190,8 +189,7 @@ BodyModel::setData(const QModelIndex& index, const QVariant& value, int role)
190189

191190
if (index.isValid() && Qt::EditRole == role)
192191
{
193-
rl::math::Transform transform;
194-
this->collision->getFrame(transform);
192+
rl::math::Transform transform = this->collision->getFrame();
195193
rl::math::Transform::TranslationPart position = transform.translation();
196194
rl::math::Vector3 orientation = transform.linear().eulerAngles(2, 1, 0).reverse();
197195

src/rl/sg/Body.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ namespace rl
9292
}
9393
}
9494

95+
void
96+
Body::getFrame(::rl::math::Transform& frame)
97+
{
98+
frame = this->getFrame();
99+
}
100+
95101
Model*
96102
Body::getModel() const
97103
{

src/rl/sg/Body.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ namespace rl
6262

6363
void getBoundingBoxPoints(const ::rl::math::Transform& frame, ::std::vector<::rl::math::Vector3>& p) const;
6464

65+
RL_SG_DEPRECATED virtual void getFrame(::rl::math::Transform& frame);
66+
67+
virtual ::rl::math::Transform getFrame() const = 0;
68+
6569
Model* getModel() const;
6670

6771
virtual ::std::string getName() const;
@@ -72,8 +76,6 @@ namespace rl
7276

7377
Shape* getShape(const ::std::size_t& i) const;
7478

75-
virtual void getFrame(::rl::math::Transform& frame) = 0;
76-
7779
virtual void remove(Shape* shape);
7880

7981
virtual void setFrame(const ::rl::math::Transform& frame) = 0;

src/rl/sg/Shape.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ namespace rl
5454
return this->name;
5555
}
5656

57+
void
58+
Shape::getTransform(::rl::math::Transform& transform)
59+
{
60+
transform = this->getTransform();
61+
}
62+
5763
void
5864
Shape::setName(const ::std::string& name)
5965
{

src/rl/sg/Shape.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ namespace rl
4949

5050
virtual ::std::string getName() const;
5151

52-
virtual void getTransform(::rl::math::Transform& transform) = 0;
52+
RL_SG_DEPRECATED virtual void getTransform(::rl::math::Transform& transform);
53+
54+
virtual ::rl::math::Transform getTransform() const = 0;
5355

5456
virtual void setName(const ::std::string& name);
5557

src/rl/sg/bullet/Body.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ namespace rl
6666
return new Shape(shape, this);
6767
}
6868

69-
void
70-
Body::getFrame(::rl::math::Transform& frame)
69+
::rl::math::Transform
70+
Body::getFrame() const
7171
{
72+
::rl::math::Transform frame;
73+
7274
for (int i = 0; i < 3; ++i)
7375
{
7476
frame(0, i) = this->object.getWorldTransform().getBasis().getRow(i).getX();
@@ -84,6 +86,8 @@ namespace rl
8486
frame(3, 1) = 0;
8587
frame(3, 2) = 0;
8688
frame(3, 3) = 1;
89+
90+
return frame;
8791
}
8892

8993
void

src/rl/sg/bullet/Body.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ namespace rl
4848

4949
::rl::sg::Shape* create(::SoVRMLShape* shape);
5050

51-
void getFrame(::rl::math::Transform& frame);
51+
using ::rl::sg::Body::getFrame;
52+
53+
::rl::math::Transform getFrame() const;
5254

5355
void setFrame(const ::rl::math::Transform& frame);
5456

src/rl/sg/bullet/Shape.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ namespace rl
133133
this->getBody()->remove(this);
134134
}
135135

136-
void
137-
Shape::getTransform(::rl::math::Transform& transform)
136+
::rl::math::Transform
137+
Shape::getTransform() const
138138
{
139139
Body* body = static_cast<Body*>(this->getBody());
140140

141+
::rl::math::Transform transform;
142+
141143
for (int i = 0; i < body->shape.getNumChildShapes(); ++i)
142144
{
143145
if (this->shape.get() == body->shape.getChildList()[i].m_childShape)
@@ -161,6 +163,8 @@ namespace rl
161163
break;
162164
}
163165
}
166+
167+
return transform;
164168
}
165169

166170
void

src/rl/sg/bullet/Shape.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ namespace rl
4747

4848
virtual ~Shape();
4949

50-
void getTransform(::rl::math::Transform& transform);
50+
using ::rl::sg::Shape::getTransform;
51+
52+
::rl::math::Transform getTransform() const;
5153

5254
void setTransform(const ::rl::math::Transform& transform);
5355

src/rl/sg/fcl/Body.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ namespace rl
7070
return new Shape(shape, this);
7171
}
7272

73-
void
74-
Body::getFrame(::rl::math::Transform& frame)
73+
::rl::math::Transform
74+
Body::getFrame() const
7575
{
76-
frame = this->frame;
76+
return this->frame;
7777
}
7878

7979
void

0 commit comments

Comments
 (0)