Skip to content

Commit

Permalink
v2d & aabbox3d<f32> & sky cleanups
Browse files Browse the repository at this point in the history
* Sky: rename Box => m_box and inline getBoundingBox
* Uniformize aabbox3d<f32> to aabb3f
  • Loading branch information
nerzhul authored and est31 committed Feb 11, 2016
1 parent 24b312c commit fefa148
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/client.cpp
Expand Up @@ -1471,13 +1471,13 @@ ClientActiveObject * Client::getSelectedActiveObject(
{
ClientActiveObject *obj = objects[i].obj;

core::aabbox3d<f32> *selection_box = obj->getSelectionBox();
aabb3f *selection_box = obj->getSelectionBox();
if(selection_box == NULL)
continue;

v3f pos = obj->getPosition();

core::aabbox3d<f32> offsetted_box(
aabb3f offsetted_box(
selection_box->MinEdge + pos,
selection_box->MaxEdge + pos
);
Expand Down
1 change: 0 additions & 1 deletion src/client/tile.h
Expand Up @@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define TILE_HEADER

#include "irrlichttypes.h"
#include "irr_v2d.h"
#include "irr_v3d.h"
#include <ITexture.h>
#include <IrrlichtDevice.h>
Expand Down
2 changes: 1 addition & 1 deletion src/clientmap.cpp
Expand Up @@ -50,7 +50,7 @@ ClientMap::ClientMap(
m_camera_direction(0,0,1),
m_camera_fov(M_PI)
{
m_box = core::aabbox3d<f32>(-BS*1000000,-BS*1000000,-BS*1000000,
m_box = aabb3f(-BS*1000000,-BS*1000000,-BS*1000000,
BS*1000000,BS*1000000,BS*1000000);

/* TODO: Add a callback function so these can be updated when a setting
Expand Down
4 changes: 2 additions & 2 deletions src/clientmap.h
Expand Up @@ -115,7 +115,7 @@ class ClientMap : public Map, public scene::ISceneNode
renderMap(driver, SceneManager->getSceneNodeRenderPass());
}

virtual const core::aabbox3d<f32>& getBoundingBox() const
virtual const aabb3f &getBoundingBox() const
{
return m_box;
}
Expand All @@ -140,7 +140,7 @@ class ClientMap : public Map, public scene::ISceneNode
private:
Client *m_client;

core::aabbox3d<f32> m_box;
aabb3f m_box;

MapDrawControl &m_control;

Expand Down
2 changes: 1 addition & 1 deletion src/clientobject.h
Expand Up @@ -56,7 +56,7 @@ class ClientActiveObject : public ActiveObject
virtual void updateLight(u8 light_at_pos){}
virtual void updateLightNoCheck(u8 light_at_pos){}
virtual v3s16 getLightPosition(){return v3s16(0,0,0);}
virtual core::aabbox3d<f32>* getSelectionBox(){return NULL;}
virtual aabb3f *getSelectionBox() { return NULL; }
virtual bool getCollisionBox(aabb3f *toset){return false;}
virtual bool collideWithObjects(){return false;}
virtual v3f getPosition(){return v3f(0,0,0);}
Expand Down
2 changes: 1 addition & 1 deletion src/clouds.cpp
Expand Up @@ -62,7 +62,7 @@ Clouds::Clouds(
g_settings->registerChangedCallback("enable_3d_clouds",
&cloud_3d_setting_changed, this);

m_box = core::aabbox3d<f32>(-BS*1000000,m_cloud_y-BS,-BS*1000000,
m_box = aabb3f(-BS*1000000,m_cloud_y-BS,-BS*1000000,
BS*1000000,m_cloud_y+BS,BS*1000000);

}
Expand Down
6 changes: 3 additions & 3 deletions src/clouds.h
Expand Up @@ -53,7 +53,7 @@ class Clouds : public scene::ISceneNode

virtual void render();

virtual const core::aabbox3d<f32>& getBoundingBox() const
virtual const aabb3f &getBoundingBox() const
{
return m_box;
}
Expand All @@ -79,15 +79,15 @@ class Clouds : public scene::ISceneNode
void updateCameraOffset(v3s16 camera_offset)
{
m_camera_offset = camera_offset;
m_box = core::aabbox3d<f32>(-BS * 1000000, m_cloud_y - BS - BS * camera_offset.Y, -BS * 1000000,
m_box = aabb3f(-BS * 1000000, m_cloud_y - BS - BS * camera_offset.Y, -BS * 1000000,
BS * 1000000, m_cloud_y + BS - BS * camera_offset.Y, BS * 1000000);
}

void readSettings();

private:
video::SMaterial m_material;
core::aabbox3d<f32> m_box;
aabb3f m_box;
s16 m_passed_cloud_y;
float m_cloud_y;
u16 m_cloud_radius_i;
Expand Down
8 changes: 4 additions & 4 deletions src/content_cao.cpp
Expand Up @@ -309,7 +309,7 @@ class ItemCAO : public ClientActiveObject

void initialize(const std::string &data);

core::aabbox3d<f32>* getSelectionBox()
aabb3f *getSelectionBox()
{return &m_selection_box;}
v3f getPosition()
{return m_position;}
Expand All @@ -319,7 +319,7 @@ class ItemCAO : public ClientActiveObject

bool getCollisionBox(aabb3f *toset) { return false; }
private:
core::aabbox3d<f32> m_selection_box;
aabb3f m_selection_box;
scene::IMeshSceneNode *m_node;
v3f m_position;
std::string m_itemstring;
Expand Down Expand Up @@ -674,7 +674,7 @@ GenericCAO::~GenericCAO()
removeFromScene(true);
}

core::aabbox3d<f32>* GenericCAO::getSelectionBox()
aabb3f *GenericCAO::getSelectionBox()
{
if(!m_prop.is_visible || !m_is_visible || m_is_local_player || getParent() != NULL)
return NULL;
Expand Down Expand Up @@ -1185,7 +1185,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)

if(m_prop.physical)
{
core::aabbox3d<f32> box = m_prop.collisionbox;
aabb3f box = m_prop.collisionbox;
box.MinEdge *= BS;
box.MaxEdge *= BS;
collisionMoveResult moveresult;
Expand Down
4 changes: 2 additions & 2 deletions src/content_cao.h
Expand Up @@ -65,7 +65,7 @@ class GenericCAO : public ClientActiveObject
//
scene::ISceneManager *m_smgr;
IrrlichtDevice *m_irr;
core::aabbox3d<f32> m_selection_box;
aabb3f m_selection_box;
scene::IMeshSceneNode *m_meshnode;
scene::IAnimatedMeshSceneNode *m_animated_meshnode;
WieldMeshSceneNode *m_wield_meshnode;
Expand Down Expand Up @@ -127,7 +127,7 @@ class GenericCAO : public ClientActiveObject

bool collideWithObjects();

core::aabbox3d<f32>* getSelectionBox();
aabb3f *getSelectionBox();

v3f getPosition();

Expand Down
4 changes: 2 additions & 2 deletions src/content_sao.cpp
Expand Up @@ -259,7 +259,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
else
{
if(m_prop.physical){
core::aabbox3d<f32> box = m_prop.collisionbox;
aabb3f box = m_prop.collisionbox;
box.MinEdge *= BS;
box.MaxEdge *= BS;
collisionMoveResult moveresult;
Expand Down Expand Up @@ -786,7 +786,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
m_prop.hp_max = PLAYER_MAX_HP;
m_prop.physical = false;
m_prop.weight = 75;
m_prop.collisionbox = core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
m_prop.collisionbox = aabb3f(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
// start of default appearance, this should be overwritten by LUA
m_prop.visual = "upright_sprite";
m_prop.visual_size = v2f(1, 2);
Expand Down
6 changes: 3 additions & 3 deletions src/mesh.cpp
Expand Up @@ -104,7 +104,7 @@ void scaleMesh(scene::IMesh *mesh, v3f scale)
if (mesh == NULL)
return;

core::aabbox3d<f32> bbox;
aabb3f bbox;
bbox.reset(0, 0, 0);

u32 mc = mesh->getMeshBufferCount();
Expand Down Expand Up @@ -132,7 +132,7 @@ void translateMesh(scene::IMesh *mesh, v3f vec)
if (mesh == NULL)
return;

core::aabbox3d<f32> bbox;
aabb3f bbox;
bbox.reset(0, 0, 0);

u32 mc = mesh->getMeshBufferCount();
Expand Down Expand Up @@ -346,7 +346,7 @@ void rotateMeshBy6dFacedir(scene::IMesh *mesh, int facedir)

void recalculateBoundingBox(scene::IMesh *src_mesh)
{
core::aabbox3d<f32> bbox;
aabb3f bbox;
bbox.reset(0,0,0);
for (u16 j = 0; j < src_mesh->getMeshBufferCount(); j++) {
scene::IMeshBuffer *buf = src_mesh->getMeshBuffer(j);
Expand Down
2 changes: 1 addition & 1 deletion src/object_properties.h
Expand Up @@ -33,7 +33,7 @@ struct ObjectProperties
bool physical;
bool collideWithObjects;
float weight;
core::aabbox3d<f32> collisionbox;
aabb3f collisionbox;
std::string visual;
std::string mesh;
v2f visual_size;
Expand Down
4 changes: 2 additions & 2 deletions src/particles.cpp
Expand Up @@ -88,7 +88,7 @@ Particle::Particle(
m_vertical = vertical;

// Irrlicht stuff
m_collisionbox = core::aabbox3d<f32>
m_collisionbox = aabb3f
(-size/2,-size/2,-size/2,size/2,size/2,size/2);
this->setAutomaticCulling(scene::EAC_OFF);

Expand Down Expand Up @@ -128,7 +128,7 @@ void Particle::step(float dtime)
m_time += dtime;
if (m_collisiondetection)
{
core::aabbox3d<f32> box = m_collisionbox;
aabb3f box = m_collisionbox;
v3f p_pos = m_pos*BS;
v3f p_velocity = m_velocity*BS;
collisionMoveSimple(m_env, m_gamedef,
Expand Down
6 changes: 3 additions & 3 deletions src/particles.h
Expand Up @@ -52,7 +52,7 @@ class Particle : public scene::ISceneNode
);
~Particle();

virtual const core::aabbox3d<f32>& getBoundingBox() const
virtual const aabb3f &getBoundingBox() const
{
return m_box;
}
Expand Down Expand Up @@ -85,8 +85,8 @@ class Particle : public scene::ISceneNode

ClientEnvironment *m_env;
IGameDef *m_gamedef;
core::aabbox3d<f32> m_box;
core::aabbox3d<f32> m_collisionbox;
aabb3f m_box;
aabb3f m_collisionbox;
video::SMaterial m_material;
v2f m_texpos;
v2f m_texsize;
Expand Down
4 changes: 2 additions & 2 deletions src/player.h
Expand Up @@ -198,7 +198,7 @@ class Player
return m_name;
}

core::aabbox3d<f32> getCollisionbox()
aabb3f getCollisionbox()
{
return m_collisionbox;
}
Expand Down Expand Up @@ -398,7 +398,7 @@ class Player
f32 m_yaw;
v3f m_speed;
v3f m_position;
core::aabbox3d<f32> m_collisionbox;
aabb3f m_collisionbox;

bool m_dirty;

Expand Down
1 change: 1 addition & 0 deletions src/script/lua_api/l_areastore.cpp
Expand Up @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_internal.h"
#include "common/c_converter.h"
#include "cpp_api/s_security.h"
#include "irr_v3d.h"
#include "areastore.h"
#include "filesys.h"
#ifndef ANDROID
Expand Down
1 change: 0 additions & 1 deletion src/script/lua_api/l_areastore.h
Expand Up @@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define L_AREASTORE_H_

#include "lua_api/l_base.h"
#include "irr_v3d.h"
#include "areastore.h"

/*
Expand Down
9 changes: 2 additions & 7 deletions src/sky.cpp
Expand Up @@ -25,8 +25,8 @@ Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
m_cloudcolor_bright_f(1,1,1,1)
{
setAutomaticCulling(scene::EAC_OFF);
Box.MaxEdge.set(0,0,0);
Box.MinEdge.set(0,0,0);
m_box.MaxEdge.set(0,0,0);
m_box.MinEdge.set(0,0,0);

// create material

Expand Down Expand Up @@ -94,11 +94,6 @@ void Sky::OnRegisterSceneNode()
scene::ISceneNode::OnRegisterSceneNode();
}

const core::aabbox3d<f32>& Sky::getBoundingBox() const
{
return Box;
}

//! renders the node.
void Sky::render()
{
Expand Down
5 changes: 3 additions & 2 deletions src/sky.h
Expand Up @@ -42,7 +42,8 @@ class Sky : public scene::ISceneNode
//! renders the node.
virtual void render();

virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual const aabb3f &getBoundingBox() const
{ return m_box; }

// Used by Irrlicht for optimizing rendering
virtual video::SMaterial& getMaterial(u32 i)
Expand Down Expand Up @@ -74,7 +75,7 @@ class Sky : public scene::ISceneNode
}

private:
core::aabbox3d<f32> Box;
aabb3f m_box;
video::SMaterial m_materials[SKY_MATERIAL_COUNT];

// How much sun & moon transition should affect horizon color
Expand Down
4 changes: 2 additions & 2 deletions src/util/numeric.h
Expand Up @@ -310,9 +310,9 @@ inline v3f intToFloat(v3s16 p, f32 d)
}

// Random helper. Usually d=BS
inline core::aabbox3d<f32> getNodeBox(v3s16 p, float d)
inline aabb3f getNodeBox(v3s16 p, float d)
{
return core::aabbox3d<f32>(
return aabb3f(
(float)p.X * d - 0.5*d,
(float)p.Y * d - 0.5*d,
(float)p.Z * d - 0.5*d,
Expand Down
4 changes: 2 additions & 2 deletions src/wieldmesh.h
Expand Up @@ -53,7 +53,7 @@ class WieldMeshSceneNode: public scene::ISceneNode

virtual void render();

virtual const core::aabbox3d<f32>& getBoundingBox() const
virtual const aabb3f &getBoundingBox() const
{ return m_bounding_box; }

private:
Expand All @@ -74,7 +74,7 @@ class WieldMeshSceneNode: public scene::ISceneNode
// Bounding box culling is disabled for this type of scene node,
// so this variable is just required so we can implement
// getBoundingBox() and is set to an empty box.
core::aabbox3d<f32> m_bounding_box;
aabb3f m_bounding_box;
};

scene::IMesh *getItemMesh(IGameDef *gamedef, const ItemStack &item);
Expand Down

0 comments on commit fefa148

Please sign in to comment.