Removed vtable from Poseable
This removes the offset created by the vtable (8 bytes). This means that pure Poseables are now tightly ;3 packed.
This commit is contained in:
parent
2bdc165572
commit
1d19d370cb
@ -46,9 +46,6 @@ Application::Application(int width, int height)
|
||||
m_fps.prepare();
|
||||
}
|
||||
|
||||
|
||||
Application::~Application() {}
|
||||
|
||||
int Application::run()
|
||||
{
|
||||
try
|
||||
|
@ -15,7 +15,7 @@ class Application
|
||||
{
|
||||
public:
|
||||
Application(int width = -1, int height = -1);
|
||||
virtual ~Application();
|
||||
virtual ~Application() {}
|
||||
|
||||
int run();
|
||||
|
||||
|
@ -24,7 +24,6 @@ void Camera2D::update_position(const vec3& position)
|
||||
Poseable::update_position(-position);
|
||||
}
|
||||
|
||||
// TODO: Inline?
|
||||
void Camera2D::translate(const vec2& position)
|
||||
{
|
||||
translate(vec3(position.x, position.y, 0.0f));
|
||||
|
@ -13,10 +13,10 @@ public:
|
||||
Camera2D(const vec3& size = vec3(2.0f, 2.0f, 2.0f), const vec3& position = vec3(0.0f, 0.0f, 0.0f));
|
||||
|
||||
void update_size(const vec3& size);
|
||||
void update_position(const vec3& position) override;
|
||||
void update_position(const vec3& position);
|
||||
|
||||
void translate(const vec2& translation);
|
||||
void translate(const vec3& translation) override;
|
||||
void translate(const vec3& translation);
|
||||
|
||||
const vec3& get_size() const { return m_size; }
|
||||
const vec3& get_position() const { return m_position; }
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
void update_frustum(float fov_y, float aspect_ratio, float znear, float zfar);
|
||||
|
||||
void translate(const vec3& translation) override;
|
||||
void translate(const vec3& translation);
|
||||
|
||||
const vec3& get_position() const { return m_position; }
|
||||
vec3 get_forward() const { return vec3(m_orientation_matrix[2]); }
|
||||
|
@ -11,6 +11,7 @@ class MyApplication :
|
||||
public:
|
||||
MyApplication(int width = -1, int height = -1);
|
||||
|
||||
protected:
|
||||
void init() override;
|
||||
|
||||
void update(float delta_time, clock_t clock) override;
|
||||
|
@ -22,13 +22,10 @@ void MyBatch::setup_vao()
|
||||
glEnableVertexAttribArray(3);
|
||||
glEnableVertexAttribArray(4);
|
||||
glEnableVertexAttribArray(5);
|
||||
|
||||
int orientation_location = offsetof(Poseable, m_orientation_matrix);
|
||||
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 0 * sizeof(vec4)));
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 1 * sizeof(vec4)));
|
||||
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 2 * sizeof(vec4)));
|
||||
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 3 * sizeof(vec4)));
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(0 * sizeof(vec4)));
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(1 * sizeof(vec4)));
|
||||
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(2 * sizeof(vec4)));
|
||||
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(3 * sizeof(vec4)));
|
||||
|
||||
glVertexAttribDivisor(0, 0); // Only need to send the mesh data once (This should probably be done every time)
|
||||
glVertexAttribDivisor(1, 1); // Send the color data for each instance drawn
|
||||
|
@ -15,15 +15,15 @@ public:
|
||||
const vec3& right = vec3(1.0f, 0.0f, 0.0f)
|
||||
);
|
||||
|
||||
virtual void update_position(const vec3& position);
|
||||
void update_position(const vec3& position);
|
||||
// Assumes that forward, up, and right are orthogonal and normalized
|
||||
virtual void update_orientation(const vec3& forward, const vec3& up, const vec3& right);
|
||||
void update_orientation(const vec3& forward, const vec3& up, const vec3& right);
|
||||
|
||||
virtual void translate(const vec3& translation);
|
||||
virtual void rotate(const vec3& axis, float angle);
|
||||
void translate(const vec3& translation);
|
||||
void rotate(const vec3& axis, float angle);
|
||||
|
||||
const mat4& get_orientation_matrix() const { return m_orientation_matrix; }
|
||||
|
||||
// Please dont use this. If you see it, tell michael that he is bad
|
||||
protected:
|
||||
mat4 m_orientation_matrix;
|
||||
};
|
Loading…
Reference in New Issue
Block a user