Skip to content

Commit

Permalink
[Engine] fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Aug 14, 2024
1 parent 9d7381e commit 945c77f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 51 deletions.
2 changes: 1 addition & 1 deletion include/overworld/Engine/Common/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ namespace owds {
owds::Model& preloaded_box_model_;
owds::Model& preloaded_cylinder_model_;
owds::Model& preloaded_sphere_model_;
std::unordered_map<owds::Urdf*, std::unique_ptr<owds::Urdf>> loaded_robots_;
std::unordered_map<owds::Urdf*, std::unique_ptr<owds::Urdf>> loaded_urdfs_;

AmbientLight ambient_light_;
PointLights point_lights_;
Expand Down
2 changes: 1 addition & 1 deletion include/overworld/Physics/Bullet3/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace owds::bullet3 {
void setStaticFriction(float coefficient) override;
void setDynamicFriction(float coefficient) override;
void setRestitution(float coefficient) override;
void setPositionAndOrientation(const std::array<float, 3>& position, const std::array<float, 3>& orientation) override;
void setPositionAndOrientation(const std::array<float, 3>& position, const std::array<float, 4>& orientation) override;

[[nodiscard]] std::array<float, 16> getModelMatrix() const override;
[[nodiscard]] std::pair<std::array<float, 3>, std::array<float, 3>> getPositionAndOrientation() const override;
Expand Down
24 changes: 12 additions & 12 deletions include/overworld/Physics/Bullet3/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,50 @@ namespace owds::bullet3 {
owds::JointRevolute& createJointRevolute [[nodiscard]] (
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation) override;
const std::array<float, 4>& joint_orientation) override;

owds::JointContinuous& createJointContinuous [[nodiscard]] (
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation) override;
const std::array<float, 4>& joint_orientation) override;

owds::JointPrismatic& createJointPrismatic [[nodiscard]] (
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation) override;
const std::array<float, 4>& joint_orientation) override;

owds::JointFixed& createJointFixed [[nodiscard]] (
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation) override;
const std::array<float, 4>& joint_orientation) override;

owds::JointFloating& createJointFloating [[nodiscard]] (
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation) override;
const std::array<float, 4>& joint_orientation) override;

owds::JointPlanar& createJointPlanar [[nodiscard]] (
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation) override;
const std::array<float, 4>& joint_orientation) override;

void setGravity(const std::array<float, 3>& gravity) override;
void stepSimulation(float delta) override;
Expand Down
26 changes: 16 additions & 10 deletions src/Engine/Common/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,33 @@ namespace owds {
else
assert(urdf_model.initFile(path));

auto robot = std::make_unique<owds::Urdf>();
const auto robot_ptr = robot.get();
loaded_robots_[robot_ptr] = std::move(robot);
auto urdf = std::make_unique<owds::Urdf>();
const auto urdf_ptr = urdf.get();
loaded_urdfs_[urdf_ptr] = std::move(urdf);

robot_ptr->name_ = urdf_model.name_;
urdf_ptr->name_ = urdf_model.name_;

for(auto& [name, material] : urdf_model.materials_)
{
processMaterial(*robot_ptr, *material);
processMaterial(*urdf_ptr, *material);
}

for(auto& [name, link] : urdf_model.links_)
{
processLinks(*robot_ptr, *link);
processLinks(*urdf_ptr, *link);
}

for(const auto& [name, joint] : urdf_model.joints_)
{
processJoint(*robot_ptr, *joint);
processJoint(*urdf_ptr, *joint);
}

for(auto& [name, link] : urdf_model.links_)
{
processJoints(*robot_ptr, *link);
processJoints(*urdf_ptr, *link);
}

return *robot_ptr;
return *urdf_ptr;
}

