Change function naming in object class to better match the naming convention
This commit is contained in:
parent
0959517d08
commit
6a47a796b9
@ -39,8 +39,11 @@ namespace egn{
|
||||
math::vec3<GLfloat> m_position; //track current positon in world space
|
||||
math::quaternion<GLfloat> m_orientation; //track current model space rotation
|
||||
math::vec3<GLfloat> m_scale{1.0f, 1.0f, 1.0f}; //track model space scale
|
||||
private:
|
||||
mutable math::mat4<GLfloat> m_model_matrix; //compile all the above info into a matrix
|
||||
protected:
|
||||
mutable int m_update_flag = NO_UPDATE; //whether or not to update the matrix upon access
|
||||
//make the update flag protected so subclasses can share it
|
||||
|
||||
public:
|
||||
object_base() = default;
|
||||
@ -62,10 +65,10 @@ namespace egn{
|
||||
virtual void set_orientation(const math::quaternion<GLfloat>& orient);
|
||||
virtual void set_scale(const math::vec3<GLfloat>& scale);
|
||||
|
||||
const math::mat4<GLfloat>& get_model_matrix()const;
|
||||
const math::vec3<GLfloat>& get_position()const;
|
||||
const math::vec3<GLfloat>& get_scale()const;
|
||||
const math::quaternion<GLfloat>& get_orientation()const;
|
||||
const math::mat4<GLfloat>& model_matrix()const;
|
||||
const math::vec3<GLfloat>& position()const;
|
||||
const math::vec3<GLfloat>& scale()const;
|
||||
const math::quaternion<GLfloat>& orientation()const;
|
||||
|
||||
protected:
|
||||
void recalc_model_matrix()const;
|
||||
@ -75,6 +78,7 @@ namespace egn{
|
||||
{
|
||||
protected:
|
||||
aabb m_model_bounding_box; //model coordinate bounding volume
|
||||
private:
|
||||
mutable aabb m_world_bounding_box; //world coordinate bounding volume
|
||||
public:
|
||||
using object_base::object_base;
|
||||
@ -97,6 +101,7 @@ namespace egn{
|
||||
{
|
||||
protected:
|
||||
aabs m_model_bounding_sphere; //model coordinate bounding volume
|
||||
private:
|
||||
mutable aabs m_world_bounding_sphere; //world coordinate bounding volume
|
||||
public:
|
||||
using object_base::object_base;
|
||||
|
||||
@ -59,20 +59,20 @@ namespace egn{
|
||||
m_update_flag |= (SCALE_UPDATE | BOUNDING_VOLUME_UPDATE);
|
||||
m_scale = scale;
|
||||
}
|
||||
const math::mat4<GLfloat>& object_base::get_model_matrix()const{
|
||||
const math::mat4<GLfloat>& object_base::model_matrix()const{
|
||||
if(m_update_flag & (SCALE_UPDATE | ROTATION_UPDATE | TRANSLATION_UPDATE)){
|
||||
recalc_model_matrix();
|
||||
m_update_flag &= (~(SCALE_UPDATE | ROTATION_UPDATE | TRANSLATION_UPDATE));
|
||||
}
|
||||
return m_model_matrix;
|
||||
}
|
||||
const math::vec3<GLfloat>& object_base::get_position()const{
|
||||
const math::vec3<GLfloat>& object_base::position()const{
|
||||
return m_position;
|
||||
}
|
||||
const math::vec3<GLfloat>& object_base::get_scale()const{
|
||||
const math::vec3<GLfloat>& object_base::scale()const{
|
||||
return m_scale;
|
||||
}
|
||||
const math::quaternion<GLfloat>& object_base::get_orientation()const{
|
||||
const math::quaternion<GLfloat>& object_base::orientation()const{
|
||||
return m_orientation;
|
||||
}
|
||||
|
||||
@ -99,9 +99,9 @@ namespace egn{
|
||||
}
|
||||
const aabb& aabb_object::get_bounding_box()const{
|
||||
if(m_update_flag){
|
||||
recalc_model_matrix();
|
||||
m_world_bounding_box.point1 = m_model_matrix * math::vec4<float>(m_model_bounding_box.point1, 1.0f);
|
||||
m_world_bounding_box.point2 = m_model_matrix * math::vec4<float>(m_model_bounding_box.point2, 1.0f);
|
||||
const auto& model_mat = model_matrix();
|
||||
m_world_bounding_box.point1 = model_mat * math::vec4<float>(m_model_bounding_box.point1, 1.0f);
|
||||
m_world_bounding_box.point2 = model_mat * math::vec4<float>(m_model_bounding_box.point2, 1.0f);
|
||||
m_update_flag &= ~BOUNDING_VOLUME_UPDATE;
|
||||
}
|
||||
return m_world_bounding_box;
|
||||
|
||||
@ -97,7 +97,7 @@ void play_state::handle_input(const egn::input_event& ev){
|
||||
|
||||
for(size_t i = 0;i < m_scene.renderables.size();++i){
|
||||
square& sq = static_cast<square&>(*m_scene.renderables[i]);
|
||||
const math::vec3<GLfloat>& sq_pos = sq.get_position();
|
||||
const math::vec3<GLfloat>& sq_pos = sq.position();
|
||||
if((projected1.x() > (sq_pos.x() - 1.0f) && projected1.x() < (sq_pos.x() + 1.0f)) &&
|
||||
(projected1.y() > (sq_pos.y() - 1.0f) && projected1.y() < (sq_pos.y() + 1.0f)))
|
||||
{
|
||||
|
||||
@ -50,7 +50,7 @@ void square::set_color(const math::vec4<float>& color){
|
||||
}
|
||||
|
||||
void square::render(gfx::shader_program& shader){
|
||||
shader.set_uniform("model_mat", get_model_matrix());
|
||||
shader.set_uniform("model_mat", model_matrix());
|
||||
shader.set_uniform("model_color", m_color_filter);
|
||||
shader.set_uniform("texture1", *m_model->mesh(0).material().get_material((int)m_active_value));
|
||||
m_model->mesh(0).vertex().render(shader);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user