Rename egn::object_base to egn::object

This commit is contained in:
2022-02-18 18:14:09 -08:00
parent f40559f543
commit 621bf0349a
7 changed files with 29 additions and 29 deletions

View File

@@ -27,7 +27,7 @@ namespace egn{
//Virtual base for camera types
//Provides general object functionality as well as projection and view matrices.
//Derived classes must provide method of recalculating the projection matrix.
class camera_iface : public object_base
class camera_iface : public object
{
protected:
enum update{

View File

@@ -24,7 +24,7 @@
namespace egn{
class object_base
class object
{
protected:
enum update{
@@ -45,15 +45,15 @@ namespace egn{
//make the update flag protected so subclasses can share it
public:
object_base(void) = default;
explicit object_base(const math::vec3f& position);
object_base(const math::vec3f& position, const math::quat_f& orientation);
object_base(const object_base&) = default;
object_base(object_base&&) = default;
virtual ~object_base(void) = default;
object(void) = default;
explicit object(const math::vec3f& position);
object(const math::vec3f& position, const math::quat_f& orientation);
object(const object&) = default;
object(object&&) = default;
virtual ~object(void) = default;
object_base& operator=(const object_base&) = default;
object_base& operator=(object_base&&) = default;
object& operator=(const object&) = default;
object& operator=(object&&) = default;
void translate(const math::vec3f& distance);
void rotate(const math::quat_f& distance);

View File

@@ -30,6 +30,6 @@ public:
virtual void render(gfx::ogl::shader_program&) = 0;
};
class renderable_object : public renderable_iface, public egn::object_base{};
class renderable_object : public renderable_iface, public egn::object{};
#endif

View File

@@ -29,7 +29,7 @@
struct scene {
std::vector<renderable_iface*> renderables;
std::vector<std::unique_ptr<egn::object_base>> objects;
std::vector<std::unique_ptr<egn::object>> objects;
std::vector<std::unique_ptr<egn::camera_iface>> cameras;
};

View File

@@ -88,7 +88,7 @@ public:
};
#endif
class tile : public egn::object_base
class tile : public egn::object
{
public:
enum class value{

View File

@@ -27,11 +27,11 @@ namespace egn{
m_near(n), m_far(f){}
void camera_iface::set_position(const math::vec3f& pos){
object_base::set_position(pos);
object::set_position(pos);
m_update_flag |= VIEW_UPDATE;
}
void camera_iface::set_orientation(const math::quat_f& orient){
object_base::set_orientation(orient);
object::set_orientation(orient);
m_update_flag |= VIEW_UPDATE;
}
const math::mat4f& camera_iface::get_projection_matrix(void)const{

View File

@@ -21,24 +21,24 @@
namespace egn{
object_base::object_base(const math::vec3f& position):
object::object(const math::vec3f& position):
m_position(position){}
object_base::object_base(const math::vec3f& position, const math::quat_f& orientation):
object::object(const math::vec3f& position, const math::quat_f& orientation):
m_position(position),
m_orientation(orientation){}
void object_base::translate(const math::vec3f& distance){
void object::translate(const math::vec3f& distance){
set_position(m_position + distance);
}
void object_base::rotate(const math::quat_f& distance){
void object::rotate(const math::quat_f& distance){
set_orientation(m_orientation * distance);
}
void object_base::scale(const math::vec3f& distance){
void object::scale(const math::vec3f& distance){
set_scale(math::vec3f{m_scale[0] * distance[0],
m_scale[1] * distance[1],
m_scale[2] * distance[2]});
}
void object_base::look_at(const math::vec3f& targ, const math::vec3f& up){
void object::look_at(const math::vec3f& targ, const math::vec3f& up){
math::vec3f front((m_position - targ).normalize());
math::vec3f right(math::cross(up, front));
math::vec3f true_up(math::cross(front, right));
@@ -46,36 +46,36 @@ namespace egn{
right[1], true_up[1], front[1],
right[2], true_up[2], front[2]}});
}
void object_base::set_position(const math::vec3f& pos){
void object::set_position(const math::vec3f& pos){
m_update_flag |= (TRANSLATION_UPDATE | BOUNDING_VOLUME_UPDATE);
m_position = pos;
}
void object_base::set_orientation(const math::quat_f& orient){
void object::set_orientation(const math::quat_f& orient){
m_update_flag |= (ROTATION_UPDATE | BOUNDING_VOLUME_UPDATE);
m_orientation = orient;
}
void object_base::set_scale(const math::vec3f& scale){
void object::set_scale(const math::vec3f& scale){
m_update_flag |= (SCALE_UPDATE | BOUNDING_VOLUME_UPDATE);
m_scale = scale;
}
const math::mat4f& object_base::model_matrix(void)const{
const math::mat4f& object::model_matrix(void)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::vec3f& object_base::position(void)const{
const math::vec3f& object::position(void)const{
return m_position;
}
const math::vec3f& object_base::scale(void)const{
const math::vec3f& object::scale(void)const{
return m_scale;
}
const math::quat_f& object_base::orientation(void)const{
const math::quat_f& object::orientation(void)const{
return m_orientation;
}
void object_base::recalc_model_matrix(void)const{
void object::recalc_model_matrix(void)const{
debug_print_verbose("Rebuilding model matrix\n");
m_model_matrix = m_orientation.to_mat4();
m_model_matrix.get(3, 0) = m_position[0];