void World::processMaterial(owds::Urdf& robot, const urdf::Material& urdf_material)
Expand Down Expand Up @@ -161,7 +161,13 @@ namespace owds {

if(urdf_link.collision)
{
// collision_shape = convertShape(material, *urdf_link.collision->geometry); // TODO
auto& origin = urdf_link.collision->origin;
glm::vec3 position = ToV3({(float)origin.position.x, (float)origin.position.y, (float)origin.position.z});
glm::quat rotation = ToQT({(float)origin.rotation.x, (float)origin.rotation.y, (float)origin.rotation.z, (float)origin.rotation.w});
glm::mat4 translate = glm::translate(glm::mat4(1), position);
glm::mat4 rotate = glm::mat4_cast(rotation);
glm::mat4 transform = translate * rotate;
collision_shape = convertShape(material, *urdf_link.collision->geometry, transform); // TODO
}

assert(urdf_link.collision_array.size() <= 1 && "Links with multiple collision shapes are not supported at this moment.");
Expand Down
12 changes: 6 additions & 6 deletions src/Physics/Bullet3/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace owds::bullet3 {
{
std::visit([this](auto& elem) { setupPhysicsShape(elem); }, collision_shape_);

if(!bt_geometry_)
if(bt_geometry_ == nullptr)
{
return;
}
Expand Down Expand Up @@ -104,7 +104,7 @@ namespace owds::bullet3 {
{
assert(bt_actor_);

(void) coefficient; // todo: uhhhh...
(void)coefficient; // todo: uhhhh...
}

void Actor::setRestitution(const float coefficient)
Expand All @@ -114,11 +114,11 @@ namespace owds::bullet3 {
bt_actor_->setRestitution(coefficient);
}

void Actor::setPositionAndOrientation(const std::array<float, 3>& position, const std::array<float, 3>& orientation)
void Actor::setPositionAndOrientation(const std::array<float, 3>& position, const std::array<float, 4>& orientation)
{
assert(bt_actor_);

const auto orientation_quat = glm::quat(owds::BitCast<glm::vec3>(orientation));
const auto orientation_quat = glm::quat(owds::BitCast<glm::vec4>(orientation));
const auto bt_transform = btTransform(
btQuaternion(
static_cast<btScalar>(orientation_quat.x),
Expand Down Expand Up @@ -182,7 +182,7 @@ namespace owds::bullet3 {

void Actor::setupPhysicsShape(const owds::ShapeCustomMesh& shape)
{
(void) shape; // todo: handle custom meshes
(void)shape; // todo: handle custom meshes
}

void Actor::setupPhysicsShape(const owds::ShapeCylinder& shape)
Expand All @@ -195,7 +195,7 @@ namespace owds::bullet3 {

void Actor::setupPhysicsShape(const owds::ShapeDummy& shape)
{
(void) shape;
(void)shape;
}

void Actor::setupPhysicsShape(const owds::ShapeSphere& shape)
Expand Down
43 changes: 22 additions & 21 deletions src/Physics/Bullet3/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "overworld/Engine/Common/Shapes/Shape.h"
#include "overworld/Engine/Common/Urdf/JointLocation.h"
#include "overworld/Helper/GlmMath.h"
#include "overworld/Physics/Bullet3/Actor.h"
#include "overworld/Physics/Bullet3/Context.h"
#include "overworld/Physics/Bullet3/Joints/JointPrismatic.h"
Expand Down Expand Up @@ -42,14 +43,14 @@ namespace owds::bullet3 {
owds::JointRevolute& World::createJointRevolute(
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation)
const std::array<float, 4>& joint_orientation)
{
(void)parent;
(void)origin_position;
(void)origin_position;
(void)origin_orientation;
(void)child;
(void)joint_position;
(void)joint_orientation;
Expand All @@ -59,14 +60,14 @@ namespace owds::bullet3 {
owds::JointContinuous& World::createJointContinuous(
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation)
const std::array<float, 4>& joint_orientation)
{
(void)parent;
(void)origin_position;
(void)origin_position;
(void)origin_orientation;
(void)child;
(void)joint_position;
(void)joint_orientation;
Expand All @@ -76,20 +77,20 @@ namespace owds::bullet3 {
owds::JointPrismatic& World::createJointPrismatic(
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation)
const std::array<float, 4>& joint_orientation)
{
auto joint = std::make_unique<owds::bullet3::JointPrismatic>(
*ctx_,
owds::JointLocation(
parent,
origin_position,
origin_position,
ToV3(origin_position),
ToQT(origin_orientation),
child,
joint_position,
joint_orientation));
ToV3(joint_position),
ToQT(joint_orientation)));

joint->setup();

Expand All @@ -100,14 +101,14 @@ namespace owds::bullet3 {
owds::JointFixed& World::createJointFixed(
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation)
const std::array<float, 4>& joint_orientation)
{
(void)parent;
(void)origin_position;
(void)origin_position;
(void)origin_orientation;
(void)child;
(void)joint_position;
(void)joint_orientation;
Expand All @@ -117,14 +118,14 @@ namespace owds::bullet3 {
owds::JointFloating& World::createJointFloating(
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation)
const std::array<float, 4>& joint_orientation)
{
(void)parent;
(void)origin_position;
(void)origin_position;
(void)origin_orientation;
(void)child;
(void)joint_position;
(void)joint_orientation;
Expand All @@ -134,14 +135,14 @@ namespace owds::bullet3 {
owds::JointPlanar& World::createJointPlanar(
owds::Actor& parent,
const std::array<float, 3>& origin_position,
const std::array<float, 3>& origin_position,
const std::array<float, 4>& origin_orientation,
owds::Actor& child,
const std::array<float, 3>& joint_position,
const std::array<float, 3>& joint_orientation)
const std::array<float, 4>& joint_orientation)
{
(void)parent;
(void)origin_position;
(void)origin_position;
(void)origin_orientation;
(void)child;
(void)joint_position;
(void)joint_orientation;
Expand Down

0 comments on commit 945c77f

Please sign in to comment.