Skip to content

Commit

Permalink
Use EigenAlignedVec for RenderableObjectState
Browse files Browse the repository at this point in the history
  • Loading branch information
schornakj committed Jul 7, 2020
1 parent dc60696 commit f5b6df9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
5 changes: 2 additions & 3 deletions include/gl_depth_sim/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ namespace gl_depth_sim
template <typename T>
using EigenAlignedVec = std::vector<T, Eigen::aligned_allocator<T>>;


class Mesh
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

Mesh(const EigenAlignedVec<Eigen::Vector3f>& vertices, const std::vector<unsigned>& indices);

std::size_t numIndices() const { return indices_.size(); }
Expand All @@ -24,6 +21,8 @@ class Mesh
const std::vector<unsigned>& indices() const { return indices_; }
const EigenAlignedVec<Eigen::Vector3f>& vertices() const { return vertices_; }

EIGEN_MAKE_ALIGNED_OPERATOR_NEW

private:
EigenAlignedVec<Eigen::Vector3f> vertices_;
std::vector<unsigned> indices_;
Expand Down
4 changes: 2 additions & 2 deletions include/gl_depth_sim/shader_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ namespace gl_depth_sim
class ShaderProgram
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

ShaderProgram(const std::string& vertex_shader, const std::string& frag_shader);
~ShaderProgram();

Expand All @@ -21,6 +19,8 @@ class ShaderProgram
void setInt(const std::string& attr, int val);
void setUniformMat4(const std::string &attr, const Eigen::Matrix4f& mat);

EIGEN_MAKE_ALIGNED_OPERATOR_NEW

private:
unsigned int id_;
};
Expand Down
18 changes: 11 additions & 7 deletions include/gl_depth_sim/sim_depth_camera.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef GL_DEPTH_SIM_SIM_DEPTH_CAMERA_H
#define GL_DEPTH_SIM_SIM_DEPTH_CAMERA_H

#include "gl_depth_sim/camera_properties.h"
#include "gl_depth_sim/glfw_guard.h"
#include "gl_depth_sim/renderable_mesh.h"
#include "gl_depth_sim/shader_program.h"
#include <gl_depth_sim/camera_properties.h>
#include <gl_depth_sim/glfw_guard.h>
#include <gl_depth_sim/renderable_mesh.h>
#include <gl_depth_sim/shader_program.h>

#include <Eigen/Core>

#include <memory>
#include <vector>
Expand All @@ -16,6 +18,9 @@ struct GLFWwindow;
namespace gl_depth_sim
{

template <typename T>
using EigenAlignedVec = std::vector<T, Eigen::aligned_allocator<T>>;

/**
* @brief Utility data structure used internally by @class SimDepthCamera
*/
Expand All @@ -39,6 +44,8 @@ struct RenderableObjectState
class SimDepthCamera
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

/**
* @brief Creates an OpenGL context and window using the given camera parameters. Only one of these should be created
* at a time.
Expand Down Expand Up @@ -83,9 +90,6 @@ class SimDepthCamera
GLFWwindow* window_;
std::unique_ptr<ShaderProgram> depth_program_;
unsigned int fbo_;

public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

}
Expand Down
4 changes: 2 additions & 2 deletions src/gl_depth_sim/sim_depth_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static Eigen::Matrix4d createProjectionMatrix(const gl_depth_sim::CameraProperti
}

gl_depth_sim::SimDepthCamera::SimDepthCamera(const gl_depth_sim::CameraProperties& camera)
: camera_{camera}
, proj_{createProjectionMatrix(camera)}
: camera_(camera)
, proj_(createProjectionMatrix(camera))
{
// Load GLFW and OpenGL libraries; create window; create extensions
initGLFW();
Expand Down

0 comments on commit f5b6df9

Please sign in to comment.