moving across to glm::vec3

moving across to glm::vec3 this one took a while!
This commit is contained in:
Alister
2021-11-14 16:46:57 +00:00
parent f5b9db2800
commit eb9b0c5c50
129 changed files with 1103 additions and 1084 deletions

View File

@@ -1,24 +1,34 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <glm/common.hpp>
#include <math/bounding_box.hpp>
namespace
{
math::vector_3d min_per_dimension(std::vector<math::vector_3d> const& points)
glm::vec3 min_per_dimension(std::vector<glm::vec3> const& points)
{
auto min(math::vector_3d::max());
auto min(glm::vec3(
std::numeric_limits<float>::max(),
std::numeric_limits<float>::max(),
std::numeric_limits<float>::max()
));
for (auto const& point : points)
{
min = math::min(min, point);
min = glm::min(min, point);
}
return min;
}
math::vector_3d max_per_dimension(std::vector<math::vector_3d> const& points)
glm::vec3 max_per_dimension(std::vector<glm::vec3> const& points)
{
auto max(math::vector_3d::min());
auto max(glm::vec3(
std::numeric_limits<float>::min(),
std::numeric_limits<float>::min(),
std::numeric_limits<float>::min()
));
for (auto const& point : points)
{
max = math::max(max, point);
max = glm::max(max, point);
}
return max;
}
@@ -26,27 +36,27 @@ namespace
namespace math
{
aabb::aabb(math::vector_3d const& min_, math::vector_3d const& max_)
aabb::aabb(glm::vec3 const& min_, glm::vec3 const& max_)
: min(min_)
, max(max_)
{
}
aabb::aabb(std::vector<math::vector_3d> points)
aabb::aabb(std::vector<glm::vec3> points)
: aabb(min_per_dimension(points), max_per_dimension(points))
{
}
//! \todo Optimize: iterate lazily.
std::vector<math::vector_3d> aabb::all_corners() const
std::vector<glm::vec3> aabb::all_corners() const
{
return box_points(min, max);
}
std::vector<math::vector_3d> box_points(math::vector_3d const& box_min, math::vector_3d const& box_max)
std::vector<glm::vec3> box_points(glm::vec3 const& box_min, glm::vec3 const& box_max)
{
std::vector<math::vector_3d> points;
std::vector<glm::vec3> points;
points.emplace_back(box_max.x, box_max.y, box_max.z);
points.emplace_back(box_max.x, box_max.y, box_min.z);

View File

@@ -10,14 +10,14 @@ namespace math
{
struct aabb
{
aabb(math::vector_3d const& min_, math::vector_3d const& max_);
aabb(std::vector<math::vector_3d> points);
aabb(glm::vec3 const& min_, glm::vec3 const& max_);
aabb(std::vector<glm::vec3> points);
std::vector<math::vector_3d> all_corners() const;
std::vector<glm::vec3> all_corners() const;
math::vector_3d min;
math::vector_3d max;
glm::vec3 min;
glm::vec3 max;
};
std::vector<math::vector_3d> box_points(math::vector_3d const& box_min, math::vector_3d const& box_max);
std::vector<glm::vec3> box_points(glm::vec3 const& box_min, glm::vec3 const& box_max);
}

View File

@@ -76,27 +76,27 @@ namespace math
matrix_4x4::matrix_4x4 (rotation_xyz_t, degrees::vec3 const& angle)
: matrix_4x4 (unit)
{
*this *= rotate_axis<x> (angle.x);
*this *= rotate_axis<y> (angle.y);
*this *= rotate_axis<z> (angle.z);
*this *= rotate_axis<x>(degrees(angle.x));
*this *= rotate_axis<y>(degrees(angle.y));
*this *= rotate_axis<z>(degrees(angle.z));
}
matrix_4x4::matrix_4x4 (rotation_yzx_t, degrees::vec3 const& angle)
: matrix_4x4 (unit)
{
*this *= rotate_axis<y> (angle.y);
*this *= rotate_axis<z> (angle.z);
*this *= rotate_axis<x> (angle.x);
*this *= rotate_axis<y> (degrees(angle.y));
*this *= rotate_axis<z> (degrees(angle.z));
*this *= rotate_axis<x> (degrees(angle.x));
}
matrix_4x4::matrix_4x4(rotation_yxz_t, degrees::vec3 const& angle)
: matrix_4x4(unit)
{
*this *= rotate_axis<y>(angle.y);
*this *= rotate_axis<x>(angle.x);
*this *= rotate_axis<z>(angle.z);
*this *= rotate_axis<y>(degrees(angle.y));
*this *= rotate_axis<x>(degrees(angle.x));
*this *= rotate_axis<z>(degrees(angle.z));
}
vector_3d matrix_4x4::operator* (vector_3d const& v) const
glm::vec3 matrix_4x4::operator* (glm::vec3 const& v) const
{
return { _m[0][0] * v[0] + _m[0][1] * v[1] + _m[0][2] * v[2] + _m[0][3]
, _m[1][0] * v[0] + _m[1][1] * v[1] + _m[1][2] * v[2] + _m[1][3]
@@ -133,10 +133,10 @@ namespace math
};
}
std::vector<math::vector_3d> matrix_4x4::operator*
(std::vector<math::vector_3d> points) const
std::vector<glm::vec3> matrix_4x4::operator*
(std::vector<glm::vec3> points) const
{
return apply ( [&] (math::vector_3d const& point)
return apply ( [&] (glm::vec3 const& point)
{
return *this * point;
}

View File

@@ -42,7 +42,7 @@ namespace math
}
static struct translation_t {} translation;
matrix_4x4 (translation_t, vector_3d const& tr)
matrix_4x4 (translation_t, glm::vec3 const& tr)
: matrix_4x4 ( 1.0f, 0.0f, 0.0f, tr.x
, 0.0f, 1.0f, 0.0f, tr.y
, 0.0f, 0.0f, 1.0f, tr.z
@@ -51,7 +51,7 @@ namespace math
{}
static struct scale_t {} scale;
matrix_4x4 (scale_t, vector_3d const& sc)
matrix_4x4 (scale_t, glm::vec3 const& sc)
: matrix_4x4 ( sc.x, 0.0f, 0.0f, 0.0f
, 0.0f, sc.y, 0.0f, 0.0f
, 0.0f, 0.0f, sc.z, 0.0f
@@ -82,10 +82,10 @@ namespace math
return _m[j][i] = value;
}
vector_3d operator* (vector_3d const&) const;
glm::vec3 operator* (glm::vec3 const&) const;
glm::vec4 operator* (glm::vec4 const&) const;
matrix_4x4 operator* (matrix_4x4 const&) const;
std::vector<math::vector_3d> operator*(std::vector<math::vector_3d> points) const;
std::vector<glm::vec3> operator*(std::vector<glm::vec3> points) const;
matrix_4x4& operator* (float);
matrix_4x4& operator/ (float);

View File

@@ -11,9 +11,9 @@ namespace math
inline matrix_4x4 perspective (math::degrees fovy, float aspect, float zNear, float zFar)
{
// assuming
// math::vector_3d lower_left_clipping_plane (left, bottom, -nearVal);
// math::vector_3d upper_right_clipping_plane (right, top, -nearVal);
// math::vector_3d eye (0, 0, 0);
// glm::vec3 lower_left_clipping_plane (left, bottom, -nearVal);
// glm::vec3 upper_right_clipping_plane (right, top, -nearVal);
// glm::vec3 eye (0, 0, 0);
// float clipping_plane_distance (zFar - zNear);
// with

View File

@@ -7,7 +7,7 @@
namespace math
{
boost::optional<float> ray::intersect_bounds
(vector_3d const& min, vector_3d const& max) const
(glm::vec3 const& min, glm::vec3 const& max) const
{
float tmin (std::numeric_limits<float>::lowest());
float tmax (std::numeric_limits<float>::max());
@@ -48,41 +48,41 @@ namespace math
}
boost::optional<float> ray::intersect_triangle
(vector_3d const& v0, vector_3d const& v1, vector_3d const& v2) const
(glm::vec3 const& v0, glm::vec3 const& v1, glm::vec3 const& v2) const
{
vector_3d const e1 (v1 - v0);
vector_3d const e2 (v2 - v0);
glm::vec3 e1 (v1 - v0);
glm::vec3 e2 (v2 - v0);
vector_3d const P (_direction % e2);
glm::vec3 P = glm::cross(_direction,e2);
float const det (e1 * P);
float const det = glm::dot(e1, P);
if (det == 0.0f)
{
return boost::none;
}
vector_3d const T (_origin - v0);
float const u ((T * P) / det);
glm::vec3 const T (_origin - v0);
float const dotu = glm::dot(T , P) / det;
if (u < 0.0f || u > 1.0f)
if (dotu < 0.0f || dotu > 1.0f)
{
return boost::none;
}
vector_3d const Q (T % e1);
float const v ((_direction * Q) / det);
glm::vec3 const Q (glm::cross(T, e1));
float const dotv = glm::dot(_direction , Q) / det;
if (v < 0.0f || u + v > 1.0f)
if (dotv < 0.0f || dotu + dotv > 1.0f)
{
return boost::none;
}
float const t ((e2 * Q) / det);
float const dott = glm::dot(e2 , Q) / det;
if (t > std::numeric_limits<float>::min())
if (dott > std::numeric_limits<float>::min())
{
return t;
return dott;
}
return boost::none;

View File

@@ -11,30 +11,28 @@ namespace math
{
struct ray
{
ray (vector_3d origin, vector_3d const& direction)
: _origin (std::move (origin))
, _direction (direction.normalized())
ray (glm::vec3 origin, glm::vec3 const& direction): _origin (std::move (origin)), _direction (glm::normalize(direction))
{}
ray (matrix_4x4 const& transform, ray const& other): ray (
math::vector_3d(
glm::vec3(
(transform * glm::vec4(other._origin.x, other._origin.y, other._origin.z, 1.0))),
math::vector_3d((transform * glm::vec4(other._direction.x, other._direction.y, other._direction.z, 0.0)))
glm::vec3((transform * glm::vec4(other._direction.x, other._direction.y, other._direction.z, 0.0)))
)
{}
boost::optional<float> intersect_bounds
(vector_3d const& _min, vector_3d const& _max) const;
(glm::vec3 const& _min, glm::vec3 const& _max) const;
boost::optional<float> intersect_triangle
(vector_3d const& _v0, vector_3d const& _v1, vector_3d const& _v2) const;
(glm::vec3 const& _v0, glm::vec3 const& _v1, glm::vec3 const& _v2) const;
vector_3d position (float distance) const
glm::vec3 position (float distance) const
{
return _origin + _direction * distance;
}
private:
vector_3d _origin;
vector_3d _direction;
glm::vec3 _origin;
glm::vec3 _direction;
};
}

View File

@@ -56,8 +56,7 @@ namespace math
return os << std::to_string(v._) << "°";
}
using vec3 = vector_3d_base<degrees>;
using vec3 = glm::vec3;
};
struct radians
@@ -105,6 +104,13 @@ namespace math
*x = xa * cos(angle) - ya * sin(angle) + x0;
*y = xa * sin(angle) + ya * cos(angle) + y0;
}
inline bool is_inside_of(const glm::vec3& pos, const glm::vec3& a, const glm::vec3& b)
{
return a.x < pos.x&& b.x > pos.x
&& a.y < pos.y&& b.y > pos.y
&& a.z < pos.z&& b.z > pos.z;
}
}
inline math::degrees operator"" _deg (long double v)

View File

@@ -215,8 +215,8 @@ namespace math
template<typename Fun>
std::vector<math::vector_3d> apply
(Fun&& fun, std::vector<math::vector_3d> points)
std::vector<glm::vec3> apply
(Fun&& fun, std::vector<glm::vec3> points)
{
for (auto& point : points)
{

View File

@@ -67,7 +67,7 @@ namespace noggit
struct ObjectInstanceCache
{
std::string filename;
math::vector_3d pos;
glm::vec3 pos;
math::degrees::vec3 dir;
float scale;
};
@@ -77,8 +77,8 @@ namespace noggit
std::unordered_set<MapTile*> vertex_tiles;
std::unordered_set<MapChunk*> vertex_chunks;
std::unordered_set<MapChunk*> vertex_border_chunks;
std::unordered_set<math::vector_3d*> vertices_selected;
math::vector_3d vertex_center;
std::unordered_set<glm::vec3*> vertices_selected;
glm::vec3 vertex_center;
};
class Action : public QObject

View File

@@ -20,7 +20,7 @@ ChunkWater::ChunkWater(MapChunk* chunk, TileWater* water_tile, float x, float z,
void ChunkWater::from_mclq(std::vector<mclq>& layers)
{
math::vector_3d pos(xbase, 0.0f, zbase);
glm::vec3 pos(xbase, 0.0f, zbase);
for (mclq& liquid : layers)
{
@@ -105,7 +105,7 @@ void ChunkWater::fromFile(MPQFile &f, size_t basePos)
f.read(&infoMask, bitmask_size);
}
math::vector_3d pos(xbase, 0.0f, zbase);
glm::vec3 pos(xbase, 0.0f, zbase);
_water_tile->registerNewChunk(_layers.size());
_layers.emplace_back(this, f, basePos, pos, info, infoMask);
}
@@ -182,7 +182,7 @@ void ChunkWater::setType(int type, size_t layer)
bool ChunkWater::is_visible ( const float& cull_distance
, const math::frustum& frustum
, const math::vector_3d& camera
, const glm::vec3& camera
, display_mode display
) const
{
@@ -227,14 +227,14 @@ bool ChunkWater::hasData(size_t layer) const
}
void ChunkWater::paintLiquid( math::vector_3d const& pos
void ChunkWater::paintLiquid( glm::vec3 const& pos
, float radius
, int liquid_id
, bool add
, math::radians const& angle
, math::radians const& orientation
, bool lock
, math::vector_3d const& origin
, glm::vec3 const& origin
, bool override_height
, bool override_liquid_id
, MapChunk* chunk
@@ -256,7 +256,7 @@ void ChunkWater::paintLiquid( math::vector_3d const& pos
if (!layer_found)
{
liquid_layer layer(this, math::vector_3d(xbase, 0.0f, zbase), pos.y, liquid_id);
liquid_layer layer(this, glm::vec3(xbase, 0.0f, zbase), pos.y, liquid_id);
copy_height_to_layer(layer, pos, radius);
_water_tile->registerNewChunk(_layers.size());
_layers.push_back(layer);
@@ -297,7 +297,7 @@ void ChunkWater::paintLiquid( math::vector_3d const& pos
}
else
{
liquid_layer layer(this, math::vector_3d(xbase, 0.0f, zbase), pos.y, liquid_id);
liquid_layer layer(this, glm::vec3(xbase, 0.0f, zbase), pos.y, liquid_id);
layer.paintLiquid(pos, radius, true, angle, orientation, lock, origin, override_height, chunk, opacity_factor);
_water_tile->registerNewChunk(_layers.size());
_layers.push_back(layer);
@@ -318,7 +318,7 @@ void ChunkWater::cleanup()
}
}
void ChunkWater::copy_height_to_layer(liquid_layer& target, math::vector_3d const& pos, float radius)
void ChunkWater::copy_height_to_layer(liquid_layer& target, glm::vec3 const& pos, float radius)
{
for (liquid_layer& layer : _layers)
{

View File

@@ -33,7 +33,7 @@ public:
bool is_visible ( const float& cull_distance
, const math::frustum& frustum
, const math::vector_3d& camera
, const glm::vec3& camera
, display_mode display
) const;
@@ -51,14 +51,14 @@ public:
float getMinHeight() { return vmin.y; };
float getMaxHeight() { return vmax.y; }
void paintLiquid( math::vector_3d const& pos
void paintLiquid( glm::vec3 const& pos
, float radius
, int liquid_id
, bool add
, math::radians const& angle
, math::radians const& orientation
, bool lock
, math::vector_3d const& origin
, glm::vec3 const& origin
, bool override_height
, bool override_liquid_id
, MapChunk* chunk
@@ -72,13 +72,13 @@ public:
private:
math::vector_3d vmin, vmax, vcenter;
glm::vec3 vmin, vmax, vcenter;
bool _use_mclq_green_lava;
// remove empty layers
void cleanup();
void copy_height_to_layer(liquid_layer& target, math::vector_3d const& pos, float radius);
void copy_height_to_layer(liquid_layer& target, glm::vec3 const& pos, float radius);
MH2O_Render Render;

View File

@@ -79,10 +79,10 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
xbase = xbase*-1.0f + ZEROPOINT;
vmin.y = 0.0f;
vmin = math::vector_3d(9999999.0f, 9999999.0f, 9999999.0f);
vmax = math::vector_3d(-9999999.0f, -9999999.0f, -9999999.0f);
vmin = glm::vec3(9999999.0f, 9999999.0f, 9999999.0f);
vmax = glm::vec3(-9999999.0f, -9999999.0f, -9999999.0f);
math::vector_3d *ttv = mVertices;
glm::vec3 *ttv = mVertices;
for (int j = 0; j < 17; ++j) {
for (int i = 0; i < ((j % 2) ? 8 : 9); ++i) {
@@ -92,7 +92,7 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
if (j % 2) {
xpos += UNITSIZE*0.5f;
}
math::vector_3d v = math::vector_3d(xbase + xpos, ybase + 0.0f, zbase + zpos);
glm::vec3 v = glm::vec3(xbase + xpos, ybase + 0.0f, zbase + zpos);
*ttv++ = v;
vmin.y = std::min(vmin.y, v.y);
vmax.y = std::max(vmax.y, v.y);
@@ -148,8 +148,8 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
zbase = zbase*-1.0f + ZEROPOINT;
xbase = xbase*-1.0f + ZEROPOINT;
vmin = math::vector_3d(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
vmax = math::vector_3d(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
vmin = glm::vec3(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
vmax = glm::vec3(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
}
texture_set = std::make_unique<TextureSet>(this, f, base, maintile, bigAlpha,
@@ -163,7 +163,7 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
assert(fourcc == 'MCVT');
math::vector_3d *ttv = mVertices;
glm::vec3 *ttv = mVertices;
// vertices
for (int j = 0; j < 17; ++j) {
@@ -175,7 +175,7 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
if (j % 2) {
xpos += UNITSIZE*0.5f;
}
math::vector_3d v = math::vector_3d(xbase + xpos, ybase + h, zbase + zpos);
glm::vec3 v = glm::vec3(xbase + xpos, ybase + h, zbase + zpos);
*ttv++ = v;
vmin.y = std::min(vmin.y, v.y);
vmax.y = std::max(vmax.y, v.y);
@@ -278,12 +278,12 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
for (int i = 0; i < mapbufsize; ++i)
{
f->read(t, 4);
mccv[i] = math::vector_3d((float)t[2] / 127.0f, (float)t[1] / 127.0f, (float)t[0] / 127.0f);
mccv[i] = glm::vec3((float)t[2] / 127.0f, (float)t[1] / 127.0f, (float)t[0] / 127.0f);
}
}
else
{
math::vector_3d mccv_default(1.f, 1.f, 1.f);
glm::vec3 mccv_default(1.f, 1.f, 1.f);
for (int i = 0; i < mapbufsize; ++i)
{
mccv[i] = mccv_default;
@@ -356,7 +356,7 @@ bool MapChunk::has_shadows() const
return false;
}
bool MapChunk::GetVertex(float x, float z, math::vector_3d *V)
bool MapChunk::GetVertex(float x, float z, glm::vec3 *V)
{
float xdiff, zdiff;
@@ -372,7 +372,7 @@ bool MapChunk::GetVertex(float x, float z, math::vector_3d *V)
return true;
}
void MapChunk::getVertexInternal(float x, float z, math::vector_3d* v)
void MapChunk::getVertexInternal(float x, float z, glm::vec3* v)
{
float xdiff, zdiff;
@@ -410,7 +410,7 @@ void MapChunk::clearHeight()
void MapChunk::draw ( math::frustum const& frustum
, opengl::scoped::use_program& mcnk_shader
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool need_visibility_update
, bool show_unpaintable_chunks
, bool draw_paintability_overlay
@@ -601,7 +601,7 @@ void MapChunk::updateVerticesData()
update_intersect_points();
}
math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
glm::vec3 MapChunk::getNeighborVertex(int i, unsigned dir)
{
// i - vertex index
// 0 - up_left
@@ -623,7 +623,7 @@ math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
float vertex_z = mVertices[i].z + zdiff[dir];
tile_index tile({vertex_x, 0, vertex_z});
math::vector_3d result{};
glm::vec3 result{};
if (tile.x == mt->index.x && tile.z == mt->index.z)
{
@@ -657,13 +657,13 @@ math::vector_3d MapChunk::getNeighborVertex(int i, unsigned dir)
if (!mt->_world->mapIndex.tileLoaded(tile))
{
return math::vector_3d( mVertices[i].x + xdiff[dir], mVertices[i].y, mVertices[i].z + zdiff[dir]);
return glm::vec3( mVertices[i].x + xdiff[dir], mVertices[i].y, mVertices[i].z + zdiff[dir]);
}
math::vector_3d vertex{};
glm::vec3 vertex{};
mt->_world->mapIndex.getTile(tile)->getVertexInternal(mVertices[i].x + xdiff[dir], mVertices[i].z + zdiff[dir], &vertex);
return math::vector_3d( mVertices[i].x + xdiff[dir], vertex.y, mVertices[i].z + zdiff[dir]);
return glm::vec3( mVertices[i].x + xdiff[dir], vertex.y, mVertices[i].z + zdiff[dir]);
}
@@ -745,18 +745,18 @@ void MapChunk::recalcNorms()
for (int i = 0; i < mapbufsize; ++i)
{
math::vector_3d const P1 (getNeighborVertex(i, 0)); // up_left
math::vector_3d const P2 (getNeighborVertex(i, 1)); // up_right
math::vector_3d const P3 (getNeighborVertex(i, 2)); // down_left
math::vector_3d const P4 (getNeighborVertex(i, 3)); // down_right
glm::vec3 const P1 (getNeighborVertex(i, 0)); // up_left
glm::vec3 const P2 (getNeighborVertex(i, 1)); // up_right
glm::vec3 const P3 (getNeighborVertex(i, 2)); // down_left
glm::vec3 const P4 (getNeighborVertex(i, 3)); // down_right
math::vector_3d const N1 ((P2 - mVertices[i]) % (P1 - mVertices[i]));
math::vector_3d const N2 ((P3 - mVertices[i]) % (P2 - mVertices[i]));
math::vector_3d const N3 ((P4 - mVertices[i]) % (P3 - mVertices[i]));
math::vector_3d const N4 ((P1 - mVertices[i]) % (P4 - mVertices[i]));
glm::vec3 const N1 = glm::cross((P2 - mVertices[i]) , (P1 - mVertices[i]));
glm::vec3 const N2 = glm::cross((P3 - mVertices[i]) , (P2 - mVertices[i]));
glm::vec3 const N3 = glm::cross((P4 - mVertices[i]) , (P3 - mVertices[i]));
glm::vec3 const N4 = glm::cross((P1 - mVertices[i]) , (P4 - mVertices[i]));
math::vector_3d Norm (N1 + N2 + N3 + N4);
Norm.normalize();
glm::vec3 Norm (N1 + N2 + N3 + N4);
Norm = glm::normalize(Norm);
Norm.x = std::floor(Norm.x * 127) / 127;
Norm.y = std::floor(Norm.y * 127) / 127;
@@ -780,7 +780,7 @@ void MapChunk::updateNormalsData()
//gl.texSubImage2D(GL_TEXTURE_2D, 0, 0, px * 16 + py, mapbufsize, 1, GL_RGB, GL_FLOAT, mNormals);
}
bool MapChunk::changeTerrain(math::vector_3d const& pos, float change, float radius, int BrushType, float inner_radius)
bool MapChunk::changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius)
{
float dist, xdiff, zdiff;
bool changed = false;
@@ -801,7 +801,7 @@ bool MapChunk::changeTerrain(math::vector_3d const& pos, float change, float rad
return changed;
}
bool MapChunk::ChangeMCCV(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode)
bool MapChunk::ChangeMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode)
{
float dist;
bool changed = false;
@@ -854,7 +854,7 @@ bool MapChunk::ChangeMCCV(math::vector_3d const& pos, glm::vec4 const& color, fl
return changed;
}
bool MapChunk::stampMCCV(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors)
bool MapChunk::stampMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors)
{
float dist;
bool changed = false;
@@ -880,7 +880,7 @@ bool MapChunk::stampMCCV(math::vector_3d const& pos, glm::vec4 const& color, flo
if(std::abs(pos.x - mVertices[i].x) > radius || std::abs(pos.z - mVertices[i].z) > radius)
continue;
math::vector_3d const diff{mVertices[i] - pos};
glm::vec3 const diff{mVertices[i] - pos};
int pixel_x = std::round(((diff.x + radius) / (2.f * radius)) * img->width());
int pixel_y = std::round(((diff.z + radius) / (2.f * radius)) * img->height());
@@ -955,14 +955,14 @@ void MapChunk::update_vertex_colors()
gl.texSubImage2D(GL_TEXTURE_2D, 0, 0, px * 16 + py, mapbufsize, 1, GL_RGB, GL_FLOAT, mccv);
}
math::vector_3d MapChunk::pickMCCV(math::vector_3d const& pos)
glm::vec3 MapChunk::pickMCCV(glm::vec3 const& pos)
{
float dist;
float cur_dist = UNITSIZE;
if (!hasMCCV)
{
return math::vector_3d(1.0f, 1.0f, 1.0f);
return glm::vec3(1.0f, 1.0f, 1.0f);
}
int v_index = 0;
@@ -980,12 +980,12 @@ math::vector_3d MapChunk::pickMCCV(math::vector_3d const& pos)
}
bool MapChunk::flattenTerrain ( math::vector_3d const& pos
bool MapChunk::flattenTerrain ( glm::vec3 const& pos
, float remain
, float radius
, int BrushType
, flatten_mode const& mode
, math::vector_3d const& origin
, glm::vec3 const& origin
, math::degrees angle
, math::degrees orientation
)
@@ -1041,7 +1041,7 @@ bool MapChunk::flattenTerrain ( math::vector_3d const& pos
return changed;
}
bool MapChunk::blurTerrain ( math::vector_3d const& pos
bool MapChunk::blurTerrain ( glm::vec3 const& pos
, float remain
, float radius
, int BrushType
@@ -1114,7 +1114,7 @@ bool MapChunk::blurTerrain ( math::vector_3d const& pos
return changed;
}
bool MapChunk::changeTerrainProcessVertex(math::vector_3d const& pos, math::vector_3d const& vertex, float& dt,
bool MapChunk::changeTerrainProcessVertex(glm::vec3 const& pos, glm::vec3 const& vertex, float& dt,
float radiusOuter, float radiusInner, int brushType)
{
float dist, xdiff, zdiff;
@@ -1170,7 +1170,7 @@ bool MapChunk::changeTerrainProcessVertex(math::vector_3d const& pos, math::vect
return changed;
}
auto MapChunk::stamp(math::vector_3d const& pos, float dt, QImage const* img, float radiusOuter
auto MapChunk::stamp(glm::vec3 const& pos, float dt, QImage const* img, float radiusOuter
, float radiusInner, int brushType, bool sculpt) -> void
{
if (sculpt)
@@ -1183,7 +1183,7 @@ auto MapChunk::stamp(math::vector_3d const& pos, float dt, QImage const* img, fl
float delta = dt;
changeTerrainProcessVertex(pos, mVertices[i], delta, radiusOuter, radiusInner, brushType);
math::vector_3d const diff{mVertices[i] - pos};
glm::vec3 const diff{mVertices[i] - pos};
int pixel_x = std::round(((diff.x + radiusOuter) / (2.f * radiusOuter)) * img->width());
int pixel_y = std::round(((diff.z + radiusOuter) / (2.f * radiusOuter)) * img->height());
@@ -1220,7 +1220,7 @@ auto MapChunk::stamp(math::vector_3d const& pos, float dt, QImage const* img, fl
changeTerrainProcessVertex(pos, mVertices[i], delta, radiusOuter, radiusInner, brushType);
math::vector_3d const diff{math::vector_3d{original_heightmap[i * 3], original_heightmap[i * 3 + 1], original_heightmap[i * 3 + 2]} - pos};
glm::vec3 const diff{glm::vec3{original_heightmap[i * 3], original_heightmap[i * 3 + 1], original_heightmap[i * 3 + 2]} - pos};
int pixel_x = std::round(((diff.x + radiusOuter) / (2.f * radiusOuter)) * img->width());
@@ -1265,17 +1265,17 @@ void MapChunk::switchTexture(scoped_blp_texture_reference const& oldTexture, sco
texture_set->replace_texture(oldTexture, std::move (newTexture));
}
bool MapChunk::paintTexture(math::vector_3d const& pos, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture)
bool MapChunk::paintTexture(glm::vec3 const& pos, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture)
{
return texture_set->paintTexture(xbase, zbase, pos.x, pos.z, brush, strength, pressure, std::move (texture));
}
bool MapChunk::stampTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint)
bool MapChunk::stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint)
{
return texture_set->stampTexture(xbase, zbase, pos.x, pos.z, brush, strength, pressure, std::move (texture), img, paint);
}
bool MapChunk::replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture)
bool MapChunk::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture)
{
return texture_set->replace_texture(xbase, zbase, pos.x, pos.z, radius, old_texture, std::move (new_texture));
}
@@ -1303,7 +1303,7 @@ bool MapChunk::isHole(int i, int j)
return (holes & ((1 << ((j * 4) + i)))) != 0;
}
void MapChunk::setHole(math::vector_3d const& pos, float radius, bool big, bool add)
void MapChunk::setHole(glm::vec3 const& pos, float radius, bool big, bool add)
{
if (big)
{
@@ -1542,9 +1542,9 @@ void MapChunk::save(sExtendableArray &lADTFile, int &lCurrentPosition, int &lMCI
std::list<int> lDoodadIDs;
std::list<int> lObjectIDs;
math::vector_3d lChunkExtents[2];
lChunkExtents[0] = math::vector_3d(xbase, 0.0f, zbase);
lChunkExtents[1] = math::vector_3d(xbase + CHUNKSIZE, 0.0f, zbase + CHUNKSIZE);
glm::vec3 lChunkExtents[2];
lChunkExtents[0] = glm::vec3(xbase, 0.0f, zbase);
lChunkExtents[1] = glm::vec3(xbase + CHUNKSIZE, 0.0f, zbase + CHUNKSIZE);
// search all wmos that are inside this chunk
lID = 0;
@@ -1713,7 +1713,7 @@ bool MapChunk::fixGapAbove(const MapChunk* chunk)
}
void MapChunk::selectVertex(math::vector_3d const& pos, float radius, std::unordered_set<math::vector_3d*>& vertices)
void MapChunk::selectVertex(glm::vec3 const& pos, float radius, std::unordered_set<glm::vec3*>& vertices)
{
if (misc::getShortestDist(pos.x, pos.z, xbase, zbase, CHUNKSIZE) > radius)
{
@@ -1729,7 +1729,7 @@ void MapChunk::selectVertex(math::vector_3d const& pos, float radius, std::unord
}
}
void MapChunk::fixVertices(std::unordered_set<math::vector_3d*>& selected)
void MapChunk::fixVertices(std::unordered_set<glm::vec3*>& selected)
{
std::vector<int> ids ={ 0, 1, 17, 18 };
// iterate through each "square" of vertices
@@ -1763,7 +1763,7 @@ void MapChunk::fixVertices(std::unordered_set<math::vector_3d*>& selected)
}
}
bool MapChunk::isBorderChunk(std::unordered_set<math::vector_3d*>& selected)
bool MapChunk::isBorderChunk(std::unordered_set<glm::vec3*>& selected)
{
for (int i = 0; i < mapbufsize; ++i)
{
@@ -1779,7 +1779,7 @@ bool MapChunk::isBorderChunk(std::unordered_set<math::vector_3d*>& selected)
QImage MapChunk::getHeightmapImage(float min_height, float max_height)
{
math::vector_3d* heightmap = getHeightmap();
glm::vec3* heightmap = getHeightmap();
QImage image(17, 17, QImage::Format_RGBA64);
@@ -1823,7 +1823,7 @@ QImage MapChunk::getAlphamapImage(unsigned layer)
void MapChunk::setHeightmapImage(QImage const& image, float multiplier, int mode)
{
math::vector_3d* heightmap = getHeightmap();
glm::vec3* heightmap = getHeightmap();
unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2};
@@ -1895,7 +1895,7 @@ void MapChunk::setAlphamapImage(const QImage &image, unsigned int layer)
QImage MapChunk::getVertexColorImage()
{
math::vector_3d* colors = getVertexColors();
glm::vec3* colors = getVertexColors();
QImage image(17, 17, QImage::Format_RGBA8888);
@@ -1920,7 +1920,7 @@ QImage MapChunk::getVertexColorImage()
void MapChunk::setVertexColorImage(const QImage &image)
{
math::vector_3d* colors = getVertexColors();
glm::vec3* colors = getVertexColors();
unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2};

View File

@@ -64,7 +64,7 @@ public:
auto getHoleMask(void) const -> unsigned { return static_cast<unsigned>(holes); }
MapTile *mt;
math::vector_3d vmin, vmax, vcenter;
glm::vec3 vmin, vmax, vcenter;
int px, py;
MapChunkHeader header;
@@ -81,9 +81,9 @@ public:
unsigned int areaID;
math::vector_3d mVertices[mapbufsize];
math::vector_3d mNormals[mapbufsize];
math::vector_3d mccv[mapbufsize];
glm::vec3 mVertices[mapbufsize];
glm::vec3 mNormals[mapbufsize];
glm::vec3 mccv[mapbufsize];
uint8_t _shadow_map[64 * 64];
@@ -107,7 +107,7 @@ public:
void draw ( math::frustum const& frustum
, opengl::scoped::use_program& mcnk_shader
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool need_visibility_update
, bool show_unpaintable_chunks
, bool draw_paintability_overlay
@@ -121,9 +121,9 @@ public:
//! \todo only this function should be public, all others should be called from it
bool intersect (math::ray const&, selection_result*);
bool ChangeMCCV(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode);
bool stampMCCV(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
math::vector_3d pickMCCV(math::vector_3d const& pos);
bool ChangeMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode);
bool stampMCCV(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
glm::vec3 pickMCCV(glm::vec3 const& pos);
ChunkWater* liquid_chunk() const;
@@ -132,27 +132,27 @@ public:
void updateVerticesData();
void recalcNorms();
void updateNormalsData();
math::vector_3d getNeighborVertex(int i, unsigned dir);
glm::vec3 getNeighborVertex(int i, unsigned dir);
//! \todo implement Action stack for these
bool changeTerrain(math::vector_3d const& pos, float change, float radius, int BrushType, float inner_radius);
bool flattenTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const math::vector_3d& origin, math::degrees angle, math::degrees orientation);
bool blurTerrain ( math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode
bool changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius);
bool flattenTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const glm::vec3& origin, math::degrees angle, math::degrees orientation);
bool blurTerrain ( glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode
, std::function<boost::optional<float> (float, float)> height
);
bool changeTerrainProcessVertex(math::vector_3d const& pos, math::vector_3d const& vertex, float& dt, float radiusOuter, float radiusInner, int brushType);
auto stamp(math::vector_3d const& pos, float dt, QImage const* img, float radiusOuter
bool changeTerrainProcessVertex(glm::vec3 const& pos, glm::vec3 const& vertex, float& dt, float radiusOuter, float radiusInner, int brushType);
auto stamp(glm::vec3 const& pos, float dt, QImage const* img, float radiusOuter
, float radiusInner, int brushType, bool sculpt) -> void;
void selectVertex(math::vector_3d const& pos, float radius, std::unordered_set<math::vector_3d*>& vertices);
void fixVertices(std::unordered_set<math::vector_3d*>& selected);
void selectVertex(glm::vec3 const& pos, float radius, std::unordered_set<glm::vec3*>& vertices);
void fixVertices(std::unordered_set<glm::vec3*>& selected);
// for the vertex tool
bool isBorderChunk(std::unordered_set<math::vector_3d*>& selected);
bool isBorderChunk(std::unordered_set<glm::vec3*>& selected);
//! \todo implement Action stack for these
bool paintTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
bool stampTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
bool replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
bool paintTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
bool stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
bool replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
bool canPaintTexture(scoped_blp_texture_reference texture);
int addTexture(scoped_blp_texture_reference texture);
void switchTexture(scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture);
@@ -162,19 +162,19 @@ public:
void clear_shadows();
bool isHole(int i, int j);
void setHole(math::vector_3d const& pos, float radius, bool big, bool add);
void setHole(glm::vec3 const& pos, float radius, bool big, bool add);
void setFlag(bool value, uint32_t);
int getAreaID();
void setAreaID(int ID);
bool GetVertex(float x, float z, math::vector_3d *V);
void getVertexInternal(float x, float z, math::vector_3d * v);
bool GetVertex(float x, float z, glm::vec3 *V);
void getVertexInternal(float x, float z, glm::vec3 * v);
float getHeight(int x, int z);
float getMinHeight() { return vmin.y; };
float getMaxHeight() { return vmax.y; };
math::vector_3d getCenter() { return vcenter; };
glm::vec3 getCenter() { return vcenter; };
void clearHeight();
@@ -186,9 +186,9 @@ public:
// fix the gaps with the chunk above
bool fixGapAbove(const MapChunk* chunk);
math::vector_3d* getHeightmap() { return &mVertices[0]; };
math::vector_3d const* getNormals() const { return &mNormals[0]; }
math::vector_3d* getVertexColors() { return &mccv[0]; };
glm::vec3* getHeightmap() { return &mVertices[0]; };
glm::vec3 const* getNormals() const { return &mNormals[0]; }
glm::vec3* getVertexColors() { return &mccv[0]; };
void update_vertex_colors();

View File

@@ -55,12 +55,12 @@ MapTile::MapTile( int pX
| ChunkUpdateFlags::SHADOW | ChunkUpdateFlags::MCCV
| ChunkUpdateFlags::NORMALS| ChunkUpdateFlags::HOLES
| ChunkUpdateFlags::AREA_ID| ChunkUpdateFlags::FLAGS)
, _extents{math::vector_3d{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
math::vector_3d{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
, _combined_extents{math::vector_3d{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
math::vector_3d{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
, _object_instance_extents{math::vector_3d{std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max()}
, math::vector_3d{std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest()}}
, _extents{glm::vec3{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
glm::vec3{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
, _combined_extents{glm::vec3{pX * TILESIZE, std::numeric_limits<float>::max(), pZ * TILESIZE},
glm::vec3{pX * TILESIZE + TILESIZE, std::numeric_limits<float>::lowest(), pZ * TILESIZE + TILESIZE}}
, _object_instance_extents{glm::vec3{std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max()}
, glm::vec3{std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest()}}
,_center{pX * TILESIZE + TILESIZE / 2.f, 0.f, pZ * TILESIZE + TILESIZE / 2.f}
{
}
@@ -382,7 +382,7 @@ void MapTile::convert_alphamap(bool to_big_alpha)
}
void MapTile::draw (opengl::scoped::use_program& mcnk_shader
, const math::vector_3d& camera
, const glm::vec3& camera
, bool show_unpaintable_chunks
, bool draw_paintability_overlay
, bool is_selected
@@ -721,12 +721,12 @@ void MapTile::drawMFBO (opengl::scoped::use_program& mfbo_shader)
gl.bufferData<GL_ARRAY_BUFFER>( _mfbo_bottom_vbo
, 9 * sizeof(math::vector_3d)
, 9 * sizeof(glm::vec3)
, mMinimumValues
, GL_STATIC_DRAW
);
gl.bufferData<GL_ARRAY_BUFFER>( _mfbo_top_vbo
, 9 * sizeof(math::vector_3d)
, 9 * sizeof(glm::vec3)
, mMaximumValues
, GL_STATIC_DRAW
);
@@ -771,7 +771,7 @@ void MapTile::drawMFBO (opengl::scoped::use_program& mfbo_shader)
void MapTile::drawWater ( math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool camera_moved
, opengl::scoped::use_program& water_shader
, int animtime
@@ -810,7 +810,7 @@ MapChunk* MapTile::getChunk(unsigned int x, unsigned int z)
}
}
std::vector<MapChunk*> MapTile::chunks_in_range (math::vector_3d const& pos, float radius) const
std::vector<MapChunk*> MapTile::chunks_in_range (glm::vec3 const& pos, float radius) const
{
std::vector<MapChunk*> chunks;
@@ -828,7 +828,7 @@ std::vector<MapChunk*> MapTile::chunks_in_range (math::vector_3d const& pos, flo
return chunks;
}
std::vector<MapChunk*> MapTile::chunks_in_rect (math::vector_3d const& pos, float radius) const
std::vector<MapChunk*> MapTile::chunks_in_rect (glm::vec3 const& pos, float radius) const
{
std::vector<MapChunk*> chunks;
@@ -853,7 +853,7 @@ std::vector<MapChunk*> MapTile::chunks_in_rect (math::vector_3d const& pos, floa
return chunks;
}
bool MapTile::GetVertex(float x, float z, math::vector_3d *V)
bool MapTile::GetVertex(float x, float z, glm::vec3 *V)
{
int xcol = (int)((x - xbase) / CHUNKSIZE);
int ycol = (int)((z - zbase) / CHUNKSIZE);
@@ -861,7 +861,7 @@ bool MapTile::GetVertex(float x, float z, math::vector_3d *V)
return xcol >= 0 && xcol <= 15 && ycol >= 0 && ycol <= 15 && mChunks[ycol][xcol]->GetVertex(x, z, V);
}
void MapTile::getVertexInternal(float x, float z, math::vector_3d* v)
void MapTile::getVertexInternal(float x, float z, glm::vec3* v)
{
int xcol = (int)((x - xbase) / CHUNKSIZE);
int ycol = (int)((z - zbase) / CHUNKSIZE);
@@ -880,9 +880,9 @@ void MapTile::saveTile(World* world)
std::vector<ModelInstance> lModelInstances;
// Check which doodads and WMOs are on this ADT.
math::vector_3d lTileExtents[2];
lTileExtents[0] = math::vector_3d(xbase, 0.0f, zbase);
lTileExtents[1] = math::vector_3d(xbase + TILESIZE, 0.0f, zbase + TILESIZE);
glm::vec3 lTileExtents[2];
lTileExtents[0] = glm::vec3(xbase, 0.0f, zbase);
lTileExtents[1] = glm::vec3(xbase + TILESIZE, 0.0f, zbase + TILESIZE);
// get every models on the tile
for (std::uint32_t uid : uids)
@@ -1130,9 +1130,9 @@ void MapTile::saveTile(World* world)
lMDDF_Data[lID].pos[0] = model.pos.x;
lMDDF_Data[lID].pos[1] = model.pos.y;
lMDDF_Data[lID].pos[2] = model.pos.z;
lMDDF_Data[lID].rot[0] = model.dir.x._;
lMDDF_Data[lID].rot[1] = model.dir.y._;
lMDDF_Data[lID].rot[2] = model.dir.z._;
lMDDF_Data[lID].rot[0] = model.dir.x;
lMDDF_Data[lID].rot[1] = model.dir.y;
lMDDF_Data[lID].rot[2] = model.dir.z;
lMDDF_Data[lID].scale = (uint16_t)(model.scale * 1024);
lMDDF_Data[lID].flags = 0;
lID++;
@@ -1167,9 +1167,9 @@ void MapTile::saveTile(World* world)
lMODF_Data[lID].pos[1] = object.pos.y;
lMODF_Data[lID].pos[2] = object.pos.z;
lMODF_Data[lID].rot[0] = object.dir.x._;
lMODF_Data[lID].rot[1] = object.dir.y._;
lMODF_Data[lID].rot[2] = object.dir.z._;
lMODF_Data[lID].rot[0] = object.dir.x;
lMODF_Data[lID].rot[1] = object.dir.y;
lMODF_Data[lID].rot[2] = object.dir.z;
lMODF_Data[lID].extents[0][0] = object.extents[0].x;
lMODF_Data[lID].extents[0][1] = object.extents[0].y;
@@ -1418,7 +1418,7 @@ QImage MapTile::getHeightmapImage(float min_height, float max_height)
{
MapChunk* chunk = getChunk(k, l);
math::vector_3d* heightmap = chunk->getHeightmap();
glm::vec3* heightmap = chunk->getHeightmap();
for (unsigned y = 0; y < SUM; ++y)
{
@@ -1451,7 +1451,7 @@ QImage MapTile::getNormalmapImage()
{
MapChunk* chunk = getChunk(k, l);
const math::vector_3d* normals = chunk->getNormals();
const glm::vec3* normals = chunk->getNormals();
for (unsigned y = 0; y < SUM; ++y)
{
@@ -1462,8 +1462,8 @@ QImage MapTile::getNormalmapImage()
bool const erp = plain % DSUM / SUM;
unsigned const idx {(plain - (is_virtual ? (erp ? SUM : 1) : 0)) / 2};
auto normal = normals[idx].normalized();
auto normal_inner = normals[idx + (erp ? SUM : 1)].normalized();
auto normal = glm::normalize(normals[idx]);
auto normal_inner = glm::normalize(normals[idx + (erp ? SUM : 1)]);
float value_r = is_virtual ? (normal.x + normal_inner.x) / 2.f : normal.x;
float value_g = is_virtual ? (normal.y + normal_inner.y) / 2.f : normal.y;
@@ -1562,7 +1562,7 @@ void MapTile::setHeightmapImage(QImage const& image, float multiplier, int mode)
{
MapChunk* chunk = getChunk(k, l);
math::vector_3d* heightmap = chunk->getHeightmap();
glm::vec3* heightmap = chunk->getHeightmap();
for (unsigned y = 0; y < SUM; ++y)
for (unsigned x = 0; x < SUM; ++x)
@@ -1679,7 +1679,7 @@ QImage MapTile::getVertexColorsImage()
if (!chunk->header_flags.flags.has_mccv)
continue;
math::vector_3d* colors = chunk->getVertexColors();
glm::vec3* colors = chunk->getVertexColors();
for (unsigned y = 0; y < SUM; ++y)
{
@@ -1711,7 +1711,7 @@ void MapTile::setVertexColorImage(QImage const& image, int mode)
{
MapChunk* chunk = getChunk(k, l);
math::vector_3d* colors = chunk->getVertexColors();
glm::vec3* colors = chunk->getVertexColors();
for (unsigned y = 0; y < SUM; ++y)
for (unsigned x = 0; x < SUM; ++x)
@@ -1910,8 +1910,8 @@ void MapTile::recalcObjectInstanceExtents()
instance->ensureExtents();
math::vector_3d& min = instance->extents[0];
math::vector_3d& max = instance->extents[1];
glm::vec3& min = instance->extents[0];
glm::vec3& max = instance->extents[1];
_object_instance_extents[0].x = std::min(_object_instance_extents[0].x, min.x);
_object_instance_extents[0].y = std::min(_object_instance_extents[0].y, min.y);
@@ -1940,7 +1940,7 @@ void MapTile::doTileOcclusionQuery(opengl::scoped::use_program& occlusion_shader
gl.endQuery(GL_ANY_SAMPLES_PASSED);
}
bool MapTile::getTileOcclusionQueryResult(math::vector_3d const& camera)
bool MapTile::getTileOcclusionQueryResult(glm::vec3 const& camera)
{
// returns true if tile is not occluded by other tiles
@@ -1983,7 +1983,7 @@ bool MapTile::getTileOcclusionQueryResult(math::vector_3d const& camera)
}
void MapTile::calcCamDist(math::vector_3d const& camera)
void MapTile::calcCamDist(glm::vec3 const& camera)
{
_cam_dist = (camera - _center).length();
}

View File

@@ -76,8 +76,8 @@ public:
//! \brief Get chunk for sub offset x,z.
MapChunk* getChunk(unsigned int x, unsigned int z);
//! \todo map_index style iterators
std::vector<MapChunk*> chunks_in_range (math::vector_3d const& pos, float radius) const;
std::vector<MapChunk*> chunks_in_rect (math::vector_3d const& pos, float radius) const;
std::vector<MapChunk*> chunks_in_range (glm::vec3 const& pos, float radius) const;
std::vector<MapChunk*> chunks_in_rect (glm::vec3 const& pos, float radius) const;
const tile_index index;
float xbase, zbase;
@@ -89,7 +89,7 @@ public:
bool tile_occlusion_cull_override = true;
void draw (opengl::scoped::use_program& mcnk_shader
, const math::vector_3d& camera
, const glm::vec3& camera
, bool show_unpaintable_chunks
, bool draw_paintability_overlay
, bool is_selected
@@ -98,7 +98,7 @@ public:
bool intersect (math::ray const&, selection_result*) const;
void drawWater ( math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool camera_moved
, opengl::scoped::use_program& water_shader
, int animtime
@@ -109,8 +109,8 @@ public:
void drawMFBO (opengl::scoped::use_program&);
bool GetVertex(float x, float z, math::vector_3d *V);
void getVertexInternal(float x, float z, math::vector_3d* v);
bool GetVertex(float x, float z, glm::vec3 *V);
void getVertexInternal(float x, float z, glm::vec3* v);
void saveTile(World*);
void CropWater();
@@ -157,8 +157,8 @@ public:
void recalcExtents();
void recalcObjectInstanceExtents();
void recalcCombinedExtents();
std::array<math::vector_3d, 2>& getExtents() { return _extents; };
std::array<math::vector_3d, 2>& getCombinedExtents() { return _combined_extents; };
std::array<glm::vec3, 2>& getExtents() { return _extents; };
std::array<glm::vec3, 2>& getCombinedExtents() { return _combined_extents; };
void unload();
@@ -170,11 +170,11 @@ public:
tsl::robin_map<AsyncObject*, std::vector<SceneObject*>> const& getObjectInstances() const { return object_instances; };
void doTileOcclusionQuery(opengl::scoped::use_program& occlusion_shader);
bool getTileOcclusionQueryResult(math::vector_3d const& camera);
bool getTileOcclusionQueryResult(glm::vec3 const& camera);
void discardTileOcclusionQuery() { _tile_occlusion_query_in_use = false; }
float camDist() { return _cam_dist; }
void calcCamDist(math::vector_3d const& camera);
void calcCamDist(glm::vec3 const& camera);
void markExtentsDirty() { _extents_dirty = true; }
void tagCombinedExtents(bool state) { _combined_extents_dirty = state; };
@@ -195,15 +195,15 @@ private:
bool _extents_dirty = true;
bool _combined_extents_dirty = true;
std::array<math::vector_3d, 2> _extents;
std::array<math::vector_3d, 2> _object_instance_extents;
std::array<math::vector_3d, 2> _combined_extents;
math::vector_3d _center;
std::array<glm::vec3, 2> _extents;
std::array<glm::vec3, 2> _object_instance_extents;
std::array<glm::vec3, 2> _combined_extents;
glm::vec3 _center;
float _cam_dist;
// MFBO:
math::vector_3d mMinimumValues[3 * 3];
math::vector_3d mMaximumValues[3 * 3];
glm::vec3 mMinimumValues[3 * 3];
glm::vec3 mMaximumValues[3 * 3];
bool _mfbo_buffer_are_setup = false;
opengl::scoped::deferred_upload_vertex_arrays<2> _mfbo_vaos;

View File

@@ -2331,7 +2331,7 @@ void MapView::setupMinimap()
_minimap->draw_skies (_show_minimap_skies.get());
connect ( _minimap, &noggit::ui::minimap_widget::map_clicked
, [this] (math::vector_3d const& pos)
, [this] (glm::vec3 const& pos)
{
move_camera_with_auto_height (pos);
}
@@ -2443,7 +2443,7 @@ void MapView::on_exit_prompt()
MapView::MapView( math::degrees camera_yaw0
, math::degrees camera_pitch0
, math::vector_3d camera_pos
, glm::vec3 camera_pos
, noggit::ui::main_window* main_window
, std::unique_ptr<World> world
, uid_fix_mode uid_fix
@@ -2569,7 +2569,7 @@ auto MapView::setBrushTexture(QImage const* img) -> void
gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
void MapView::move_camera_with_auto_height (math::vector_3d const& pos)
void MapView::move_camera_with_auto_height (glm::vec3 const& pos)
{
makeCurrent();
opengl::context::scoped_setter const _ (::gl, context());
@@ -2869,7 +2869,7 @@ void MapView::paintGL()
_transform_gizmo.setUseMultiselectionPivot(_use_median_pivot_point.get());
auto pivot = _world->multi_select_pivot().is_initialized() ?
_world->multi_select_pivot().get() : math::vector_3d(0.f, 0.f, 0.f);
_world->multi_select_pivot().get() : glm::vec3(0.f, 0.f, 0.f);
_transform_gizmo.setMultiselectionPivot(pivot);
@@ -3052,9 +3052,9 @@ void MapView::tick (float dt)
math::degrees yaw (-_camera.yaw()._);
math::vector_3d dir(1.0f, 0.0f, 0.0f);
math::vector_3d dirUp(1.0f, 0.0f, 0.0f);
math::vector_3d dirRight(0.0f, 0.0f, 1.0f);
glm::vec3 dir(1.0f, 0.0f, 0.0f);
glm::vec3 dirUp(1.0f, 0.0f, 0.0f);
glm::vec3 dirRight(0.0f, 0.0f, 1.0f);
math::rotate(0.0f, 0.0f, &dir.x, &dir.y, _camera.pitch());
math::rotate(0.0f, 0.0f, &dir.x, &dir.z, yaw);
@@ -3809,19 +3809,19 @@ math::ray MapView::intersect_ray() const
math::matrix_4x4 const invertedViewMatrix = (projection() * model_view()).inverted();
auto normalisedView = invertedViewMatrix * normalized_device_coords(mx, mz);
auto pos = math::vector_3d(normalisedView.x / normalisedView.w, normalisedView.y / normalisedView.w, normalisedView.z / normalisedView.w);
auto pos = glm::vec3(normalisedView.x / normalisedView.w, normalisedView.y / normalisedView.w, normalisedView.z / normalisedView.w);
return { _camera.position, pos - _camera.position };
}
else
{
math::vector_3d const pos
glm::vec3 const pos
( _camera.position.x - (width() * 0.5f - mx) * _2d_zoom
, _camera.position.y
, _camera.position.z - (height() * 0.5f - mz) * _2d_zoom
);
return { pos, math::vector_3d(0.f, -1.f, 0.f) };
return { pos, glm::vec3(0.f, -1.f, 0.f) };
}
}
@@ -4001,8 +4001,8 @@ math::matrix_4x4 MapView::model_view() const
{
if (_display_mode == display_mode::in_2D)
{
math::vector_3d eye = _camera.position;
math::vector_3d target = eye;
glm::vec3 eye = _camera.position;
glm::vec3 target = eye;
target.y -= 1.f;
target.z -= 0.001f;
@@ -4035,7 +4035,7 @@ void MapView::draw_map()
ZoneScoped;
//! \ todo: make the current tool return the radius
float radius = 0.0f, inner_radius = 0.0f, angle = 0.0f, orientation = 0.0f;
math::vector_3d ref_pos;
glm::vec3 ref_pos;
bool angled_mode = false, use_ref_pos = false;
_cursorType = CursorType::CIRCLE;
@@ -4277,7 +4277,7 @@ void MapView::keyPressEvent (QKeyEvent *event)
}
if (event->key() == Qt::Key_Home)
{
_camera.position = math::vector_3d(_cursor_pos.x, _cursor_pos.y + 50, _cursor_pos.z);
_camera.position = glm::vec3(_cursor_pos.x, _cursor_pos.y + 50, _cursor_pos.z);
_camera_moved_since_last_draw = true;
_minimap->update();
}
@@ -4294,28 +4294,28 @@ void MapView::keyPressEvent (QKeyEvent *event)
if (event->key() == Qt::Key_Up)
{
auto next_z = cur_tile.z - 1;
_camera.position = math::vector_3d((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
_camera.position = glm::vec3((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
_camera_moved_since_last_draw = true;
_minimap->update();
}
else if (event->key() == Qt::Key_Down)
{
auto next_z = cur_tile.z + 1;
_camera.position = math::vector_3d((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
_camera.position = glm::vec3((cur_tile.x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (next_z * TILESIZE) + (TILESIZE / 2));
_camera_moved_since_last_draw = true;
_minimap->update();
}
else if (event->key() == Qt::Key_Left)
{
auto next_x = cur_tile.x - 1;
_camera.position = math::vector_3d((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
_camera.position = glm::vec3((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
_camera_moved_since_last_draw = true;
_minimap->update();
}
else if (event->key() == Qt::Key_Right)
{
auto next_x = cur_tile.x + 1;
_camera.position = math::vector_3d((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
_camera.position = glm::vec3((next_x * TILESIZE) + (TILESIZE / 2), _camera.position.y, (cur_tile.z * TILESIZE) + (TILESIZE / 2));
_camera_moved_since_last_draw = true;
_minimap->update();
}

View File

@@ -117,7 +117,7 @@ private:
float _2d_zoom = 1.f;
float moving, strafing, updown, mousedir, turn, lookat;
CursorType _cursorType;
math::vector_3d _cursor_pos;
glm::vec3 _cursor_pos;
float _cursorRotation;
bool look, freelook;
bool ui_hidden = false;
@@ -175,7 +175,7 @@ private:
bool MoveObj;
float numpad_moveratio = 0.001f;
math::vector_3d objMove;
glm::vec3 objMove;
std::vector<selection_type> lastSelected;
@@ -231,7 +231,7 @@ public:
MapView ( math::degrees ah0
, math::degrees av0
, math::vector_3d camera_pos
, glm::vec3 camera_pos
, noggit::ui::main_window*
, std::unique_ptr<World>
, uid_fix_mode uid_fix = uid_fix_mode::none
@@ -353,7 +353,7 @@ private:
QDockWidget* _texture_palette_dock;
QDockWidget* _object_palette_dock;
void move_camera_with_auto_height (math::vector_3d const&);
void move_camera_with_auto_height (glm::vec3 const&);
void setToolPropertyWidgetVisibility(editing_mode mode);

View File

@@ -15,13 +15,13 @@
namespace misc
{
bool pointInside(math::vector_3d point, std::array<math::vector_3d, 2> const& extents)
bool pointInside(glm::vec3 point, std::array<glm::vec3, 2> const& extents)
{
return point.x >= extents[0].x && point.z >= extents[0].z &&
point.x <= extents[1].x && point.z <= extents[1].z;
}
void minmax(math::vector_3d* a, math::vector_3d* b)
void minmax(glm::vec3* a, glm::vec3* b)
{
if (a->x > b->x)
{
@@ -68,7 +68,7 @@ namespace misc
return std::sqrt(xdiff*xdiff + zdiff*zdiff);
}
float dist(math::vector_3d const& p1, math::vector_3d const& p2)
float dist(glm::vec3 const& p1, glm::vec3 const& p2)
{
return dist(p1.x, p1.z, p2.x, p2.z);
}
@@ -100,7 +100,7 @@ namespace misc
return (px == x && pz == z) ? 0.0f : dist(x, z, px, pz);
}
float getShortestDist(math::vector_3d const& pos, math::vector_3d const& square_pos, float unitSize)
float getShortestDist(glm::vec3 const& pos, glm::vec3 const& square_pos, float unitSize)
{
return getShortestDist(pos.x, pos.z, square_pos.x, square_pos.z, unitSize);
}
@@ -132,7 +132,7 @@ namespace misc
return d <= radius;
}
bool rectOverlap(math::vector_3d const* r1, math::vector_3d const* r2)
bool rectOverlap(glm::vec3 const* r1, glm::vec3 const* r2)
{
return r1[0].x <= r2[1].x
&& r2[0].x <= r1[1].x
@@ -140,7 +140,7 @@ namespace misc
&& r2[0].z <= r1[1].z;
}
float angledHeight(math::vector_3d const& origin, math::vector_3d const& pos, math::radians const& angle, math::radians const& orientation)
float angledHeight(glm::vec3 const& origin, glm::vec3 const& pos, math::radians const& angle, math::radians const& orientation)
{
return ( origin.y
+ ( (pos.x - origin.x) * math::cos(orientation)
@@ -148,7 +148,7 @@ namespace misc
) * math::tan(angle));
}
void extract_v3d_min_max(math::vector_3d const& point, math::vector_3d& min, math::vector_3d& max)
void extract_v3d_min_max(glm::vec3 const& point, glm::vec3& min, glm::vec3& max)
{
min.x = std::min(min.x, point.x);
max.x = std::max(max.x, point.x);
@@ -158,9 +158,9 @@ namespace misc
max.z = std::max(max.z, point.z);
}
std::vector<math::vector_3d> intersection_points(math::vector_3d const& vmin, math::vector_3d const& vmax)
std::vector<glm::vec3> intersection_points(glm::vec3 const& vmin, glm::vec3 const& vmax)
{
std::vector<math::vector_3d> points;
std::vector<glm::vec3> points;
points.emplace_back (vmin.x, vmin.y, vmin.z);
points.emplace_back (vmin.x, vmin.y, vmax.z);
@@ -174,7 +174,7 @@ namespace misc
return points;
}
math::vector_3d transform_model_box_coords(math::vector_3d const& pos)
glm::vec3 transform_model_box_coords(glm::vec3 const& pos)
{
return {pos.x, pos.z, -pos.y};
}
@@ -191,14 +191,14 @@ namespace misc
return filename;
}
bool vec3d_equals(math::vector_3d const& v1, math::vector_3d const& v2)
bool vec3d_equals(glm::vec3 const& v1, glm::vec3 const& v2)
{
return float_equals(v1.x, v2.x) && float_equals(v1.y, v2.y) && float_equals(v1.z, v2.z);
}
bool deg_vec3d_equals(math::degrees::vec3 const& v1, math::degrees::vec3 const& v2)
{
return float_equals(v1.x._, v2.x._) && float_equals(v1.y._, v2.y._) && float_equals(v1.z._, v2.z._);
return float_equals(v1.x, v2.x) && float_equals(v1.y, v2.y) && float_equals(v1.z, v2.z);
}
}

View File

@@ -26,16 +26,16 @@ namespace misc
float randfloat(float lower, float upper);
int randint(int lower, int upper);
float dist(float x1, float z1, float x2, float z2);
float dist(math::vector_3d const& p1, math::vector_3d const& p2);
float dist(glm::vec3 const& p1, glm::vec3 const& p2);
float getShortestDist(float x, float z, float squareX, float squareZ, float unitSize);
float getShortestDist(math::vector_3d const& pos, math::vector_3d const& square_pos, float unitSize);
float getShortestDist(glm::vec3 const& pos, glm::vec3 const& square_pos, float unitSize);
bool square_is_in_circle(float x, float z, float radius, float square_x, float square_z, float square_size);
bool rectOverlap(math::vector_3d const*, math::vector_3d const*);
bool rectOverlap(glm::vec3 const*, glm::vec3 const*);
// used for angled tools, get the height a point (pos) should be given an origin, angle and orientation
float angledHeight(math::vector_3d const& origin, math::vector_3d const& pos, math::radians const& angle, math::radians const& orientation);
void extract_v3d_min_max(math::vector_3d const& point, math::vector_3d& min, math::vector_3d& max);
std::vector<math::vector_3d> intersection_points(math::vector_3d const& vmin, math::vector_3d const& vmax);
math::vector_3d transform_model_box_coords(math::vector_3d const& pos);
float angledHeight(glm::vec3 const& origin, glm::vec3 const& pos, math::radians const& angle, math::radians const& orientation);
void extract_v3d_min_max(glm::vec3 const& point, glm::vec3& min, glm::vec3& max);
std::vector<glm::vec3> intersection_points(glm::vec3 const& vmin, glm::vec3 const& vmax);
glm::vec3 transform_model_box_coords(glm::vec3 const& pos);
// normalize the filename used in adts since TC extractors don't accept /
std::string normalize_adt_filename(std::string filename);
@@ -45,11 +45,11 @@ namespace misc
return std::abs(a - b) < (std::max(1.f, std::max(a, b)) * std::numeric_limits<float>::epsilon());
}
bool vec3d_equals(math::vector_3d const& v1, math::vector_3d const& v2);
bool vec3d_equals(glm::vec3 const& v1, glm::vec3 const& v2);
bool deg_vec3d_equals(math::degrees::vec3 const& v1, math::degrees::vec3 const& v2);
bool pointInside(math::vector_3d point, std::array<math::vector_3d, 2> const& extents);
void minmax(math::vector_3d* a, math::vector_3d* b);
bool pointInside(glm::vec3 point, std::array<glm::vec3, 2> const& extents);
void minmax(glm::vec3* a, glm::vec3* b);
inline int rounded_int_div(int value, int div)
{

View File

@@ -163,16 +163,16 @@ bool Model::isAnimated(const MPQFile& f)
}
math::vector_3d fixCoordSystem(math::vector_3d v)
glm::vec3 fixCoordSystem(glm::vec3 v)
{
return math::vector_3d(v.x, v.z, -v.y);
return glm::vec3(v.x, v.z, -v.y);
}
namespace
{
math::vector_3d fixCoordSystem2(math::vector_3d v)
glm::vec3 fixCoordSystem2(glm::vec3 v)
{
return math::vector_3d(v.x, v.z, v.y);
return glm::vec3(v.x, v.z, v.y);
}
glm::quat fixCoordSystemQuat(glm::quat v)
@@ -621,7 +621,7 @@ bool ModelRenderPass::prepare_draw(opengl::scoped::use_program& m2_shader, Model
// emissive colors
if (color_index != -1 && m->_colors[color_index].color.uses(0))
{
::math::vector_3d c (m->_colors[color_index].color.getValue (0, m->_anim_time, m->_global_animtime));
::glm::vec3 c (m->_colors[color_index].color.getValue (0, m->_anim_time, m->_global_animtime));
if (m->_colors[color_index].opacity.uses (m->_current_anim_seq))
{
mesh_color.w = m->_colors[color_index].opacity.getValue (m->_current_anim_seq, m->_anim_time, m->_global_animtime);
@@ -898,7 +898,7 @@ void ModelRenderPass::init_uv_types(Model* m)
FakeGeometry::FakeGeometry(Model* m)
{
math::vector_3d min = m->header.bounding_box_min, max = m->header.bounding_box_max;
glm::vec3 min = m->header.bounding_box_min, max = m->header.bounding_box_max;
vertices.emplace_back(min.x, max.y, min.z);
vertices.emplace_back(min.x, max.y, max.z);
@@ -1234,15 +1234,15 @@ void Model::animate(math::matrix_4x4 const& model_view, int anim_id, int anim_ti
for (auto& vertex : _current_vertices)
{
::math::vector_3d v(0, 0, 0), n(0, 0, 0);
::glm::vec3 v(0, 0, 0), n(0, 0, 0);
for (size_t b (0); b < 4; ++b)
{
if (vertex.weights[b] <= 0)
continue;
::math::vector_3d tv = bones[vertex.bones[b]].mat * vertex.position;
::math::vector_3d tn = bones[vertex.bones[b]].mrot * vertex.normal;
::glm::vec3 tv = bones[vertex.bones[b]].mat * vertex.position;
::glm::vec3 tn = bones[vertex.bones[b]].mrot * vertex.normal;
v += tv * (static_cast<float> (vertex.weights[b]) / 255.0f);
n += tn * (static_cast<float> (vertex.weights[b]) / 255.0f);
@@ -1319,8 +1319,8 @@ ModelLight::ModelLight(const MPQFile& f, const ModelLightDef &mld, int *global)
, parent (mld.bone)
, pos (fixCoordSystem(mld.pos))
, tpos (fixCoordSystem(mld.pos))
, dir (::math::vector_3d(0,1,0))
, tdir (::math::vector_3d(0,1,0)) // obviously wrong
, dir (::glm::vec3(0,1,0))
, tdir (::glm::vec3(0,1,0)) // obviously wrong
, diffColor (mld.color, f, global)
, ambColor (mld.ambColor, f, global)
, diffIntensity (mld.intensity, f, global)
@@ -1419,10 +1419,10 @@ void Bone::calcMatrix( math::matrix_4x4 const& model_view
if (flags.billboard)
{
math::vector_3d vRight (model_view[0], model_view[4], model_view[8]);
math::vector_3d vUp (model_view[1], model_view[5], model_view[9]); // Spherical billboarding
//math::vector_3d vUp = math::vector_3d(0,1,0); // Cylindrical billboarding
vRight = vRight * -1;
glm::vec3 vRight (model_view[0], model_view[4], model_view[8]);
glm::vec3 vUp (model_view[1], model_view[5], model_view[9]); // Spherical billboarding
//glm::vec3 vUp = glm::vec3(0,1,0); // Cylindrical billboarding
vRight = glm::vec3(vRight.x * -1, vRight.y * -1, vRight.z * -1);
m (0, 2, vRight.x);
m (1, 2, vRight.y);
m (2, 2, vRight.z);
@@ -1470,7 +1470,7 @@ void Model::draw( math::matrix_4x4 const& model_view
, opengl::M2RenderState& model_render_state
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, int animtime
, display_mode display
, bool no_cull
@@ -1504,11 +1504,11 @@ void Model::draw( math::matrix_4x4 const& model_view
{
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const binder(_vertices_buffer);
m2_shader.attrib("pos", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), 0);
m2_shader.attrib("bones_weight", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d)));
m2_shader.attrib("bones_indices", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 4));
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) + 8));
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) * 2 + 8));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::math::vector_3d) * 2 + 8 + sizeof(glm::vec2)));
m2_shader.attrib("bones_weight", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3)));
m2_shader.attrib("bones_indices", 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) + 4));
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) + 8));
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), reinterpret_cast<void*> (sizeof(::glm::vec3) * 2 + 8 + sizeof(glm::vec2)));
}
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
@@ -1533,7 +1533,7 @@ void Model::draw ( math::matrix_4x4 const& model_view
, opengl::M2RenderState& model_render_state
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, int animtime
, bool all_boxes
, std::unordered_map<Model*, std::size_t>& model_boxes_to_draw
@@ -1753,7 +1753,7 @@ void Model::upload()
{
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const binder (_box_vbo);
gl.bufferData (GL_ARRAY_BUFFER, _vertex_box_points.size() * sizeof (math::vector_3d), _vertex_box_points.data(), GL_STATIC_DRAW);
gl.bufferData (GL_ARRAY_BUFFER, _vertex_box_points.size() * sizeof (glm::vec3), _vertex_box_points.data(), GL_STATIC_DRAW);
}
opengl::scoped::buffer_binder<GL_ELEMENT_ARRAY_BUFFER> indices_binder(_indices_buffer);
@@ -1807,11 +1807,11 @@ void Model::setupVAO(opengl::scoped::use_program& m2_shader)
{
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const binder (_vertices_buffer);
m2_shader.attrib("pos", 3, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), 0);
m2_shader.attribi("bones_weight", 4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d)));
m2_shader.attribi("bones_indices",4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 4));
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) + 8));
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) * 2 + 8));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::math::vector_3d) * 2 + 8 + sizeof(glm::vec2)));
m2_shader.attribi("bones_weight", 4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3)));
m2_shader.attribi("bones_indices",4, GL_UNSIGNED_BYTE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) + 4));
m2_shader.attrib("normal", 3, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) + 8));
m2_shader.attrib("texcoord1", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) * 2 + 8));
m2_shader.attrib("texcoord2", 2, GL_FLOAT, GL_FALSE, sizeof (ModelVertex), reinterpret_cast<void*> (sizeof (::glm::vec3) * 2 + 8 + sizeof(glm::vec2)));
}
{

View File

@@ -26,15 +26,15 @@ class ModelInstance;
class ParticleSystem;
class RibbonEmitter;
math::vector_3d fixCoordSystem(math::vector_3d v);
glm::vec3 fixCoordSystem(glm::vec3 v);
class Bone {
Animation::M2Value<math::vector_3d> trans;
Animation::M2Value<glm::vec3> trans;
Animation::M2Value<glm::quat, packed_quaternion> rot;
Animation::M2Value<math::vector_3d> scale;
Animation::M2Value<glm::vec3> scale;
public:
math::vector_3d pivot;
glm::vec3 pivot;
int parent;
typedef struct
@@ -73,9 +73,9 @@ public:
class TextureAnim {
Animation::M2Value<math::vector_3d> trans;
Animation::M2Value<glm::vec3> trans;
Animation::M2Value<glm::quat, packed_quaternion> rot;
Animation::M2Value<math::vector_3d> scale;
Animation::M2Value<glm::vec3> scale;
public:
math::matrix_4x4 mat;
@@ -85,7 +85,7 @@ public:
};
struct ModelColor {
Animation::M2Value<math::vector_3d> color;
Animation::M2Value<glm::vec3> color;
Animation::M2Value<float, int16_t> opacity;
ModelColor(const MPQFile& f, const ModelColorDef &mcd, int *global);
@@ -185,14 +185,14 @@ struct FakeGeometry
{
FakeGeometry(Model* m);
std::vector<math::vector_3d> vertices;
std::vector<glm::vec3> vertices;
std::vector<uint16_t> indices;
};
struct ModelLight {
int type, parent;
math::vector_3d pos, tpos, dir, tdir;
Animation::M2Value<math::vector_3d> diffColor, ambColor;
glm::vec3 pos, tpos, dir, tdir;
Animation::M2Value<glm::vec3> diffColor, ambColor;
Animation::M2Value<float> diffIntensity, ambIntensity;
//Animation::M2Value<float> attStart,attEnd;
//Animation::M2Value<bool> Enabled;
@@ -219,7 +219,7 @@ public:
, opengl::M2RenderState& model_render_state
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, int animtime
, display_mode display
, bool no_cull = false
@@ -230,7 +230,7 @@ public:
, opengl::M2RenderState& model_render_state
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, int animtime
, bool all_boxes
, std::unordered_map<Model*, std::size_t>& model_boxes_to_draw
@@ -321,7 +321,7 @@ private:
bool _finished_upload = false;
bool _vao_setup = false;
std::vector<math::vector_3d> _vertex_box_points;
std::vector<glm::vec3> _vertex_box_points;
// buffers
opengl::scoped::deferred_upload_buffers<6> _buffers;

View File

@@ -71,11 +71,11 @@ struct ModelHeader {
uint32_t nTexAnimLookup;
uint32_t ofsTexAnimLookup;
math::vector_3d bounding_box_min;
math::vector_3d bounding_box_max;
glm::vec3 bounding_box_min;
glm::vec3 bounding_box_max;
float bounding_box_radius;
math::vector_3d collision_box_min;
math::vector_3d collision_box_max;
glm::vec3 collision_box_min;
glm::vec3 collision_box_max;
float collision_box_radius;
uint32_t nBoundingTriangles;
@@ -125,7 +125,7 @@ struct ModelAnimation {
uint32_t d2;
uint32_t playSpeed; // note: this can't be play speed because it's 0 for some models
math::vector_3d boxA, boxB;
glm::vec3 boxA, boxB;
float rad;
int16_t NextAnimation;
@@ -163,10 +163,10 @@ struct ModelTexAnimDef {
};
struct ModelVertex {
math::vector_3d position;
glm::vec3 position;
uint8_t weights[4];
uint8_t bones[4];
math::vector_3d normal;
glm::vec3 normal;
glm::vec2 texcoords[2];
};
@@ -192,7 +192,7 @@ struct ModelGeoset {
uint16_t d4; // ? always 1 to 4
uint16_t d5; // ?
uint16_t d6; // root bone?
math::vector_3d BoundingBox[2];
glm::vec3 BoundingBox[2];
float radius;
};
@@ -249,7 +249,7 @@ struct ModelTextureDef {
struct ModelLightDef {
int16_t type;
int16_t bone;
math::vector_3d pos;
glm::vec3 pos;
AnimationBlock ambColor;
AnimationBlock ambIntensity;
AnimationBlock color;
@@ -263,9 +263,9 @@ struct ModelCameraDef {
int32_t id;
float fov, farclip, nearclip;
AnimationBlock transPos;
math::vector_3d pos;
glm::vec3 pos;
AnimationBlock transTarget;
math::vector_3d target;
glm::vec3 target;
AnimationBlock rot;
};
@@ -295,7 +295,7 @@ struct ModelParticleParams {
struct ModelParticleEmitterDef {
int32_t id;
int32_t flags;
math::vector_3d pos; // The position. Relative to the following bone.
glm::vec3 pos; // The position. Relative to the following bone.
int16_t bone; // The bone its attached to.
int16_t texture; // And the texture that is used.
int32_t nModelFileName;
@@ -330,7 +330,7 @@ struct ModelParticleEmitterDef {
struct ModelRibbonEmitterDef {
int32_t id;
int32_t bone;
math::vector_3d pos;
glm::vec3 pos;
int32_t nTextures;
int32_t ofsTextures;
int32_t nMaterials;
@@ -351,7 +351,7 @@ struct ModelEvents {
char id[4];
int32_t data;
int32_t bone;
math::vector_3d pos;
glm::vec3 pos;
int16_t type;
int16_t seq;
uint32_t nTimes;
@@ -361,7 +361,7 @@ struct ModelEvents {
struct ModelAttachmentDef {
int32_t id;
int32_t bone;
math::vector_3d pos;
glm::vec3 pos;
AnimationBlock Enabled;
};
@@ -373,7 +373,7 @@ struct ModelBoneDef {
AnimationBlock translation;
AnimationBlock rotation;
AnimationBlock scaling;
math::vector_3d pivot;
glm::vec3 pivot;
};
struct ModelBoundTriangle {

View File

@@ -23,11 +23,8 @@ ModelInstance::ModelInstance(std::string const& filename, ENTRY_MDDF const*d, no
, model (filename, context)
{
uid = d->uniqueID;
pos = math::vector_3d(d->pos[0], d->pos[1], d->pos[2]);
dir = math::degrees::vec3( math::degrees(d->rot[0])
, math::degrees(d->rot[1])
, math::degrees(d->rot[2])
);
pos = glm::vec3(d->pos[0], d->pos[1], d->pos[2]);
dir = math::degrees::vec3( math::degrees(d->rot[0])._, math::degrees(d->rot[1])._, math::degrees(d->rot[2])._);
// scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float?
scale = d->scale / 1024.0f;
@@ -126,7 +123,7 @@ bool ModelInstance::isInFrustum(const math::frustum& frustum)
return true;
}
bool ModelInstance::isInRenderDist(const float& cull_distance, const math::vector_3d& camera, display_mode display)
bool ModelInstance::isInRenderDist(const float& cull_distance, const glm::vec3& camera, display_mode display)
{
float dist;
@@ -178,12 +175,8 @@ void ModelInstance::recalcExtents()
updateTransformMatrix();
math::aabb const relative_to_model
( math::min ( model->header.collision_box_min
, model->header.bounding_box_min
)
, math::max ( model->header.collision_box_max
, model->header.bounding_box_max
)
( glm::min ( model->header.collision_box_min, model->header.bounding_box_min)
, glm::max ( model->header.collision_box_max, model->header.bounding_box_max)
);
//! \todo If both boxes are {inf, -inf}, or well, if any min.c > max.c,
@@ -212,7 +205,7 @@ void ModelInstance::ensureExtents()
}
}
math::vector_3d* ModelInstance::getExtents()
glm::vec3* ModelInstance::getExtents()
{
if (_need_recalc_extents && model->finishedLoading())
{
@@ -229,7 +222,7 @@ wmo_doodad_instance::wmo_doodad_instance(std::string const& filename, MPQFile* f
float ff[4];
f->read(ff, 12);
pos = math::vector_3d(ff[0], ff[2], -ff[1]);
pos = glm::vec3(ff[0], ff[2], -ff[1]);
f->read(ff, 16);
doodad_orientation = glm::quat (-ff[0], -ff[2], ff[1], ff[3]);
@@ -247,7 +240,7 @@ wmo_doodad_instance::wmo_doodad_instance(std::string const& filename, MPQFile* f
f->read(&color.packed, 4);
light_color = math::vector_3d(color.bgra.r / 255.f, color.bgra.g / 255.f, color.bgra.b / 255.f);
light_color = glm::vec3(color.bgra.r / 255.f, color.bgra.g / 255.f, color.bgra.b / 255.f);
}
void wmo_doodad_instance::update_transform_matrix_wmo(WMOInstance* wmo)

View File

@@ -3,7 +3,7 @@
#pragma once
#include <math/ray.hpp>
#include <math/vector_3d.hpp> // math::vector_3d
#include <math/vector_3d.hpp> // glm::vec3
#include <noggit/MPQ.h> // MPQFile
#include <noggit/MapHeaders.h> // ENTRY_MDDF
#include <noggit/ModelManager.h>
@@ -28,7 +28,7 @@ public:
scoped_model_reference model;
math::vector_3d light_color = { 1.f, 1.f, 1.f };
glm::vec3 light_color = { 1.f, 1.f, 1.f };
// used when flag 0x8 is set in wdt
// longest side of an AABB transformed model's bounding box from the M2 header
@@ -89,15 +89,15 @@ public:
bool isInFrustum(math::frustum const& frustum);
bool isInRenderDist(const float& cull_distance, const math::vector_3d& camera, display_mode display);
bool isInRenderDist(const float& cull_distance, const glm::vec3& camera, display_mode display);
[[nodiscard]]
virtual math::vector_3d const& get_pos() const { return pos; }
virtual glm::vec3 const& get_pos() const { return pos; }
void recalcExtents() override;
void ensureExtents() override;
bool finishedLoading() override { return model->finishedLoading(); };
math::vector_3d* getExtents();
glm::vec3* getExtents();
[[nodiscard]]
virtual bool isWMODoodad() const { return false; };
@@ -119,7 +119,7 @@ class wmo_doodad_instance : public ModelInstance
{
public:
glm::quat doodad_orientation;
math::vector_3d world_pos;
glm::vec3 world_pos;
explicit wmo_doodad_instance(std::string const& filename
, MPQFile* f
@@ -158,7 +158,7 @@ public:
void update_transform_matrix_wmo(WMOInstance* wmo);
virtual math::vector_3d const& get_pos() const override { return world_pos; };
virtual glm::vec3 const& get_pos() const override { return world_pos; };
[[nodiscard]]
virtual bool isWMODoodad() const override { return true; };

View File

@@ -57,8 +57,8 @@ ParticleSystem::ParticleSystem(Model* model_
, tofs (misc::frand())
, _context(context)
{
math::vector_3d colors2[3];
memcpy(colors2, f.getBuffer() + mta.p.colors.ofsKeys, sizeof(math::vector_3d) * 3);
glm::vec3 colors2[3];
memcpy(colors2, f.getBuffer() + mta.p.colors.ofsKeys, sizeof(glm::vec3) * 3);
for (size_t i = 0; i<3; ++i) {
float opacity = *reinterpret_cast<int16_t const*>(f.getBuffer() + mta.p.opacity.ofsKeys + i * 2);
colors[i] = glm::vec4(colors2[i].x / 255.0f, colors2[i].y / 255.0f, colors2[i].z / 255.0f, opacity / 32767.0f);
@@ -307,17 +307,17 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
//model->_textures[_texture_id]->bind();
math::vector_3d vRight(1, 0, 0);
math::vector_3d vUp(0, 1, 0);
glm::vec3 vRight(1, 0, 0);
glm::vec3 vUp(0, 1, 0);
// position stuff
const float f = 1;//0.707106781f; // sqrt(2)/2
math::vector_3d bv0 = math::vector_3d(-f, +f, 0);
math::vector_3d bv1 = math::vector_3d(+f, +f, 0);
glm::vec3 bv0 = glm::vec3(-f, +f, 0);
glm::vec3 bv1 = glm::vec3(+f, +f, 0);
std::vector<std::uint16_t> indices;
std::vector<math::vector_3d> vertices;
std::vector<math::vector_3d> offsets;
std::vector<glm::vec3> vertices;
std::vector<glm::vec3> offsets;
std::vector<glm::vec4> colors_data;
std::vector<glm::vec2> texcoords;
@@ -325,9 +325,9 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
if (billboard)
{
vRight = math::vector_3d(model_view[0], model_view[4], model_view[8]);
vUp = math::vector_3d(model_view[1], model_view[5], model_view[9]); // Spherical billboarding
//vUp = math::vector_3d(0,1,0); // Cylindrical billboarding
vRight = glm::vec3(model_view[0], model_view[4], model_view[8]);
vUp = glm::vec3(model_view[1], model_view[5], model_view[9]); // Spherical billboarding
//vUp = glm::vec3(0,1,0); // Cylindrical billboarding
}
auto add_quad_indices([] (std::vector<std::uint16_t>& indices, std::uint16_t& start)
@@ -423,12 +423,12 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
{ // Sphere particles
// particles from origin to position
/*
bv0 = mbb * math::vector_3d(0,-1.0f,0);
bv1 = mbb * math::vector_3d(0,+1.0f,0);
bv0 = mbb * glm::vec3(0,-1.0f,0);
bv1 = mbb * glm::vec3(0,+1.0f,0);
bv0 = mbb * math::vector_3d(-1.0f,0,0);
bv1 = mbb * math::vector_3d(1.0f,0,0);
bv0 = mbb * glm::vec3(-1.0f,0,0);
bv1 = mbb * glm::vec3(1.0f,0,0);
*/
for (ParticleList::iterator it = particles.begin(); it != particles.end(); ++it)
@@ -458,7 +458,7 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
}
}
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_vertices_vbo, vertices, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec4>(_colors_vbo, colors_data, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STREAM_DRAW);
@@ -474,7 +474,7 @@ void ParticleSystem::draw( math::matrix_4x4 const& model_view
}
if(billboard)
{
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_offsets_vbo, offsets, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_offsets_vbo, offsets, GL_STREAM_DRAW);
opengl::scoped::buffer_binder<GL_ARRAY_BUFFER> const offset_binder (_offsets_vbo);
shader.attrib("offset", 3, GL_FLOAT, GL_FALSE, 0, 0);
@@ -610,57 +610,57 @@ Particle PlaneParticleEmitter::newParticle(ParticleSystem* sys, int anim, int ti
auto mrot = sys->parent->mrot*CalcSpreadMatrix(spr, spr, 1.0f, 1.0f);
if (sys->flags == 1041) { // Trans Halo
p.pos = sys->parent->mat * (sys->pos + math::vector_3d(misc::randfloat(-l, l), 0, misc::randfloat(-w, w)));
p.pos = sys->parent->mat * (sys->pos + glm::vec3(misc::randfloat(-l, l), 0, misc::randfloat(-w, w)));
const float t = misc::randfloat(0.0f, 2.0f * glm::pi<float>());
p.pos = math::vector_3d(0.0f, sys->pos.y + 0.15f, sys->pos.z) + math::vector_3d(cos(t) / 8, 0.0f, sin(t) / 8); // Need to manually correct for the halo - why?
p.pos = glm::vec3(0.0f, sys->pos.y + 0.15f, sys->pos.z) + glm::vec3(cos(t) / 8, 0.0f, sin(t) / 8); // Need to manually correct for the halo - why?
// var isn't being used, which is set to 1.0f, whats the importance of this?
// why does this set of values differ from other particles
math::vector_3d dir(0.0f, 1.0f, 0.0f);
glm::vec3 dir(0.0f, 1.0f, 0.0f);
p.dir = dir;
p.speed = dir.normalize() * spd * misc::randfloat(0, var);
p.speed = glm::normalize(dir) * spd * misc::randfloat(0, var);
}
else if (sys->flags == 25 && sys->parent->parent<1) { // Weapon Flame
p.pos = sys->parent->pivot + (sys->pos + math::vector_3d(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
math::vector_3d dir = mrot * math::vector_3d(0.0f, 1.0f, 0.0f);
p.dir = dir.normalize();
//math::vector_3d dir = sys->model->bones[sys->parent->parent].mrot * sys->parent->mrot * math::vector_3d(0.0f, 1.0f, 0.0f);
p.pos = sys->parent->pivot + (sys->pos + glm::vec3(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
glm::vec3 dir = mrot * glm::vec3(0.0f, 1.0f, 0.0f);
p.dir = glm::normalize(dir);
//glm::vec3 dir = sys->model->bones[sys->parent->parent].mrot * sys->parent->mrot * glm::vec3(0.0f, 1.0f, 0.0f);
//p.speed = dir.normalize() * spd;
}
else if (sys->flags == 25 && sys->parent->parent > 0) { // Weapon with built-in Flame (Avenger lightsaber!)
p.pos = sys->parent->mat * (sys->pos + math::vector_3d(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
math::vector_3d dir = math::vector_3d(sys->parent->mat (1, 0), sys->parent->mat (1, 1), sys->parent->mat (1, 2)) + math::vector_3d(0.0f, 1.0f, 0.0f);
p.speed = dir.normalize() * spd * misc::randfloat(0, var * 2);
p.pos = sys->parent->mat * (sys->pos + glm::vec3(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
glm::vec3 dir = glm::vec3(sys->parent->mat (1, 0), sys->parent->mat (1, 1), sys->parent->mat (1, 2)) + glm::vec3(0.0f, 1.0f, 0.0f);
p.speed = glm::normalize(dir) * spd * misc::randfloat(0, var * 2);
}
else if (sys->flags == 17 && sys->parent->parent<1) { // Weapon Glow
p.pos = sys->parent->pivot + (sys->pos + math::vector_3d(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
math::vector_3d dir = mrot * math::vector_3d(0, 1, 0);
p.dir = dir.normalize();
p.pos = sys->parent->pivot + (sys->pos + glm::vec3(misc::randfloat(-l, l), misc::randfloat(-l, l), misc::randfloat(-w, w)));
glm::vec3 dir = mrot * glm::vec3(0, 1, 0);
p.dir = glm::normalize(dir);
}
else {
p.pos = sys->pos + math::vector_3d(misc::randfloat(-l, l), 0, misc::randfloat(-w, w));
p.pos = sys->pos + glm::vec3(misc::randfloat(-l, l), 0, misc::randfloat(-w, w));
p.pos = sys->parent->mat * p.pos;
//math::vector_3d dir = mrot * math::vector_3d(0,1,0);
math::vector_3d dir = sys->parent->mrot * math::vector_3d(0, 1, 0);
//glm::vec3 dir = mrot * glm::vec3(0,1,0);
glm::vec3 dir = sys->parent->mrot * glm::vec3(0, 1, 0);
p.dir = dir;//.normalize();
p.down = math::vector_3d(0, -1.0f, 0); // dir * -1.0f;
p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var));
p.down = glm::vec3(0, -1.0f, 0); // dir * -1.0f;
p.speed = glm::normalize(dir) * spd * (1.0f + misc::randfloat(-var, var));
}
if (!sys->billboard) {
p.corners[0] = mrot * math::vector_3d(-1, 0, +1);
p.corners[1] = mrot * math::vector_3d(+1, 0, +1);
p.corners[2] = mrot * math::vector_3d(+1, 0, -1);
p.corners[3] = mrot * math::vector_3d(-1, 0, -1);
p.corners[0] = mrot * glm::vec3(-1, 0, +1);
p.corners[1] = mrot * glm::vec3(+1, 0, +1);
p.corners[2] = mrot * glm::vec3(+1, 0, -1);
p.corners[3] = mrot * glm::vec3(-1, 0, -1);
}
p.life = 0;
@@ -675,7 +675,7 @@ Particle PlaneParticleEmitter::newParticle(ParticleSystem* sys, int anim, int ti
Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int time, int animtime, float w, float l, float spd, float var, float spr, float spr2)
{
Particle p;
math::vector_3d dir;
glm::vec3 dir;
float radius;
radius = misc::randfloat(0, 1);
@@ -700,18 +700,18 @@ Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int t
// l = w;
// New method
// math::vector_3d bdir(w*math::cos(t), 0.0f, l*math::sin(t));
// glm::vec3 bdir(w*math::cos(t), 0.0f, l*math::sin(t));
// --
//! \todo fix shpere emitters to work properly
/* // Old Method
//math::vector_3d bdir(l*math::cos(t), 0, w*math::sin(t));
//math::vector_3d bdir(0, w*math::cos(t), l*math::sin(t));
//glm::vec3 bdir(l*math::cos(t), 0, w*math::sin(t));
//glm::vec3 bdir(0, w*math::cos(t), l*math::sin(t));
float theta_range = sys->spread.getValue(anim, time, animtime);
float theta = -0.5f* theta_range + misc::randfloat(0, theta_range);
math::vector_3d bdir(0, l*math::cos(theta), w*math::sin(theta));
glm::vec3 bdir(0, l*math::cos(theta), w*math::sin(theta));
float phi_range = sys->lat.getValue(anim, time, animtime);
float phi = misc::randfloat(0, phi_range);
@@ -719,24 +719,24 @@ Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int t
*/
if (sys->flags == 57 || sys->flags == 313) { // Faith Halo
math::vector_3d bdir(w*math::cos(t)*1.6f, 0.0f, l*math::sin(t)*1.6f);
glm::vec3 bdir(w*math::cos(t)*1.6f, 0.0f, l*math::sin(t)*1.6f);
p.pos = sys->pos + bdir;
p.pos = sys->parent->mat * p.pos;
if (bdir.length_squared() == 0)
p.speed = math::vector_3d(0, 0, 0);
if (glm::length(bdir) * glm::length(bdir) == 0)
p.speed = glm::vec3(0, 0, 0);
else {
dir = sys->parent->mrot * (bdir.normalize());//mrot * math::vector_3d(0, 1.0f,0);
p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var)); // ?
dir = sys->parent->mrot * (glm::normalize(bdir));//mrot * glm::vec3(0, 1.0f,0);
p.speed = glm::normalize(dir) * spd * (1.0f + misc::randfloat(-var, var)); // ?
}
}
else {
math::vector_3d bdir;
glm::vec3 bdir;
float temp;
bdir = mrot * math::vector_3d(0, 1, 0) * radius;
bdir = mrot * glm::vec3(0, 1, 0) * radius;
temp = bdir.z;
bdir.z = bdir.y;
bdir.y = temp;
@@ -748,24 +748,24 @@ Particle SphereParticleEmitter::newParticle(ParticleSystem* sys, int anim, int t
//p.pos = sys->parent->mat * p.pos;
if (!bdir.length_squared() && !(sys->flags & 0x100))
if (!(glm::length(bdir) * glm::length(bdir)) && !(sys->flags & 0x100))
{
p.speed = math::vector_3d(0, 0, 0);
dir = sys->parent->mrot * math::vector_3d(0, 1, 0);
p.speed = glm::vec3(0, 0, 0);
dir = sys->parent->mrot * glm::vec3(0, 1, 0);
}
else
{
if (sys->flags & 0x100)
dir = sys->parent->mrot * math::vector_3d(0, 1, 0);
dir = sys->parent->mrot * glm::vec3(0, 1, 0);
else
dir = bdir.normalize();
dir = glm::normalize(bdir);
p.speed = dir.normalize() * spd * (1.0f + misc::randfloat(-var, var)); // ?
p.speed = glm::normalize(dir) * spd * (1.0f + misc::randfloat(-var, var)); // ?
}
}
p.dir = dir.normalize();//mrot * math::vector_3d(0, 1.0f,0);
p.down = math::vector_3d(0, -1.0f, 0);
p.dir = glm::normalize(dir);//mrot * glm::vec3(0, 1.0f,0);
p.down = glm::vec3(0, -1.0f, 0);
p.life = 0;
p.maxlife = sys->lifespan.getValue(anim, time, animtime);
@@ -855,10 +855,10 @@ RibbonEmitter::RibbonEmitter(RibbonEmitter&& other)
void RibbonEmitter::setup(int anim, int time, int animtime)
{
math::vector_3d ntpos = parent->mat * pos;
math::vector_3d ntup = parent->mat * (pos + math::vector_3d(0, 0, 1));
glm::vec3 ntpos = parent->mat * pos;
glm::vec3 ntup = parent->mat * (pos + glm::vec3(0, 0, 1));
ntup -= ntpos;
ntup.normalize();
ntup = glm::normalize(ntup);
float dlen = (ntpos - tpos).length();
manim = anim;
@@ -868,7 +868,7 @@ void RibbonEmitter::setup(int anim, int time, int animtime)
RibbonSegment &first = *segs.begin();
if (first.len > seglen) {
// add new segment
first.back = (tpos - ntpos).normalize();
first.back = glm::normalize((tpos - ntpos));
first.len0 = first.len;
RibbonSegment newseg (ntpos, dlen);
newseg.up = ntup;
@@ -916,7 +916,7 @@ void RibbonEmitter::draw( opengl::scoped::use_program& shader
}
std::vector<std::uint16_t> indices;
std::vector<math::vector_3d> vertices;
std::vector<glm::vec3> vertices;
std::vector<glm::vec2> texcoords;
//model->_textures[_texture_ids[0]]->bind();
@@ -965,7 +965,7 @@ void RibbonEmitter::draw( opengl::scoped::use_program& shader
vertices.push_back(it->pos - tbelow * it->up + (it->len / it->len0) * it->back);
}
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_vertices_vbo, vertices, GL_STREAM_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec2>(_texcoord_vbo, texcoords, GL_STREAM_DRAW);
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STREAM_DRAW);

View File

@@ -18,9 +18,9 @@ class ParticleSystem;
class RibbonEmitter;
struct Particle {
math::vector_3d pos, speed, down, origin, dir;
math::vector_3d corners[4];
//math::vector_3d tpos;
glm::vec3 pos, speed, down, origin, dir;
glm::vec3 corners[4];
//glm::vec3 tpos;
float size, life, maxlife;
unsigned int tile;
glm::vec4 color;
@@ -61,7 +61,7 @@ class ParticleSystem
std::array<glm::vec4, 3> colors;
std::array<float,3> sizes;
float mid, slowdown;
math::vector_3d pos;
glm::vec3 pos;
uint16_t _texture_id;
ParticleList particles;
int blend, order, type;
@@ -122,9 +122,9 @@ private:
struct RibbonSegment
{
math::vector_3d pos, up, back;
glm::vec3 pos, up, back;
float len, len0;
RibbonSegment (::math::vector_3d pos_, float len_)
RibbonSegment (::glm::vec3 pos_, float len_)
: pos (pos_)
, len (len_)
{}
@@ -134,19 +134,19 @@ class RibbonEmitter
{
Model *model;
Animation::M2Value<math::vector_3d> color;
Animation::M2Value<glm::vec3> color;
Animation::M2Value<float, int16_t> opacity;
Animation::M2Value<float> above, below;
Bone *parent;
math::vector_3d pos;
glm::vec3 pos;
int manim, mtime;
int seglen;
float length;
math::vector_3d tpos;
glm::vec3 tpos;
glm::vec4 tcolor;
float tabove, tbelow;

View File

@@ -229,7 +229,7 @@ void BrushStack::addAction(BrushStackItem* brush_stack_item)
}
void BrushStack::execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
void BrushStack::execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
{
for (int i = 0; i < _ui.brushList->layout()->count(); ++i)
{

View File

@@ -24,7 +24,7 @@ namespace noggit::Red
public:
BrushStack(MapView* map_view, QWidget* parent = nullptr);
void execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
void execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
void changeRadius(float change);
void changeInnerRadius(float change);

View File

@@ -386,7 +386,7 @@ void BrushStackItem::setMaskRotation(int rot)
}
}
void BrushStackItem::execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
void BrushStackItem::execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map)
{
auto action = noggit::ActionManager::instance()->getCurrentAction();

View File

@@ -58,7 +58,7 @@ namespace noggit::Red
void setSpeed(float speed);
void setMaskRotation(int rot);
void setBrushMode(bool sculpt);
void execute(math::vector_3d const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
void execute(glm::vec3 const& cursor_pos, World* world, float dt, bool mod_shift_down, bool mod_alt_down, bool mod_ctrl_down, bool is_under_map);
void syncSliders(double radius, double inner_radius, double speed, int rot, int brushMode);
bool isRadiusAffecting() { return _is_radius_affecting->isChecked(); };

View File

@@ -200,7 +200,7 @@ void ChunkAddDetailDoodads::compute()
subchunkStatuses |= mask;
unsigned const curOfs{curSplat[1] * 17 + curSplat[0]};
using namespace math;
vector_3d const* curOrigin{chunk->getHeightmap() + curOfs};
glm::vec3 const* curOrigin{chunk->getHeightmap() + curOfs};
float const ref{curOrigin[9].y};
std::array<float, 2> rels;
std::array<float, 2> relHs;
@@ -331,7 +331,7 @@ void ChunkAddDetailDoodads::compute()
filename = filename.replace(".mdx", ".m2", Qt::CaseInsensitive);
world->addM2(filename.toStdString(), {chunk->xbase - inMinichunkCoords[0]
, 0, chunk->zbase - inMinichunkCoords[1]}, 1.0, {0_deg, 0_deg, 0_deg}, nullptr);
, 0, chunk->zbase - inMinichunkCoords[1]}, 1.0, {(0_deg)._, (0_deg)._, (0_deg)._ }, nullptr);
}
}

View File

@@ -31,7 +31,7 @@ void ChunkGetHeightmapNode::compute()
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
math::vector_3d* heightmap = chunk->getHeightmap();
glm::vec3* heightmap = chunk->getHeightmap();
_heightmap.clear();
_heightmap.resize(mapbufsize);

View File

@@ -30,14 +30,14 @@ void ChunkGetVertexColorsNode::compute()
opengl::context::scoped_setter const _ (::gl, gCurrentContext->getViewport()->context());
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
math::vector_3d* colors = chunk->getVertexColors();
glm::vec3* colors = chunk->getVertexColors();
_colors.clear();
_colors.resize(mapbufsize);
for (int i = 0; i < mapbufsize; ++i)
{
math::vector_3d& color = colors[i];
glm::vec3& color = colors[i];
_colors[i] = std::make_shared<ColorData>(glm::vec4(color.x, color.y, color.z, 1.0));
}

View File

@@ -31,7 +31,7 @@ void ChunkSetHeightmapNode::compute()
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
auto list = defaultPortData<ListData>(PortType::In, 2)->value();
math::vector_3d* heightmap = chunk->getHeightmap();
glm::vec3* heightmap = chunk->getHeightmap();
for (int i = 0; i < mapbufsize; ++i)
{

View File

@@ -32,7 +32,7 @@ void ChunkSetVertexColorsNode::compute()
MapChunk* chunk = defaultPortData<ChunkData>(PortType::In, 1)->value();
auto list = defaultPortData<ListData>(PortType::In, 2)->value();
math::vector_3d* colors = chunk->getVertexColors();
glm::vec3* colors = chunk->getVertexColors();
for (int i = 0; i < mapbufsize; ++i)
{

View File

@@ -34,7 +34,7 @@ void GetChunkFromPosNode::compute()
auto pos_data = defaultPortData<Vector3DData>(PortType::In, 1);
glm::vec3 const& pos = pos_data->value();
math::vector_3d n_pos(pos.x, pos.y, pos.z);
glm::vec3 n_pos(pos.x, pos.y, pos.z);
MapTile* tile(world->mapIndex.getTile(n_pos));

View File

@@ -33,7 +33,7 @@ void GetTileFromPosNode::compute()
auto pos_data = defaultPortData<Vector3DData>(PortType::In, 1);
glm::vec3 const& pos = pos_data->value();
math::vector_3d n_pos(pos.x, pos.y, pos.z);
glm::vec3 n_pos(pos.x, pos.y, pos.z);
world->mapIndex.loadTile(n_pos);
MapTile* tile(world->mapIndex.getTile(n_pos));

View File

@@ -34,7 +34,7 @@ void HasTileAtPosNode::compute()
_out_ports[0].out_value = std::make_shared<LogicData>(true);
_node->onDataUpdated(0);
_out_ports[1].out_value = std::make_shared<BooleanData>(world->mapIndex.hasTile(math::vector_3d(pos.x, pos.y, pos.z)));
_out_ports[1].out_value = std::make_shared<BooleanData>(world->mapIndex.hasTile(glm::vec3(pos.x, pos.y, pos.z)));
_node->onDataUpdated(1);
}

View File

@@ -29,7 +29,7 @@ void CropWaterADTAtPosNode::compute()
auto pos_data = defaultPortData<Vector3DData>(PortType::In, 1);
glm::vec3 const& pos = pos_data->value();
math::vector_3d n_pos(pos.x, pos.y, pos.z);
glm::vec3 n_pos(pos.x, pos.y, pos.z);
world->mapIndex.loadTile(n_pos);
MapTile* tile(world->mapIndex.getTile(n_pos));

View File

@@ -31,7 +31,7 @@ void GetWaterTypeNode::compute()
unsigned layer = defaultPortData<UnsignedIntegerData>(PortType::In, 1)->value();
math::vector_3d n_pos(pos.x, pos.y, pos.z);
glm::vec3 n_pos(pos.x, pos.y, pos.z);
world->mapIndex.loadTile(n_pos);
MapTile* tile(world->mapIndex.getTile(n_pos));

View File

@@ -46,7 +46,7 @@ void SetWaterTypeNode::compute()
unsigned layer = defaultPortData<UnsignedIntegerData>(PortType::In, 2)->value();
math::vector_3d n_pos(pos.x, pos.y, pos.z);
glm::vec3 n_pos(pos.x, pos.y, pos.z);
world->mapIndex.loadTile(n_pos);
MapTile* tile(world->mapIndex.getTile(n_pos));

View File

@@ -58,11 +58,11 @@ void AddObjectInstanceNode::compute()
if (QString(path.c_str()).endsWith(".m2", Qt::CaseInsensitive))
{
noggit::object_paste_params paste_params;
obj = world->addM2AndGetInstance(path, {pos.x, pos.y, pos.z}, scale, {math::degrees(dir.x), math::degrees(dir.y), math::degrees(dir.z)}, &paste_params);
obj = world->addM2AndGetInstance(path, {pos.x, pos.y, pos.z}, scale, {math::degrees(dir.x)._, math::degrees(dir.y)._, math::degrees(dir.z)._ }, &paste_params);
}
else if (QString(path.c_str()).endsWith(".wmo", Qt::CaseInsensitive))
{
obj = world->addWMOAndGetInstance(path, {pos.x, pos.y, pos.z}, {math::degrees(dir.x), math::degrees(dir.y), math::degrees(dir.z)});
obj = world->addWMOAndGetInstance(path, {pos.x, pos.y, pos.z}, {math::degrees(dir.x)._, math::degrees(dir.y)._, math::degrees(dir.z)._ });
}
else
{

View File

@@ -36,13 +36,13 @@ void ObjectInstanceInfoNode::compute()
if (_out_ports[0].connected)
{
_out_ports[0].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->pos.x, obj->pos.y, obj->pos.z));
_out_ports[0].out_value = std::make_shared<Vector3DData>(obj->pos);
_node->onDataUpdated(0);
}
if (_out_ports[1].connected)
{
_out_ports[1].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->dir.x._, obj->dir.y._, obj->dir.z._));
_out_ports[1].out_value = std::make_shared<Vector3DData>(obj->dir);
_node->onDataUpdated(1);
}
@@ -54,17 +54,13 @@ void ObjectInstanceInfoNode::compute()
if (_out_ports[3].connected)
{
_out_ports[3].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->extents[0].x,
obj->extents[0].y,
obj->extents[0].z));
_out_ports[3].out_value = std::make_shared<Vector3DData>(obj->extents[0]);
_node->onDataUpdated(3);
}
if (_out_ports[4].connected)
{
_out_ports[4].out_value = std::make_shared<Vector3DData>(glm::vec3(obj->extents[1].x,
obj->extents[1].y,
obj->extents[1].z));
_out_ports[4].out_value = std::make_shared<Vector3DData>(obj->extents[1]);
_node->onDataUpdated(4);
}

View File

@@ -34,9 +34,9 @@ void ObjectInstanceSetRotationNode::compute()
auto rot_data = defaultPortData<Vector3DData>(PortType::In, 2);
glm::vec3 const& rotation = rot_data->value();
obj->dir.x = math::degrees(rotation.x);
obj->dir.y = math::degrees(rotation.y);
obj->dir.z = math::degrees(rotation.z);
obj->dir.x = math::degrees(rotation.x)._;
obj->dir.y = math::degrees(rotation.y)._;
obj->dir.z = math::degrees(rotation.z)._;
obj->recalcExtents();

View File

@@ -34,7 +34,7 @@ void TileGetVertexNode::compute()
auto xy_data = defaultPortData<Vector2DData>(PortType::In, 2);
glm::vec2 const& xy = xy_data->value();
math::vector_3d n_pos(0.0f, 0.0f, 0.0f);
glm::vec3 n_pos(0.0f, 0.0f, 0.0f);
tile->GetVertex(xy.x, xy.y, &n_pos);

View File

@@ -33,14 +33,14 @@ void ModelViewer::paintGL()
{
_world->draw(world_model_view().transposed()
, world_projection().transposed()
, math::vector_3d(0.f, 0.f, 0.f)
, glm::vec3(0.f, 0.f, 0.f)
, 0.f
, glm::vec4(1.f, 1.f, 1.f, 1.f)
, CursorType::CIRCLE
, 0.f
, false
, 0.f
, math::vector_3d(0.f, 0.f, 0.f)
, glm::vec3(0.f, 0.f, 0.f)
, 0.f
, 0.f
, false

View File

@@ -121,7 +121,7 @@ void PresetEditorWidget::setupConnectsCommon()
);
connect(ui->minimapWidget, &minimap_widget::map_clicked
, [this] (::math::vector_3d const& pos)
, [this] (::glm::vec3 const& pos)
{
ui->viewport->getWorldCamera()->position = pos;
}

View File

@@ -25,7 +25,7 @@ using namespace noggit::Red;
PreviewRenderer::PreviewRenderer(int width, int height, noggit::NoggitRenderContext context, QWidget* parent)
: noggit::Red::ViewportManager::Viewport(parent)
, _camera (math::vector_3d(0.0f, 0.0f, 0.0f), math::degrees(0.0f), math::degrees(0.0f))
, _camera (glm::vec3(0.0f, 0.0f, 0.0f), math::degrees(0.0f), math::degrees(0.0f))
, _settings (new QSettings())
, _width(width)
, _height(height)
@@ -45,7 +45,7 @@ PreviewRenderer::PreviewRenderer(int width, int height, noggit::NoggitRenderCont
opengl::context::scoped_setter const context_set (::gl, &_offscreen_context);
_light_dir = math::vector_3d(0.0f, 1.0f, 0.0f);
_light_dir = glm::vec3(0.0f, 1.0f, 0.0f);
}
void PreviewRenderer::setModel(std::string const &filename)
@@ -113,7 +113,7 @@ void PreviewRenderer::resetCamera(float x, float y, float z, float roll, float y
_camera.reset(x, y, z, roll, yaw, pitch);
float radius = 0.f;
std::vector<math::vector_3d> extents = calcSceneExtents();
std::vector<glm::vec3> extents = calcSceneExtents();
_camera.position = (extents[0] + extents[1]) / 2.0f;
radius = std::max((_camera.position - extents[0]).length(), (_camera.position - extents[1]).length());
@@ -211,10 +211,10 @@ void PreviewRenderer::draw()
//water_shader.uniform("model_view", model_view().transposed());
//water_shader.uniform("projection", projection().transposed());
glm::vec4ocean_color_light(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
glm::vec4ocean_color_dark(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
glm::vec4river_color_light(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
glm::vec4river_color_dark(math::vector_3d(1.0f, 1.0f, 1.0f), 1.f);
glm::vec4ocean_color_light(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
glm::vec4ocean_color_dark(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
glm::vec4river_color_light(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
glm::vec4river_color_dark(glm::vec3(1.0f, 1.0f, 1.0f), 1.f);
//water_shader.uniform("ocean_color_light", ocean_color_light);
//water_shader.uniform("ocean_color_dark", ocean_color_dark);
@@ -243,7 +243,7 @@ void PreviewRenderer::draw()
{
wmo_instance.draw(
wmo_program, model_view().transposed(), projection().transposed(), frustum, culldistance,
math::vector_3d(0.0f, 0.0f, 0.0f), _draw_boxes.get(), _draw_models.get() // doodads
glm::vec3(0.0f, 0.0f, 0.0f), _draw_boxes.get(), _draw_models.get() // doodads
, false, std::vector<selection_type>(), 0, false, display_mode::in_3D
);
@@ -410,7 +410,7 @@ void PreviewRenderer::draw()
if (_draw_grid.get())
{
_grid.draw(mvp, math::vector_3d(0.f, 0.f, 0.f),
_grid.draw(mvp, glm::vec3(0.f, 0.f, 0.f),
glm::vec4(0.7f, 0.7f, 0.7f, 1.0f), 30.f);
}
@@ -433,13 +433,13 @@ float PreviewRenderer::aspect_ratio() const
return static_cast<float>(_width) / static_cast<float>(_height);
}
std::vector<math::vector_3d> PreviewRenderer::calcSceneExtents()
std::vector<glm::vec3> PreviewRenderer::calcSceneExtents()
{
math::vector_3d min = {std::numeric_limits<float>::max(),
glm::vec3 min = {std::numeric_limits<float>::max(),
std::numeric_limits<float>::max(),
std::numeric_limits<float>::max()};
math::vector_3d max = {std::numeric_limits<float>::min(),
glm::vec3 max = {std::numeric_limits<float>::min(),
std::numeric_limits<float>::min(),
std::numeric_limits<float>::min()};
@@ -461,7 +461,7 @@ std::vector<math::vector_3d> PreviewRenderer::calcSceneExtents()
}
}
return std::move(std::vector<math::vector_3d>{min, max});
return std::move(std::vector<glm::vec3>{min, max});
}
QPixmap* PreviewRenderer::renderToPixmap()

View File

@@ -74,7 +74,7 @@ class PreviewRenderer : public noggit::Red::ViewportManager::Viewport
bool _destroying = false;
std::vector<math::vector_3d> calcSceneExtents();
std::vector<glm::vec3> calcSceneExtents();
virtual void draw();
virtual void tick(float dt);
virtual math::matrix_4x4 model_view() const;
@@ -97,10 +97,10 @@ class PreviewRenderer : public noggit::Red::ViewportManager::Viewport
QOpenGLFramebufferObjectFormat _fmt;
QOffscreenSurface _offscreen_surface;
math::vector_3d _background_color;
math::vector_3d _diffuse_light;
math::vector_3d _ambient_light;
math::vector_3d _light_dir;
glm::vec3 _background_color;
glm::vec3 _diffuse_light;
glm::vec3 _ambient_light;
glm::vec3 _light_dir;
bool _gl_initialized = false;

View File

@@ -111,7 +111,7 @@ auto Tool::getInnerRadius(void) const -> float
return _radiusInner;
}
auto Tool::stamp(World* world, math::vector_3d const& pos, float dt, bool doAdd) const -> void
auto Tool::stamp(World* world, glm::vec3 const& pos, float dt, bool doAdd) const -> void
{
if(!_curPixmap)
return;

View File

@@ -8,6 +8,7 @@
#include <QSlider>
#include <QDial>
#include <QDoubleSpinBox>
#include <glm/vec3.hpp>
class QPixmap;
class World;
@@ -31,7 +32,7 @@ namespace noggit
Tool(bool_toggle_property* showPalette, float* cursorRotation, QWidget* parent = nullptr);
auto getOuterRadius(void) const -> float;
auto getInnerRadius(void) const -> float;
auto stamp(World* world, math::vector_3d const& pos, float dt, bool doAdd) const -> void;
auto stamp(World* world, glm::vec3 const& pos, float dt, bool doAdd) const -> void;
public slots:
void setPixmap(QPixmap const* pixmap);
private:

View File

@@ -118,7 +118,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
glm::mat4 glm_transform_mat = glm::make_mat4(static_cast<float*>(delta_matrix));
math::vector_3d& pos = obj_instance->pos;
glm::vec3& pos = obj_instance->pos;
math::degrees::vec3& rotation = obj_instance->dir;
float wmo_scale = 0.f;
float& scale = obj_instance->which() == eMODEL ? obj_instance->scale : wmo_scale;
@@ -146,7 +146,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
{
case ImGuizmo::TRANSLATE:
{
pos += {new_translation.x, new_translation.y, new_translation.z};
pos += glm::vec3(new_translation.x, new_translation.y, new_translation.z);
break;
}
case ImGuizmo::ROTATE:
@@ -156,12 +156,12 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
if (!_use_multiselection_pivot)
{
rotation += {math::degrees(rot_euler.x), math::degrees(rot_euler.y), math::degrees(rot_euler.z)};
rotation += glm::vec3(math::degrees(rot_euler.x)._, math::degrees(rot_euler.y)._, math::degrees(rot_euler.z)._);
}
else
{
//LogDebug << rot_euler.x << " " << rot_euler.y << " " << rot_euler.z << std::endl;
rotation.y += math::degrees(rot_euler.y);
rotation.y += math::degrees(rot_euler.y)._;
// building model matrix
glm::mat4 model_transform = glm::make_mat4(static_cast<float*>(object_matrix));
@@ -237,7 +237,7 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
glm::mat4 glm_transform_mat = glm::make_mat4(static_cast<float*>(delta_matrix));
math::vector_3d& pos = obj_instance->pos;
glm::vec3& pos = obj_instance->pos;
math::degrees::vec3& rotation = obj_instance->dir;
float wmo_scale = 0.f;
float& scale = obj_instance->which() == eMODEL ? obj_instance->scale : wmo_scale;
@@ -266,13 +266,13 @@ void ViewportGizmo::handleTransformGizmo(MapView* map_view
case ImGuizmo::TRANSLATE:
{
pos += {new_translation.x, new_translation.y, new_translation.z};
pos += glm::vec3(new_translation.x, new_translation.y, new_translation.z);
break;
}
case ImGuizmo::ROTATE:
{
auto rot_euler = glm::eulerAngles(new_orientation) * 57.2957795f;
rotation += {math::degrees(rot_euler.x), math::degrees(rot_euler.y), math::degrees(rot_euler.z)};
rotation += glm::vec3(math::degrees(rot_euler.x)._, math::degrees(rot_euler.y)._, math::degrees(rot_euler.z)._);
break;
}
case ImGuizmo::SCALE:

View File

@@ -49,7 +49,7 @@ namespace noggit
bool isOver() {ImGuizmo::SetID(_gizmo_context); return ImGuizmo::IsOver();};
bool isUsing() {ImGuizmo::SetID(_gizmo_context); return ImGuizmo::IsUsing();};
void setUseMultiselectionPivot(bool use_pivot) { _use_multiselection_pivot = use_pivot; };
void setMultiselectionPivot(math::vector_3d const& pivot) { _multiselection_pivot = pivot; };
void setMultiselectionPivot(glm::vec3 const& pivot) { _multiselection_pivot = pivot; };
void setWorld(World* world) { _world = world; }
private:
@@ -59,7 +59,7 @@ namespace noggit
ImGuizmo::MODE _gizmo_mode;
GizmoContext _gizmo_context;
bool _use_multiselection_pivot;
math::vector_3d _multiselection_pivot;
glm::vec3 _multiselection_pivot;
float _last_pivot_scale;
};
}

View File

@@ -11,7 +11,7 @@ SceneObject::SceneObject(SceneObjectTypes type, noggit::NoggitRenderContext cont
{
}
bool SceneObject::isInsideRect(math::vector_3d rect[2]) const
bool SceneObject::isInsideRect(glm::vec3 rect[2]) const
{
return misc::rectOverlap(extents, rect);
}
@@ -30,7 +30,7 @@ void SceneObject::updateTransformMatrix()
* math::matrix_4x4
( math::matrix_4x4::rotation_yzx
, { -dir.z
, dir.y - 90.0_deg
, dir.y - math::degrees(90.0)._
, dir.x
})
@@ -44,7 +44,7 @@ void SceneObject::updateTransformMatrix()
void SceneObject::resetDirection()
{
dir = math::degrees::vec3(0_deg, dir.y, 0.0_deg);
dir = math::degrees::vec3((0_deg)._, dir.y, (0.0_deg)._);
recalcExtents();
}

View File

@@ -27,7 +27,7 @@ public:
SceneObject(SceneObjectTypes type, noggit::NoggitRenderContext context, std::string filename = "");
[[nodiscard]]
bool isInsideRect(math::vector_3d rect[2]) const;
bool isInsideRect(glm::vec3 rect[2]) const;
[[nodiscard]]
bool isDuplicateOf(SceneObject const& other);
@@ -60,9 +60,9 @@ public:
virtual AsyncObject* instance_model() = 0;
public:
math::vector_3d pos;
math::vector_3d extents[2];
math::degrees::vec3 dir;
glm::vec3 pos;
glm::vec3 extents[2];
glm::vec3 dir;
float scale = 1.f;
unsigned int uid;
int frame;

View File

@@ -14,7 +14,7 @@ class MapChunk;
struct selected_chunk_type
{
selected_chunk_type(MapChunk* _chunk, std::tuple<int, int, int> _triangle, math::vector_3d _position)
selected_chunk_type(MapChunk* _chunk, std::tuple<int, int, int> _triangle, glm::vec3 _position)
: chunk(_chunk)
, triangle(_triangle)
, position(_position)
@@ -22,7 +22,7 @@ struct selected_chunk_type
MapChunk* chunk;
std::tuple<int,int,int> triangle; // mVertices[i] points of the hit triangle
math::vector_3d position;
glm::vec3 position;
bool operator== (selected_chunk_type const& other) const
{

View File

@@ -33,7 +33,7 @@ Sky::Sky(DBCFile::Iterator data, noggit::NoggitRenderContext context)
: _context(context)
, _selected(false)
{
pos = math::vector_3d(data->getFloat(LightDB::PositionX) / skymul, data->getFloat(LightDB::PositionY) / skymul, data->getFloat(LightDB::PositionZ) / skymul);
pos = glm::vec3(data->getFloat(LightDB::PositionX) / skymul, data->getFloat(LightDB::PositionY) / skymul, data->getFloat(LightDB::PositionZ) / skymul);
r1 = data->getFloat(LightDB::RadiusInner) / skymul;
r2 = data->getFloat(LightDB::RadiusOuter) / skymul;
@@ -209,13 +209,13 @@ float Sky::floatParamFor(int r, int t) const
return c1 + ((c2 - c1) * tt);
}
math::vector_3d Sky::colorFor(int r, int t) const
glm::vec3 Sky::colorFor(int r, int t) const
{
if (mmin[r]<0)
{
return math::vector_3d(0, 0, 0);
return glm::vec3(0, 0, 0);
}
math::vector_3d c1, c2;
glm::vec3 c1, c2;
int t1, t2;
size_t last = colorRows[r].size() - 1;
@@ -285,7 +285,7 @@ Skies::Skies(unsigned int mapid, noggit::NoggitRenderContext context)
skies.push_back(s);
numSkies++;
if (s.pos == math::vector_3d(0, 0, 0))
if (s.pos == glm::vec3(0, 0, 0))
has_global = true;
}
}
@@ -309,13 +309,13 @@ Skies::Skies(unsigned int mapid, noggit::NoggitRenderContext context)
std::sort(skies.begin(), skies.end());
}
Sky* Skies::findSkyWeights(math::vector_3d pos)
Sky* Skies::findSkyWeights(glm::vec3 pos)
{
Sky* default_sky = nullptr;
for (auto& sky : skies)
{
if (sky.pos == math::vector_3d(0, 0, 0))
if (sky.pos == glm::vec3(0, 0, 0))
{
default_sky = &sky;
break;
@@ -350,7 +350,7 @@ Sky* Skies::findSkyWeights(math::vector_3d pos)
return default_sky;
}
void Skies::update_sky_colors(math::vector_3d pos, int time)
void Skies::update_sky_colors(glm::vec3 pos, int time)
{
if (numSkies == 0 || (_last_time == time && _last_pos == pos))
{
@@ -382,7 +382,7 @@ void Skies::update_sky_colors(math::vector_3d pos, int time)
for (int i = 0; i < NUM_SkyColorNames; ++i)
{
color_set[i] = math::vector_3d(1, 1, 1);
color_set[i] = glm::vec3(1, 1, 1);
}
_fog_multiplier = 0.f;
@@ -411,12 +411,8 @@ void Skies::update_sky_colors(math::vector_3d pos, int time)
LogDebug << "Sky " << j << " " << i << " is out of bounds!" << std::endl;
continue;
}
auto original_col = reinterpret_cast<glm::vec3*>(&color_set[i]._data[0]);
auto timed_color = sky.colorFor(i, time);
auto new_col = reinterpret_cast<glm::vec3*>(&timed_color._data[0]);
glm::vec3 final_color = glm::mix(*original_col, *new_col, sky.weight);
color_set[i] = *reinterpret_cast<math::vector_3d*>(&final_color);
color_set[i] = glm::mix(color_set[i], timed_color, sky.weight);
}
_fog_distance = (_fog_distance * (1.0f - sky.weight)) + (sky.floatParamFor(0, time) * sky.weight);
@@ -454,7 +450,7 @@ void Skies::update_sky_colors(math::vector_3d pos, int time)
bool Skies::draw( math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, opengl::scoped::use_program& m2_shader
, math::frustum const& frustum
, const float& cull_distance
@@ -555,7 +551,7 @@ bool Skies::draw( math::matrix_4x4 const& model_view
void Skies::drawLightingSpheres (math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, math::frustum const& frustum
, const float& cull_distance
)
@@ -564,8 +560,8 @@ void Skies::drawLightingSpheres (math::matrix_4x4 const& model_view
{
if ((sky.pos - camera_pos).length() - sky.r2 <= cull_distance) // TODO: frustum cull here
{
math::vector_3d diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
math::vector_3d ambient = color_set[LIGHT_GLOBAL_AMBIENT];
glm::vec3 diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
glm::vec3 ambient = color_set[LIGHT_GLOBAL_AMBIENT];
_sphere_render.draw(model_view * projection, sky.pos, {ambient.x, ambient.y, ambient.z, 0.3}, sky.r1);
_sphere_render.draw(model_view * projection, sky.pos, {diffuse.x, diffuse.y, diffuse.z, 0.3}, sky.r2);
}
@@ -574,7 +570,7 @@ void Skies::drawLightingSpheres (math::matrix_4x4 const& model_view
void Skies::drawLightingSphereHandles (math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, math::frustum const& frustum
, const float& cull_distance
, bool draw_spheres)
@@ -588,8 +584,8 @@ void Skies::drawLightingSphereHandles (math::matrix_4x4 const& model_view
if (sky.selected())
{
math::vector_3d diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
math::vector_3d ambient = color_set[LIGHT_GLOBAL_AMBIENT];
glm::vec3 diffuse = color_set[LIGHT_GLOBAL_DIFFUSE];
glm::vec3 ambient = color_set[LIGHT_GLOBAL_AMBIENT];
_sphere_render.draw(model_view * projection, sky.pos, {ambient.x, ambient.y, ambient.z, 0.3}, sky.r1);
_sphere_render.draw(model_view * projection, sky.pos, {diffuse.x, diffuse.y, diffuse.z, 0.3}, sky.r2);
@@ -651,16 +647,16 @@ void main()
_vertex_array.upload();
_buffers.upload();
std::vector<math::vector_3d> vertices;
std::vector<glm::vec3> vertices;
std::vector<std::uint16_t> indices;
math::vector_3d basepos1[cnum], basepos2[cnum];
glm::vec3 basepos1[cnum], basepos2[cnum];
for (int h = 0; h < hseg; h++)
{
for (int i = 0; i < cnum; ++i)
{
basepos1[i] = basepos2[i] = math::vector_3d(math::cos(angles[i])*rad, math::sin(angles[i])*rad, 0);
basepos1[i] = basepos2[i] = glm::vec3(math::cos(angles[i])*rad, math::sin(angles[i])*rad, 0);
math::rotate(0, 0, &basepos1[i].x, &basepos1[i].z, math::radians(glm::pi<float>() *2.0f / hseg * h));
math::rotate(0, 0, &basepos2[i].x, &basepos2[i].z, math::radians(glm::pi<float>() *2.0f / hseg * (h + 1)));
@@ -685,7 +681,7 @@ void main()
}
}
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_vertices_vbo, vertices, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_vertices_vbo, vertices, GL_STATIC_DRAW);
gl.bufferData<GL_ELEMENT_ARRAY_BUFFER, std::uint16_t>(_indices_vbo, indices, GL_STATIC_DRAW);
_indices_count = indices.size();
@@ -715,7 +711,7 @@ void Skies::update_vao(opengl::scoped::use_program& shader)
void Skies::update_color_buffer()
{
std::vector<math::vector_3d> colors;
std::vector<glm::vec3> colors;
for (int h = 0; h < hseg; h++)
{
@@ -728,7 +724,7 @@ void Skies::update_color_buffer()
}
}
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d>(_colors_vbo, colors, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3>(_colors_vbo, colors, GL_STATIC_DRAW);
_need_vao_update = true;
}

View File

@@ -19,7 +19,7 @@
struct OutdoorLightStats
{
float nightIntensity;
math::vector_3d dayDir;
glm::vec3 dayDir;
void interpolate(OutdoorLightStats *a, OutdoorLightStats *b, float r);
};
@@ -37,7 +37,7 @@ public:
struct SkyColor
{
math::vector_3d color;
glm::vec3 color;
int time;
SkyColor(int t, int col);
@@ -56,7 +56,7 @@ class Sky
public:
boost::optional<ModelInstance> skybox;
math::vector_3d pos;
glm::vec3 pos;
float r1, r2;
explicit Sky(DBCFile::Iterator data, noggit::NoggitRenderContext context);
@@ -68,7 +68,7 @@ public:
char name[32];
math::vector_3d colorFor(int r, int t) const;
glm::vec3 colorFor(int r, int t) const;
float floatParamFor(int r, int t) const;
float weight;
@@ -142,7 +142,7 @@ private:
ModelInstance stars;
int _last_time = -1;
math::vector_3d _last_pos;
glm::vec3 _last_pos;
float _river_shallow_alpha;
float _river_deep_alpha;
@@ -156,16 +156,16 @@ private:
public:
std::vector<Sky> skies;
std::vector<math::vector_3d> color_set = std::vector<math::vector_3d>(NUM_SkyColorNames);
std::vector<glm::vec3> color_set = std::vector<glm::vec3>(NUM_SkyColorNames);
explicit Skies(unsigned int mapid, noggit::NoggitRenderContext context);
Sky* findSkyWeights(math::vector_3d pos);
void update_sky_colors(math::vector_3d pos, int time);
Sky* findSkyWeights(glm::vec3 pos);
void update_sky_colors(glm::vec3 pos, int time);
bool draw ( math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, opengl::scoped::use_program& m2_shader
, math::frustum const& frustum
, const float& cull_distance
@@ -175,14 +175,14 @@ public:
void drawLightingSpheres (math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, math::frustum const& frustum
, const float& cull_distance
);
void drawLightingSphereHandles (math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, math::frustum const& frustum
, const float& cull_distance
, bool draw_spheres

View File

@@ -16,8 +16,8 @@ TileWater::TileWater(MapTile *pTile, float pXbase, float pZbase, bool use_mclq_g
: tile(pTile)
, xbase(pXbase)
, zbase(pZbase)
, _extents{math::vector_3d{pXbase, std::numeric_limits<float>::max(), pZbase},
math::vector_3d{pXbase + TILESIZE, std::numeric_limits<float>::lowest(), pZbase + TILESIZE}}
, _extents{glm::vec3{pXbase, std::numeric_limits<float>::max(), pZbase},
glm::vec3{pXbase + TILESIZE, std::numeric_limits<float>::lowest(), pZbase + TILESIZE}}
{
for (int z = 0; z < 16; ++z)
{
@@ -42,7 +42,7 @@ void TileWater::readFromFile(MPQFile &theFile, size_t basePos)
void TileWater::draw ( math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool camera_moved
, opengl::scoped::use_program& water_shader
, int animtime
@@ -59,8 +59,8 @@ void TileWater::draw ( math::frustum const& frustum
if (_extents_changed)
{
_extents = {math::vector_3d{xbase, std::numeric_limits<float>::max(), zbase},
math::vector_3d{xbase + TILESIZE, std::numeric_limits<float>::lowest(), zbase + TILESIZE}};
_extents = {glm::vec3{xbase, std::numeric_limits<float>::max(), zbase},
glm::vec3{xbase + TILESIZE, std::numeric_limits<float>::lowest(), zbase + TILESIZE}};
for (int i = 0; i < 256; ++i)
{

View File

@@ -44,7 +44,7 @@ public:
void draw ( math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool camera_moved
, opengl::scoped::use_program& water_shader
, int animtime
@@ -68,7 +68,7 @@ public:
void updateLayerData(LiquidTextureManager* tex_manager);
std::array<math::vector_3d, 2>& getExtents() { return _extents; };
std::array<glm::vec3, 2>& getExtents() { return _extents; };
void unload();
@@ -82,7 +82,7 @@ private:
MapTile *tile;
std::unique_ptr<ChunkWater> chunks[16][16];
std::array<math::vector_3d, 2> _extents;
std::array<glm::vec3, 2> _extents;
std::vector<LiquidLayerDrawCallData> _render_layers;

View File

@@ -74,9 +74,9 @@ void WMO::finishLoading ()
f.read (&ambient_color, 4);
f.read (&nX, 4);
f.read (ff, 12);
extents[0] = ::math::vector_3d (ff[0], ff[1], ff[2]);
extents[0] = ::glm::vec3 (ff[0], ff[1], ff[2]);
f.read (ff, 12);
extents[1] = ::math::vector_3d (ff[0], ff[1], ff[2]);
extents[1] = ::glm::vec3 (ff[0], ff[1], ff[2]);
f.read(&flags, 2);
f.seekRelative (2);
@@ -195,11 +195,11 @@ void WMO::finishLoading ()
f.seekRelative (size);
/*
std::vector<math::vector_3d> portal_vertices;
std::vector<glm::vec3> portal_vertices;
for (size_t i (0); i < size / 12; ++i) {
f.read (ff, 12);
portal_vertices.push_back(math::vector_3d(ff[0], ff[2], -ff[1]));
portal_vertices.push_back(glm::vec3(ff[0], ff[2], -ff[1]));
}
*/
@@ -342,7 +342,7 @@ void WMO::draw ( opengl::scoped::use_program& wmo_shader
, bool boundingbox
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool // draw_doodads
, bool draw_fog
, int animtime
@@ -403,8 +403,8 @@ void WMO::draw ( opengl::scoped::use_program& wmo_shader
, projection
, transform_matrix_transposed
, {1.0f, 0.0f, 0.0f, 1.0f}
, math::vector_3d(extents[0].x, extents[0].z, -extents[0].y)
, math::vector_3d(extents[1].x, extents[1].z, -extents[1].y)
, glm::vec3(extents[0].x, extents[0].z, -extents[0].y)
, glm::vec3(extents[1].x, extents[1].z, -extents[1].y)
);
}
@@ -428,18 +428,21 @@ std::vector<float> WMO::intersect (math::ray const& ray) const
}
bool WMO::draw_skybox ( math::matrix_4x4 const& model_view
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, opengl::scoped::use_program& m2_shader
, math::frustum const& frustum
, const float& cull_distance
, int animtime
, bool draw_particles
, math::vector_3d aabb_min
, math::vector_3d aabb_max
, std::map<int, std::pair<math::vector_3d, math::vector_3d>> const& group_extents
, glm::vec3 aabb_min
, glm::vec3 aabb_max
, std::map<int, std::pair<glm::vec3, glm::vec3>> const& group_extents
) const
{
if (!skybox || !camera_pos.is_inside_of(aabb_min, aabb_max))
if (!skybox || !math::is_inside_of(camera_pos,aabb_min, aabb_max))
{
return false;
}
@@ -455,7 +458,7 @@ bool WMO::draw_skybox ( math::matrix_4x4 const& model_view
auto& extent(group_extents.at(i));
if (camera_pos.is_inside_of(extent.first, extent.second))
if (math::is_inside_of(camera_pos, extent.first, extent.second))
{
ModelInstance sky(skybox.get()->filename, _context);
sky.pos = camera_pos;
@@ -525,12 +528,12 @@ void WMOLight::init(MPQFile* f)
char type[4];
f->read(&type, 4);
f->read(&color, 4);
f->read(pos, 12);
f->read(&pos, 12);
f->read(&intensity, 4);
f->read(unk, 4 * 5);
f->read(&r, 4);
pos = math::vector_3d(pos.x, pos.z, -pos.y);
pos = glm::vec3(pos.x, pos.z, -pos.y);
// rgb? bgr? hm
float fa = ((color & 0xff000000) >> 24) / 255.0f;
@@ -556,7 +559,7 @@ void WMOLight::setup(GLint)
// not used right now -_-
}
void WMOLight::setupOnce(GLint, math::vector_3d, math::vector_3d)
void WMOLight::setupOnce(GLint, glm::vec3, glm::vec3)
{
//glm::vec4position(dir, 0);
//glm::vec4position(0,1,0,0);
@@ -579,9 +582,9 @@ WMOGroup::WMOGroup(WMO *_wmo, MPQFile* f, int _num, char const* names)
f->read(&flags, 4);
float ff[3];
f->read(ff, 12);
VertexBoxMax = math::vector_3d(ff[0], ff[1], ff[2]);
VertexBoxMax = glm::vec3(ff[0], ff[1], ff[2]);
f->read(ff, 12);
VertexBoxMin = math::vector_3d(ff[0], ff[1], ff[2]);
VertexBoxMin = glm::vec3(ff[0], ff[1], ff[2]);
int nameOfs;
f->read(&nameOfs, 4);
@@ -895,8 +898,8 @@ void WMOGroup::load()
if (wf.r2 <= 0) fog = -1; // default outdoor fog..?
else fog = header.fogs[0];
BoundingBoxMin = ::math::vector_3d (header.box1[0], header.box1[2], -header.box1[1]);
BoundingBoxMax = ::math::vector_3d (header.box2[0], header.box2[2], -header.box2[1]);
BoundingBoxMin = ::glm::vec3 (header.box1[0], header.box1[2], -header.box1[1]);
BoundingBoxMax = ::glm::vec3 (header.box2[0], header.box2[2], -header.box2[1]);
// - MOPY ----------------------------------------------
@@ -926,20 +929,20 @@ void WMOGroup::load()
assert (fourcc == 'MOVT');
// let's hope it's padded to 12 bytes, not 16...
::math::vector_3d const* vertices = reinterpret_cast< ::math::vector_3d const*>(f.getPointer ());
::glm::vec3 const* vertices = reinterpret_cast< ::glm::vec3 const*>(f.getPointer ());
VertexBoxMin = ::math::vector_3d (std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
VertexBoxMax = ::math::vector_3d (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
VertexBoxMin = ::glm::vec3 (std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
VertexBoxMax = ::glm::vec3 (std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
rad = 0;
_vertices.resize(size / sizeof (::math::vector_3d));
_vertices.resize(size / sizeof (::glm::vec3));
for (size_t i = 0; i < _vertices.size(); ++i)
{
_vertices[i] = math::vector_3d(vertices[i].x, vertices[i].z, -vertices[i].y);
_vertices[i] = glm::vec3(vertices[i].x, vertices[i].z, -vertices[i].y);
::math::vector_3d& v = _vertices[i];
::glm::vec3& v = _vertices[i];
if (v.x < VertexBoxMin.x) VertexBoxMin.x = v.x;
if (v.y < VertexBoxMin.y) VertexBoxMin.y = v.y;
@@ -961,7 +964,7 @@ void WMOGroup::load()
assert (fourcc == 'MONR');
_normals.resize (size / sizeof (::math::vector_3d));
_normals.resize (size / sizeof (::glm::vec3));
f.read (_normals.data (), size);
@@ -1314,7 +1317,7 @@ void WMOGroup::load()
// "real" lighting?
if (header.flags.indoor && header.flags.has_vertex_color)
{
::math::vector_3d dirmin(1, 1, 1);
::glm::vec3 dirmin(1, 1, 1);
float lenmin;
for (auto doodad : _doodad_ref)
@@ -1324,8 +1327,9 @@ void WMOGroup::load()
for (unsigned int j = 0; j < wmo->lights.size(); j++)
{
WMOLight& l = wmo->lights[j];
::math::vector_3d dir = l.pos - mi.pos;
float ll = dir.length_squared ();
::glm::vec3 dir = l.pos - mi.pos;
float ll = glm::length(dir) * glm::length(dir);
if (ll < lenmin)
{
lenmin = ll;
@@ -1435,11 +1439,11 @@ void WMOGroup::fix_vertex_color_alpha()
bool WMOGroup::is_visible( math::matrix_4x4 const& transform
, math::frustum const& frustum
, float const& cull_distance
, math::vector_3d const& camera
, glm::vec3 const& camera
, display_mode display
) const
{
math::vector_3d pos = transform * center;
glm::vec3 pos = transform * center;
if (!frustum.intersects(pos + BoundingBoxMin, pos + BoundingBoxMax))
{
@@ -1456,7 +1460,7 @@ bool WMOGroup::is_visible( math::matrix_4x4 const& transform
void WMOGroup::draw( opengl::scoped::use_program& wmo_shader
, math::frustum const& // frustum
, const float& //cull_distance
, const math::vector_3d& //camera
, const glm::vec3& //camera
, bool // draw_fog
, bool // world_has_skies
)

View File

@@ -142,7 +142,7 @@ public:
void draw( opengl::scoped::use_program& wmo_shader
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool draw_fog
, bool world_has_skies
);
@@ -164,16 +164,16 @@ public:
bool is_visible( math::matrix_4x4 const& transform_matrix
, math::frustum const& frustum
, float const& cull_distance
, math::vector_3d const& camera
, glm::vec3 const& camera
, display_mode display
) const;
std::vector<uint16_t> doodad_ref() const { return _doodad_ref; }
math::vector_3d BoundingBoxMin;
math::vector_3d BoundingBoxMax;
math::vector_3d VertexBoxMin;
math::vector_3d VertexBoxMax;
glm::vec3 BoundingBoxMin;
glm::vec3 BoundingBoxMax;
glm::vec3 VertexBoxMin;
glm::vec3 VertexBoxMax;
bool use_outdoor_lights;
std::string name;
@@ -188,7 +188,7 @@ private:
WMO *wmo;
wmo_group_header header;
::math::vector_3d center;
::glm::vec3 center;
float rad;
int32_t num;
int32_t fog;
@@ -197,8 +197,8 @@ private:
std::vector<wmo_batch> _batches;
std::vector<::math::vector_3d> _vertices;
std::vector<::math::vector_3d> _normals;
std::vector<::glm::vec3> _vertices;
std::vector<::glm::vec3> _normals;
std::vector<glm::vec2> _texcoords;
std::vector<glm::vec2> _texcoords_2;
std::vector<glm::vec4> _vertex_colors;
@@ -231,7 +231,7 @@ private:
struct WMOLight {
uint32_t flags, color;
math::vector_3d pos;
glm::vec3 pos;
float intensity;
float unk[5];
float r;
@@ -241,11 +241,11 @@ struct WMOLight {
void init(MPQFile* f);
void setup(GLint light);
static void setupOnce(GLint light, math::vector_3d dir, math::vector_3d light_color);
static void setupOnce(GLint light, glm::vec3 dir, glm::vec3 light_color);
};
struct WMOPV {
math::vector_3d a, b, c, d;
glm::vec3 a, b, c, d;
};
struct WMOPR {
@@ -261,7 +261,7 @@ struct WMODoodadSet {
struct WMOFog {
unsigned int flags;
math::vector_3d pos;
glm::vec3 pos;
float r1, r2, fogend, fogstart;
unsigned int color1;
float f2;
@@ -302,7 +302,7 @@ public:
, bool boundingbox
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool draw_doodads
, bool draw_fog
, int animtime
@@ -311,15 +311,15 @@ public:
);
bool draw_skybox( math::matrix_4x4 const& model_view
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, opengl::scoped::use_program& m2_shader
, math::frustum const& frustum
, const float& cull_distance
, int animtime
, bool draw_particles
, math::vector_3d aabb_min
, math::vector_3d aabb_max
, std::map<int, std::pair<math::vector_3d, math::vector_3d>> const& group_extents
, glm::vec3 aabb_min
, glm::vec3 aabb_max
, std::map<int, std::pair<glm::vec3, glm::vec3>> const& group_extents
) const;
std::vector<float> intersect (math::ray const&) const;
@@ -336,11 +336,11 @@ public:
std::vector<WMOGroup> groups;
std::vector<WMOMaterial> materials;
math::vector_3d extents[2];
glm::vec3 extents[2];
std::vector<scoped_blp_texture_reference> textures;
std::vector<std::string> models;
std::vector<wmo_doodad_instance> modelis;
std::vector<math::vector_3d> model_nearest_light_vector;
std::vector<glm::vec3> model_nearest_light_vector;
std::vector<WMOLight> lights;
glm::vec4 ambient_light_color;

View File

@@ -18,13 +18,13 @@ WMOInstance::WMOInstance(std::string const& filename, ENTRY_MODF const* d, noggi
, mUnknown(d->unknown), mNameset(d->nameSet)
, _doodadset(d->doodadSet)
{
pos = math::vector_3d(d->pos[0], d->pos[1], d->pos[2]);
dir = math::degrees::vec3{math::degrees(d->rot[0]), math::degrees(d->rot[1]), math::degrees(d->rot[2])};
pos = glm::vec3(d->pos[0], d->pos[1], d->pos[2]);
dir = math::degrees::vec3{math::degrees(d->rot[0])._, math::degrees(d->rot[1])._, math::degrees(d->rot[2])._ };
uid = d->uniqueID;
extents[0] = math::vector_3d(d->extents[0][0], d->extents[0][1], d->extents[0][2]);
extents[1] = math::vector_3d(d->extents[1][0], d->extents[1][1], d->extents[1][2]);
extents[0] = glm::vec3(d->extents[0][0], d->extents[0][1], d->extents[0][2]);
extents[1] = glm::vec3(d->extents[1][0], d->extents[1][1], d->extents[1][2]);
updateTransformMatrix();
change_doodadset(_doodadset);
@@ -39,8 +39,8 @@ WMOInstance::WMOInstance(std::string const& filename, noggit::NoggitRenderContex
, _doodadset(0)
{
change_doodadset(_doodadset);
pos = math::vector_3d(0.0f, 0.0f, 0.0f);
dir = math::degrees::vec3(0_deg, 0_deg, 0_deg);
pos = glm::vec3(0.0f, 0.0f, 0.0f);
dir = math::degrees::vec3((0_deg)._, (0_deg)._, (0_deg)._);
uid = 0;
_context = context;
}
@@ -51,7 +51,7 @@ void WMOInstance::draw ( opengl::scoped::use_program& wmo_shader
, math::matrix_4x4 const& projection
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool force_box
, bool draw_doodads
, bool draw_fog
@@ -164,10 +164,10 @@ void WMOInstance::recalcExtents()
updateTransformMatrix();
update_doodads();
std::vector<math::vector_3d> points;
std::vector<glm::vec3> points;
math::vector_3d wmo_min(misc::transform_model_box_coords(wmo->extents[0]));
math::vector_3d wmo_max(misc::transform_model_box_coords(wmo->extents[1]));
glm::vec3 wmo_min(misc::transform_model_box_coords(wmo->extents[0]));
glm::vec3 wmo_max(misc::transform_model_box_coords(wmo->extents[1]));
auto&& root_points = _transform_mat * math::aabb(wmo_min, wmo_max).all_corners();
@@ -233,7 +233,7 @@ void WMOInstance::update_doodads()
std::vector<wmo_doodad_instance*> WMOInstance::get_visible_doodads
( math::frustum const& frustum
, float const& cull_distance
, math::vector_3d const& camera
, glm::vec3 const& camera
, bool draw_hidden_models
, display_mode display
)

View File

@@ -4,7 +4,7 @@
#include <noggit/SceneObject.hpp>
#include <math/ray.hpp>
#include <math/vector_3d.hpp> // math::vector_3d
#include <math/vector_3d.hpp> // glm::vec3
#include <noggit/WMO.h>
#include <noggit/ContextObject.hpp>
@@ -18,7 +18,7 @@ class WMOInstance : public SceneObject
{
public:
scoped_wmo_reference wmo;
std::map<int, std::pair<math::vector_3d, math::vector_3d>> group_extents;
std::map<int, std::pair<glm::vec3, glm::vec3>> group_extents;
uint16_t mFlags;
uint16_t mUnknown;
uint16_t mNameset;
@@ -91,7 +91,7 @@ public:
, math::matrix_4x4 const& projection
, math::frustum const& frustum
, const float& cull_distance
, const math::vector_3d& camera
, const glm::vec3& camera
, bool force_box
, bool draw_doodads
, bool draw_fog
@@ -112,7 +112,7 @@ public:
std::vector<wmo_doodad_instance*> get_visible_doodads( math::frustum const& frustum
, float const& cull_distance
, math::vector_3d const& camera
, glm::vec3 const& camera
, bool draw_hidden_models
, display_mode display
);

View File

@@ -137,7 +137,7 @@ void World::update_selection_pivot()
ZoneScoped;
if (has_multiple_model_selected())
{
math::vector_3d pivot;
glm::vec3 pivot;
int model_count = 0;
for (auto const& entry : _current_selection)
@@ -250,19 +250,29 @@ boost::optional<selection_type> World::get_last_selected_model() const
? boost::optional<selection_type>() : boost::optional<selection_type> (*it);
}
math::vector_3d getBarycentricCoordinatesAt(
const math::vector_3d& a,
const math::vector_3d& b,
const math::vector_3d& c,
const math::vector_3d& point,
const math::vector_3d& normal)
glm::vec3 getBarycentricCoordinatesAt(
const glm::vec3& a,
const glm::vec3& b,
const glm::vec3& c,
const glm::vec3& point,
const glm::vec3& normal)
{
math::vector_3d bary;
glm::vec3 bary;
// The area of a triangle is
double areaABC = normal * ((b - a) % (c - a));
double areaPBC = normal * ((b - point) % (c - point));
double areaPCA = normal * ((c - point) % (a - point));
glm::vec3 aMb = (b - a);
glm::vec3 cMa = (c - a);
glm::vec3 bMpoint = (b - point);
glm::vec3 cMpont = (c - point);
glm::vec3 aMpoint = (a - point);
glm::vec3 ABC = glm::cross(aMb ,cMa);
glm::vec3 PBC = glm::cross(bMpoint, cMpont);
glm::vec3 PCA = glm::cross(cMpont, aMpoint);
double areaABC = glm::dot(normal , ABC);
double areaPBC = glm::dot(normal , PBC);
double areaPCA = glm::dot(normal , PCA);
bary.x = areaPBC / areaABC; // alpha
bary.y = areaPCA / areaABC; // beta
@@ -338,9 +348,9 @@ void World::rotate_selected_models_randomly(float minX, float maxX, float minY,
glm::quat finalRotationNormalized = glm::normalize(finalRotation);
auto eulerAngles = glm::eulerAngles(finalRotationNormalized);
dir.x = math::degrees(math::radians(eulerAngles.x));
dir.z = math::degrees(math::radians(eulerAngles.y));
dir.y = math::degrees(math::radians(eulerAngles.z));
dir.x = math::degrees(math::radians(eulerAngles.z))._;
dir.y = math::degrees(math::radians(eulerAngles.x))._;
dir.z = math::degrees(math::radians(eulerAngles.y))._;
obj->recalcExtents();
@@ -365,7 +375,7 @@ void World::rotate_selected_models_to_ground_normal(bool smoothNormals)
updateTilesEntry(entry, model_update::remove);
math::vector_3d rayPos = obj->pos;
glm::vec3 rayPos = obj->pos;
math::degrees::vec3& dir = obj->dir;
@@ -373,13 +383,13 @@ void World::rotate_selected_models_to_ground_normal(bool smoothNormals)
for_chunk_at(rayPos, [&](MapChunk* chunk)
{
{
math::ray intersect_ray(rayPos, math::vector_3d(0.f, -1.f, 0.f));
math::ray intersect_ray(rayPos, glm::vec3(0.f, -1.f, 0.f));
chunk->intersect(intersect_ray, &results);
}
// object is below ground
if (results.empty())
{
math::ray intersect_ray(rayPos, math::vector_3d(0.f, 1.f, 0.f));
math::ray intersect_ray(rayPos, glm::vec3(0.f, 1.f, 0.f));
chunk->intersect(intersect_ray, &results);
}
});
@@ -396,17 +406,17 @@ void World::rotate_selected_models_to_ground_normal(bool smoothNormals)
auto const& hitChunkInfo = boost::get<selected_chunk_type>(results.front().second);
glm::quat q;
math::vector_3d varnormal;
glm::vec3 varnormal;
// Surface Normal
auto &p0 = hitChunkInfo.chunk->mVertices[std::get<0>(hitChunkInfo.triangle)];
auto &p1 = hitChunkInfo.chunk->mVertices[std::get<1>(hitChunkInfo.triangle)];
auto &p2 = hitChunkInfo.chunk->mVertices[std::get<2>(hitChunkInfo.triangle)];
math::vector_3d v1 = p1 - p0;
math::vector_3d v2 = p2 - p0;
glm::vec3 v1 = p1 - p0;
glm::vec3 v2 = p2 - p0;
const auto tmpVec = v2 % v1;
auto tmpVec = glm::cross(v2 ,v1);
varnormal.x = tmpVec.z;
varnormal.y = tmpVec.y;
varnormal.z = tmpVec.x;
@@ -419,9 +429,9 @@ void World::rotate_selected_models_to_ground_normal(bool smoothNormals)
auto& tile_buffer = hitChunkInfo.chunk->mt->getChunkHeightmapBuffer();
int chunk_start = (hitChunkInfo.chunk->px * 16 + hitChunkInfo.chunk->py) * mapbufsize * 4;
const auto& vNormal0 = *reinterpret_cast<math::vector_3d*>(&tile_buffer[chunk_start + std::get<0>(hitChunkInfo.triangle) * 4]);
const auto& vNormal1 = *reinterpret_cast<math::vector_3d*>(&tile_buffer[chunk_start + std::get<1>(hitChunkInfo.triangle) * 4]);
const auto& vNormal2 = *reinterpret_cast<math::vector_3d*>(&tile_buffer[chunk_start + std::get<2>(hitChunkInfo.triangle) * 4]);
const auto& vNormal0 = *reinterpret_cast<glm::vec3*>(&tile_buffer[chunk_start + std::get<0>(hitChunkInfo.triangle) * 4]);
const auto& vNormal1 = *reinterpret_cast<glm::vec3*>(&tile_buffer[chunk_start + std::get<1>(hitChunkInfo.triangle) * 4]);
const auto& vNormal2 = *reinterpret_cast<glm::vec3*>(&tile_buffer[chunk_start + std::get<2>(hitChunkInfo.triangle) * 4]);
varnormal.x =
vNormal0.x * normalWeights.x +
@@ -440,15 +450,22 @@ void World::rotate_selected_models_to_ground_normal(bool smoothNormals)
}
math::vector_3d worldUp = math::vector_3d(0, 1, 0);
math::vector_3d a = worldUp % (varnormal);
glm::vec3 worldUp = glm::vec3(0, 1, 0);
glm::vec3 a =glm::cross(worldUp ,varnormal);
q.x = a.x;
q.y = a.y;
q.z = a.z;
q.w = std::sqrt((worldUp.length_squared() * (varnormal.length_squared()))
+ (worldUp * varnormal));
math::vector_3d x;
auto as = 5 + x;
auto worldLengthSqrd = glm::length(worldUp) * glm::length(worldUp);
auto normalLengthSqrd = glm::length(varnormal) * glm::length(varnormal);
auto worldDotNormal = glm::dot(worldUp, varnormal);
q.w = std::sqrt((worldLengthSqrd * normalLengthSqrd) + (worldDotNormal));
auto normalizedQ = glm::normalize(q);
@@ -474,9 +491,9 @@ void World::rotate_selected_models_to_ground_normal(bool smoothNormals)
}*/
auto eulerAngles = glm::eulerAngles(normalizedQ);
dir.x = math::degrees(math::radians(eulerAngles.z));
dir.y = math::degrees(math::radians(eulerAngles.x));
dir.z = math::degrees(math::radians(eulerAngles.y));
dir.x = math::degrees(math::radians(eulerAngles.z))._; //Roll
dir.y = math::degrees(math::radians(eulerAngles.x))._; //Pitch
dir.z = math::degrees(math::radians(eulerAngles.y))._; //Yaw
boost::get<selected_object_type>(entry)->recalcExtents();
@@ -579,7 +596,7 @@ void World::snap_selected_models_to_the_ground()
auto& obj = boost::get<selected_object_type>(entry);
noggit::ActionManager::instance()->getCurrentAction()->registerObjectTransformed(obj);
math::vector_3d& pos = obj->pos;
glm::vec3& pos = obj->pos;
selection_result hits;
@@ -587,13 +604,13 @@ void World::snap_selected_models_to_the_ground()
for_chunk_at(pos, [&] (MapChunk* chunk)
{
{
math::ray intersect_ray(pos, math::vector_3d(0.f, -1.f, 0.f));
math::ray intersect_ray(pos, glm::vec3(0.f, -1.f, 0.f));
chunk->intersect(intersect_ray, &hits);
}
// object is below ground
if (hits.empty())
{
math::ray intersect_ray(pos, math::vector_3d(0.f, 1.f, 0.f));
math::ray intersect_ray(pos, glm::vec3(0.f, 1.f, 0.f));
chunk->intersect(intersect_ray, &hits);
}
});
@@ -674,7 +691,7 @@ void World::move_selected_models(float dx, float dy, float dz)
auto& obj = boost::get<selected_object_type>(entry);
noggit::ActionManager::instance()->getCurrentAction()->registerObjectTransformed(obj);
math::vector_3d& pos = obj->pos;
glm::vec3& pos = obj->pos;
updateTilesEntry(entry, model_update::remove);
@@ -690,13 +707,13 @@ void World::move_selected_models(float dx, float dy, float dz)
update_selection_pivot();
}
void World::set_selected_models_pos(math::vector_3d const& pos, bool change_height)
void World::set_selected_models_pos(glm::vec3 const& pos, bool change_height)
{
ZoneScoped;
// move models relative to the pivot when several are selected
if (has_multiple_model_selected())
{
math::vector_3d diff = pos - _multi_select_pivot.get();
glm::vec3 diff = pos - _multi_select_pivot.get();
if (change_height)
{
@@ -734,7 +751,7 @@ void World::set_selected_models_pos(math::vector_3d const& pos, bool change_heig
void World::rotate_selected_models(math::degrees rx, math::degrees ry, math::degrees rz, bool use_pivot)
{
ZoneScoped;
math::degrees::vec3 dir_change(rx, ry, rz);
math::degrees::vec3 dir_change(rx._, ry._, rz._);
bool has_multi_select = has_multiple_model_selected();
for (auto& entry : _current_selection)
@@ -753,10 +770,10 @@ void World::rotate_selected_models(math::degrees rx, math::degrees ry, math::deg
if (use_pivot && has_multi_select)
{
math::vector_3d& pos = obj->pos;
glm::vec3& pos = obj->pos;
math::degrees::vec3& dir = obj->dir;
math::vector_3d diff_pos = pos - _multi_select_pivot.get();
math::vector_3d rot_result = math::matrix_4x4(math::matrix_4x4::rotation_xyz, {rx, ry, rz}) * diff_pos;
glm::vec3 diff_pos = pos - _multi_select_pivot.get();
glm::vec3 rot_result = math::matrix_4x4(math::matrix_4x4::rotation_xyz, {rx._, ry._, rz._ }) * diff_pos;
pos += rot_result - diff_pos;
}
@@ -775,7 +792,7 @@ void World::rotate_selected_models(math::degrees rx, math::degrees ry, math::deg
void World::set_selected_models_rotation(math::degrees rx, math::degrees ry, math::degrees rz)
{
ZoneScoped;
math::degrees::vec3 new_dir(rx, ry, rz);
math::degrees::vec3 new_dir(rx._, ry._, rz._);
for (auto& entry : _current_selection)
{
@@ -822,7 +839,7 @@ void World::initDisplay()
ol = std::make_unique<OutdoorLighting> ("World\\dnc.db");
}
MapChunk* World::getChunkAt(math::vector_3d const& pos)
MapChunk* World::getChunkAt(glm::vec3 const& pos)
{
MapTile* tile(mapIndex.getTile(pos));
if (tile && tile->finishedLoading())
@@ -1060,21 +1077,21 @@ void World::initShaders()
void World::draw ( math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& cursor_pos
, glm::vec3 const& cursor_pos
, float cursorRotation
, glm::vec4 const& cursor_color
, CursorType cursor_type
, float brush_radius
, bool show_unpaintable_chunks
, float inner_radius_ratio
, math::vector_3d const& ref_pos
, glm::vec3 const& ref_pos
, float angle
, float orientation
, bool use_ref_pos
, bool angled_mode
, bool draw_paintability_overlay
, editing_mode terrainMode
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, bool camera_moved
, bool draw_mfbo
, bool draw_terrain
@@ -1328,7 +1345,7 @@ void World::draw ( math::matrix_4x4 const& model_view
float size = (vertexCenter() - camera_pos).length();
gl.pointSize(std::max(0.001f, 10.0f - (1.25f * size / CHUNKSIZE)));
for (math::vector_3d const* pos : _vertices_selected)
for (glm::vec3 const* pos : _vertices_selected)
{
_sphere_render.draw(mvp, *pos, glm::vec4(1.f, 0.f, 0.f, 1.f), 0.5f);
}
@@ -1783,7 +1800,7 @@ void World::draw ( math::matrix_4x4 const& model_view
if (angled_mode && !use_ref_pos)
{
math::vector_3d pos = cursor_pos;
glm::vec3 pos = cursor_pos;
pos.y += 0.1f; // to avoid z-fighting with the ground
_square_render.draw(mvp, pos, radius, incl, orient, color);
}
@@ -1791,7 +1808,7 @@ void World::draw ( math::matrix_4x4 const& model_view
{
if (angled_mode)
{
math::vector_3d pos = cursor_pos;
glm::vec3 pos = cursor_pos;
pos.y = misc::angledHeight(ref_pos, pos, incl, orient);
pos.y += 0.1f;
_square_render.draw(mvp, pos, radius, incl, orient, color);
@@ -1799,14 +1816,14 @@ void World::draw ( math::matrix_4x4 const& model_view
// display the plane when the cursor is far from ref_point
if (misc::dist(pos.x, pos.z, ref_pos.x, ref_pos.z) > 10.f + radius)
{
math::vector_3d ref = ref_pos;
glm::vec3 ref = ref_pos;
ref.y += 0.1f;
_square_render.draw(mvp, ref, 10.f, incl, orient, color);
}
}
else
{
math::vector_3d pos = cursor_pos;
glm::vec3 pos = cursor_pos;
pos.y = ref_pos.y + 0.1f;
_square_render.draw(mvp, pos, radius, math::degrees(0.f), math::degrees(0.f), color);
}
@@ -1913,13 +1930,13 @@ void World::update_models_emitters(float dt)
ModelManager::updateEmitters(dt);
}
unsigned int World::getAreaID (math::vector_3d const& pos)
unsigned int World::getAreaID (glm::vec3 const& pos)
{
ZoneScoped;
return for_maybe_chunk_at (pos, [&] (MapChunk* chunk) { return chunk->getAreaID(); }).get_value_or (-1);
}
void World::clearHeight(math::vector_3d const& pos)
void World::clearHeight(glm::vec3 const& pos)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -1952,7 +1969,7 @@ void World::CropWaterADT(const tile_index& pos)
});
}
void World::setAreaID(math::vector_3d const& pos, int id, bool adt, float radius)
void World::setAreaID(glm::vec3 const& pos, int id, bool adt, float radius)
{
ZoneScoped;
if (adt)
@@ -1989,7 +2006,7 @@ void World::setAreaID(math::vector_3d const& pos, int id, bool adt, float radius
}
}
bool World::GetVertex(float x, float z, math::vector_3d *V) const
bool World::GetVertex(float x, float z, glm::vec3 *V) const
{
ZoneScoped;
tile_index tile({x, 0, z});
@@ -2006,7 +2023,7 @@ bool World::GetVertex(float x, float z, math::vector_3d *V) const
void World::changeShader(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode)
void World::changeShader(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode)
{
ZoneScoped;
for_all_chunks_in_range
@@ -2019,7 +2036,7 @@ void World::changeShader(math::vector_3d const& pos, glm::vec4 const& color, flo
);
}
void World::stampShader(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors)
void World::stampShader(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors)
{
ZoneScoped;
for_all_chunks_in_rect
@@ -2032,10 +2049,10 @@ void World::stampShader(math::vector_3d const& pos, glm::vec4 const& color, floa
);
}
math::vector_3d World::pickShaderColor(math::vector_3d const& pos)
glm::vec3 World::pickShaderColor(glm::vec3 const& pos)
{
ZoneScoped;
math::vector_3d color = math::vector_3d(1.0f, 1.0f, 1.0f);
glm::vec3 color = glm::vec3(1.0f, 1.0f, 1.0f);
for_all_chunks_in_range
(pos, 0.1f
, [&] (MapChunk* chunk)
@@ -2048,7 +2065,7 @@ math::vector_3d World::pickShaderColor(math::vector_3d const& pos)
return color;
}
auto World::stamp(math::vector_3d const& pos, float dt, QImage const* img, float radiusOuter
auto World::stamp(glm::vec3 const& pos, float dt, QImage const* img, float radiusOuter
, float radiusInner, int brushType, bool sculpt) -> void
{
ZoneScoped;
@@ -2121,7 +2138,7 @@ auto World::stamp(math::vector_3d const& pos, float dt, QImage const* img, float
}
void World::changeTerrain(math::vector_3d const& pos, float change, float radius, int BrushType, float inner_radius)
void World::changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius)
{
ZoneScoped;
for_all_chunks_in_range
@@ -2138,7 +2155,7 @@ void World::changeTerrain(math::vector_3d const& pos, float change, float radius
);
}
void World::flattenTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const math::vector_3d& origin, math::degrees angle, math::degrees orientation)
void World::flattenTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const glm::vec3& origin, math::degrees angle, math::degrees orientation)
{
ZoneScoped;
for_all_chunks_in_range
@@ -2155,7 +2172,7 @@ void World::flattenTerrain(math::vector_3d const& pos, float remain, float radiu
);
}
void World::blurTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode)
void World::blurTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode)
{
ZoneScoped;
for_all_chunks_in_range
@@ -2170,7 +2187,7 @@ void World::blurTerrain(math::vector_3d const& pos, float remain, float radius,
, mode
, [this] (float x, float z) -> boost::optional<float>
{
math::vector_3d vec;
glm::vec3 vec;
auto res (GetVertex (x, z, &vec));
return boost::make_optional (res, vec.y);
}
@@ -2189,7 +2206,7 @@ void World::recalc_norms (MapChunk* chunk) const
chunk->recalcNorms();
}
bool World::paintTexture(math::vector_3d const& pos, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture)
bool World::paintTexture(glm::vec3 const& pos, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture)
{
ZoneScoped;
return for_all_chunks_in_range
@@ -2202,7 +2219,7 @@ bool World::paintTexture(math::vector_3d const& pos, Brush* brush, float strengt
);
}
bool World::stampTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint)
bool World::stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint)
{
ZoneScoped;
return for_all_chunks_in_rect
@@ -2215,7 +2232,7 @@ bool World::stampTexture(math::vector_3d const& pos, Brush *brush, float strengt
);
}
bool World::sprayTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, float spraySize, float sprayPressure, scoped_blp_texture_reference texture)
bool World::sprayTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, float spraySize, float sprayPressure, scoped_blp_texture_reference texture)
{
ZoneScoped;
bool succ = false;
@@ -2235,7 +2252,7 @@ bool World::sprayTexture(math::vector_3d const& pos, Brush *brush, float strengt
return succ;
}
bool World::replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture)
bool World::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture)
{
ZoneScoped;
return for_all_chunks_in_range
@@ -2248,7 +2265,7 @@ bool World::replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_
);
}
void World::eraseTextures(math::vector_3d const& pos)
void World::eraseTextures(glm::vec3 const& pos)
{
ZoneScoped;
for_chunk_at(pos, [](MapChunk* chunk)
@@ -2258,7 +2275,7 @@ void World::eraseTextures(math::vector_3d const& pos)
});
}
void World::overwriteTextureAtCurrentChunk(math::vector_3d const& pos, scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture)
void World::overwriteTextureAtCurrentChunk(glm::vec3 const& pos, scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture)
{
ZoneScoped;
for_chunk_at(pos, [&](MapChunk* chunk)
@@ -2268,7 +2285,7 @@ void World::overwriteTextureAtCurrentChunk(math::vector_3d const& pos, scoped_bl
});
}
void World::setHole(math::vector_3d const& pos, float radius, bool big, bool hole)
void World::setHole(glm::vec3 const& pos, float radius, bool big, bool hole)
{
ZoneScoped;
for_all_chunks_in_range
@@ -2282,7 +2299,7 @@ void World::setHole(math::vector_3d const& pos, float radius, bool big, bool hol
);
}
void World::setHoleADT(math::vector_3d const& pos, bool hole)
void World::setHoleADT(glm::vec3 const& pos, bool hole)
{
ZoneScoped;
@@ -2355,7 +2372,7 @@ void World::convert_alphamap(bool to_big_alpha)
void World::drawMinimap ( MapTile *tile
, math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, MinimapRenderSettings* settings
)
{
@@ -2433,13 +2450,13 @@ void World::drawMinimap ( MapTile *tile
skies->update_sky_colors(camera_pos, daytime);
outdoorLightStats = ol->getLightStats(static_cast<int>(time) * 60);
math::vector_3d light_dir = outdoorLightStats.dayDir;
glm::vec3 light_dir = outdoorLightStats.dayDir;
light_dir = {-light_dir.x, light_dir.z, -light_dir.y};
// todo: figure out why I need to use a different light vector for the terrain
math::vector_3d terrain_light_dir = outdoorLightStats.dayDir;
glm::vec3 terrain_light_dir = outdoorLightStats.dayDir;
math::vector_3d diffuse_color(skies->color_set[LIGHT_GLOBAL_DIFFUSE]);
math::vector_3d ambient_color(skies->color_set[LIGHT_GLOBAL_AMBIENT]);
glm::vec3 diffuse_color(skies->color_set[LIGHT_GLOBAL_DIFFUSE]);
glm::vec3 ambient_color(skies->color_set[LIGHT_GLOBAL_AMBIENT]);
culldistance = 100000.0f;
@@ -2738,14 +2755,14 @@ bool World::saveMinimap(tile_index const& tile_idx, MinimapRenderSettings* setti
100000.0f
);
auto look_at = math::look_at(math::vector_3d(TILESIZE * tile_idx.x + TILESIZE / 2.0f, max_height + 10.0f, TILESIZE * tile_idx.z + TILESIZE / 2.0f),
math::vector_3d(TILESIZE * tile_idx.x + TILESIZE / 2.0f, max_height + 9.0f, TILESIZE * tile_idx.z + TILESIZE / 2.0 - 0.005f),
math::vector_3d(0.f,1.f, 0.f));
auto look_at = math::look_at(glm::vec3(TILESIZE * tile_idx.x + TILESIZE / 2.0f, max_height + 10.0f, TILESIZE * tile_idx.z + TILESIZE / 2.0f),
glm::vec3(TILESIZE * tile_idx.x + TILESIZE / 2.0f, max_height + 9.0f, TILESIZE * tile_idx.z + TILESIZE / 2.0 - 0.005f),
glm::vec3(0.f,1.f, 0.f));
drawMinimap(mTile
, look_at.transposed()
, projection.transposed()
, math::vector_3d(TILESIZE * tile_idx.x + TILESIZE / 2.0f
, glm::vec3(TILESIZE * tile_idx.x + TILESIZE / 2.0f
, max_height + 15.0f, TILESIZE * tile_idx.z + TILESIZE / 2.0f)
, settings);
@@ -2900,9 +2917,9 @@ void World::unload_every_model_and_wmo_instance()
}
void World::addM2 ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, float scale
, math::degrees::vec3 rotation
, glm::vec3 rotation
, noggit::object_paste_params* paste_params
)
{
@@ -2920,15 +2937,15 @@ void World::addM2 ( std::string const& filename
{
float min = paste_params->minRotation;
float max = paste_params->maxRotation;
model_instance.dir.y += math::degrees(misc::randfloat(min, max));
model_instance.dir.y += math::degrees(misc::randfloat(min, max))._;
}
if (_settings->value ("model/random_tilt", false).toBool ())
{
float min = paste_params->minTilt;
float max = paste_params->maxTilt;
model_instance.dir.x += math::degrees(misc::randfloat(min, max));
model_instance.dir.z += math::degrees(misc::randfloat(min, max));
model_instance.dir.x += math::degrees(misc::randfloat(min, max))._;
model_instance.dir.z += math::degrees(misc::randfloat(min, max))._;
}
if (_settings->value ("model/random_size", false).toBool ())
@@ -2949,7 +2966,7 @@ void World::addM2 ( std::string const& filename
}
ModelInstance* World::addM2AndGetInstance ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, float scale
, math::degrees::vec3 rotation
, noggit::object_paste_params* paste_params
@@ -2969,15 +2986,15 @@ ModelInstance* World::addM2AndGetInstance ( std::string const& filename
{
float min = paste_params->minRotation;
float max = paste_params->maxRotation;
model_instance.dir.y += math::degrees(misc::randfloat(min, max));
model_instance.dir.y += math::degrees(misc::randfloat(min, max))._;
}
if (_settings->value ("model/random_tilt", false).toBool ())
{
float min = paste_params->minTilt;
float max = paste_params->maxTilt;
model_instance.dir.x += math::degrees(misc::randfloat(min, max));
model_instance.dir.z += math::degrees(misc::randfloat(min, max));
model_instance.dir.x += math::degrees(misc::randfloat(min, max))._;
model_instance.dir.z += math::degrees(misc::randfloat(min, max))._;
}
if (_settings->value ("model/random_size", false).toBool ())
@@ -3001,7 +3018,7 @@ ModelInstance* World::addM2AndGetInstance ( std::string const& filename
}
void World::addWMO ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, math::degrees::vec3 rotation
)
{
@@ -3020,7 +3037,7 @@ void World::addWMO ( std::string const& filename
}
WMOInstance* World::addWMOAndGetInstance ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, math::degrees::vec3 rotation
)
{
@@ -3149,7 +3166,7 @@ unsigned int World::getMapID()
return mapIndex._map_id;
}
void World::clearTextures(math::vector_3d const& pos)
void World::clearTextures(glm::vec3 const& pos)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -3160,7 +3177,7 @@ void World::clearTextures(math::vector_3d const& pos)
}
void World::exportADTAlphamap(math::vector_3d const& pos)
void World::exportADTAlphamap(glm::vec3 const& pos)
{
ZoneScoped;
for_tile_at ( pos
@@ -3188,7 +3205,7 @@ void World::exportADTAlphamap(math::vector_3d const& pos)
);
}
void World::exportADTNormalmap(math::vector_3d const& pos)
void World::exportADTNormalmap(glm::vec3 const& pos)
{
ZoneScoped;
for_tile_at ( pos
@@ -3212,7 +3229,7 @@ void World::exportADTNormalmap(math::vector_3d const& pos)
);
}
void World::exportADTAlphamap(math::vector_3d const& pos, std::string const& filename)
void World::exportADTAlphamap(glm::vec3 const& pos, std::string const& filename)
{
ZoneScoped;
for_tile_at ( pos
@@ -3238,7 +3255,7 @@ void World::exportADTAlphamap(math::vector_3d const& pos, std::string const& fil
);
}
void World::exportADTHeightmap(math::vector_3d const& pos, float min_height, float max_height)
void World::exportADTHeightmap(glm::vec3 const& pos, float min_height, float max_height)
{
ZoneScoped;
for_tile_at ( pos
@@ -3264,7 +3281,7 @@ void World::exportADTHeightmap(math::vector_3d const& pos, float min_height, flo
);
}
void World::exportADTVertexColorMap(math::vector_3d const& pos)
void World::exportADTVertexColorMap(glm::vec3 const& pos)
{
ZoneScoped;
for_tile_at ( pos
@@ -3290,7 +3307,7 @@ void World::exportADTVertexColorMap(math::vector_3d const& pos)
);
}
void World::importADTAlphamap(math::vector_3d const& pos, QImage const& image, unsigned layer)
void World::importADTAlphamap(glm::vec3 const& pos, QImage const& image, unsigned layer)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -3322,7 +3339,7 @@ void World::importADTAlphamap(math::vector_3d const& pos, QImage const& image, u
}
void World::importADTAlphamap(math::vector_3d const& pos)
void World::importADTAlphamap(glm::vec3 const& pos)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -3361,7 +3378,7 @@ void World::importADTAlphamap(math::vector_3d const& pos)
);
}
void World::importADTHeightmap(math::vector_3d const& pos, QImage const& image, float multiplier, unsigned mode)
void World::importADTHeightmap(glm::vec3 const& pos, QImage const& image, float multiplier, unsigned mode)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -3392,7 +3409,7 @@ void World::importADTHeightmap(math::vector_3d const& pos, QImage const& image,
}
}
void World::importADTHeightmap(math::vector_3d const& pos, float multiplier, unsigned mode)
void World::importADTHeightmap(glm::vec3 const& pos, float multiplier, unsigned mode)
{
ZoneScoped;
for_tile_at ( pos
@@ -3429,7 +3446,7 @@ void World::importADTHeightmap(math::vector_3d const& pos, float multiplier, uns
);
}
void World::importADTVertexColorMap(math::vector_3d const& pos, int mode)
void World::importADTVertexColorMap(glm::vec3 const& pos, int mode)
{
ZoneScoped;
for_tile_at ( pos
@@ -3466,7 +3483,7 @@ void World::importADTVertexColorMap(math::vector_3d const& pos, int mode)
);
}
void World::ensureAllTilesetsADT(math::vector_3d const& pos)
void World::ensureAllTilesetsADT(glm::vec3 const& pos)
{
ZoneScoped;
static QStringList textures {"tileset/generic/black.blp",
@@ -3490,7 +3507,7 @@ void World::ensureAllTilesetsADT(math::vector_3d const& pos)
});
}
void World::importADTVertexColorMap(math::vector_3d const& pos, QImage const& image, int mode)
void World::importADTVertexColorMap(glm::vec3 const& pos, QImage const& image, int mode)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -3521,7 +3538,7 @@ void World::importADTVertexColorMap(math::vector_3d const& pos, QImage const& im
}
}
void World::setBaseTexture(math::vector_3d const& pos)
void World::setBaseTexture(glm::vec3 const& pos)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -3535,7 +3552,7 @@ void World::setBaseTexture(math::vector_3d const& pos)
});
}
void World::clear_shadows(math::vector_3d const& pos)
void World::clear_shadows(glm::vec3 const& pos)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [] (MapChunk* chunk)
@@ -3545,7 +3562,7 @@ void World::clear_shadows(math::vector_3d const& pos)
});
}
void World::swapTexture(math::vector_3d const& pos, scoped_blp_texture_reference tex)
void World::swapTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex)
{
ZoneScoped;
if (!!noggit::ui::selected_texture::get())
@@ -3558,7 +3575,7 @@ void World::swapTexture(math::vector_3d const& pos, scoped_blp_texture_reference
}
}
void World::removeTexDuplicateOnADT(math::vector_3d const& pos)
void World::removeTexDuplicateOnADT(glm::vec3 const& pos)
{
ZoneScoped;
for_all_chunks_on_tile(pos, [](MapChunk* chunk)
@@ -3568,7 +3585,7 @@ void World::removeTexDuplicateOnADT(math::vector_3d const& pos)
} );
}
void World::change_texture_flag(math::vector_3d const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add)
void World::change_texture_flag(glm::vec3 const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add)
{
ZoneScoped;
for_chunk_at(pos, [&] (MapChunk* chunk)
@@ -3578,14 +3595,14 @@ void World::change_texture_flag(math::vector_3d const& pos, scoped_blp_texture_r
});
}
void World::paintLiquid( math::vector_3d const& pos
void World::paintLiquid( glm::vec3 const& pos
, float radius
, int liquid_id
, bool add
, math::radians const& angle
, math::radians const& orientation
, bool lock
, math::vector_3d const& origin
, glm::vec3 const& origin
, bool override_height
, bool override_liquid_id
, float opacity_factor
@@ -3723,7 +3740,7 @@ void World::fixAllGaps()
}
}
bool World::isUnderMap(math::vector_3d const& pos)
bool World::isUnderMap(glm::vec3 const& pos)
{
ZoneScoped;
tile_index const tile (pos);
@@ -3740,7 +3757,7 @@ bool World::isUnderMap(math::vector_3d const& pos)
return true;
}
void World::selectVertices(math::vector_3d const& pos, float radius)
void World::selectVertices(glm::vec3 const& pos, float radius)
{
ZoneScoped;
noggit::ActionManager::instance()->getCurrentAction()->registerVertexSelectionChange();
@@ -3757,16 +3774,16 @@ void World::selectVertices(math::vector_3d const& pos, float radius)
}
bool World::deselectVertices(math::vector_3d const& pos, float radius)
bool World::deselectVertices(glm::vec3 const& pos, float radius)
{
ZoneScoped;
noggit::ActionManager::instance()->getCurrentAction()->registerVertexSelectionChange();
_vertex_center_updated = false;
_vertex_border_updated = false;
std::unordered_set<math::vector_3d*> inRange;
std::unordered_set<glm::vec3*> inRange;
for (math::vector_3d* v : _vertices_selected)
for (glm::vec3* v : _vertices_selected)
{
if (misc::dist(*v, pos) <= radius)
{
@@ -3774,7 +3791,7 @@ bool World::deselectVertices(math::vector_3d const& pos, float radius)
}
}
for (math::vector_3d* v : inRange)
for (glm::vec3* v : inRange)
{
_vertices_selected.erase(v);
}
@@ -3793,7 +3810,7 @@ void World::moveVertices(float h)
cur_action->registerChunkTerrainChange(chunk);
_vertex_center_updated = false;
for (math::vector_3d* v : _vertices_selected)
for (glm::vec3* v : _vertices_selected)
{
v->y += h;
}
@@ -3823,7 +3840,7 @@ void World::updateSelectedVertices()
}
}
void World::orientVertices ( math::vector_3d const& ref_pos
void World::orientVertices ( glm::vec3 const& ref_pos
, math::degrees vertex_angle
, math::degrees vertex_orientation
)
@@ -3836,7 +3853,7 @@ void World::orientVertices ( math::vector_3d const& ref_pos
for (auto& chunk : _vertex_chunks)
cur_action->registerChunkTerrainChange(chunk);
for (math::vector_3d* v : _vertices_selected)
for (glm::vec3* v : _vertices_selected)
{
v->y = misc::angledHeight(ref_pos, *v, vertex_angle, vertex_orientation);
}
@@ -3846,7 +3863,7 @@ void World::orientVertices ( math::vector_3d const& ref_pos
void World::flattenVertices (float height)
{
ZoneScoped;
for (math::vector_3d* v : _vertices_selected)
for (glm::vec3* v : _vertices_selected)
{
v->y = height;
}
@@ -3870,13 +3887,13 @@ void World::updateVertexCenter()
_vertex_center_updated = true;
_vertex_center = { 0,0,0 };
float f = 1.0f / _vertices_selected.size();
for (math::vector_3d* v : _vertices_selected)
for (glm::vec3* v : _vertices_selected)
{
_vertex_center += (*v) * f;
}
}
math::vector_3d const& World::vertexCenter()
glm::vec3 const& World::vertexCenter()
{
ZoneScoped;
if (!_vertex_center_updated)
@@ -3921,7 +3938,7 @@ void World::update_models_by_filename()
need_model_updates = false;
}
void World::range_add_to_selection(math::vector_3d const& pos, float radius, bool remove)
void World::range_add_to_selection(glm::vec3 const& pos, float radius, bool remove)
{
ZoneScoped;
for_tile_at(pos, [this, pos, radius, remove](MapTile* tile)
@@ -4521,7 +4538,7 @@ void World::updateMVPUniformBlock(const math::matrix_4x4& model_view, const math
}
void World::updateLightingUniformBlock(bool draw_fog, math::vector_3d const& camera_pos)
void World::updateLightingUniformBlock(bool draw_fog, glm::vec3 const& camera_pos)
{
ZoneScoped;
@@ -4530,13 +4547,13 @@ void World::updateLightingUniformBlock(bool draw_fog, math::vector_3d const& cam
skies->update_sky_colors(camera_pos, daytime);
outdoorLightStats = ol->getLightStats(static_cast<int>(time));
math::vector_3d diffuse = skies->color_set[LIGHT_GLOBAL_DIFFUSE];
math::vector_3d ambient = skies->color_set[LIGHT_GLOBAL_AMBIENT];
math::vector_3d fog_color = skies->color_set[FOG_COLOR];
math::vector_3d ocean_color_light = skies->color_set[OCEAN_COLOR_LIGHT];
math::vector_3d ocean_color_dark = skies->color_set[OCEAN_COLOR_DARK];
math::vector_3d river_color_light = skies->color_set[RIVER_COLOR_LIGHT];
math::vector_3d river_color_dark = skies->color_set[RIVER_COLOR_DARK];
glm::vec3 diffuse = skies->color_set[LIGHT_GLOBAL_DIFFUSE];
glm::vec3 ambient = skies->color_set[LIGHT_GLOBAL_AMBIENT];
glm::vec3 fog_color = skies->color_set[FOG_COLOR];
glm::vec3 ocean_color_light = skies->color_set[OCEAN_COLOR_LIGHT];
glm::vec3 ocean_color_dark = skies->color_set[OCEAN_COLOR_DARK];
glm::vec3 river_color_light = skies->color_set[RIVER_COLOR_LIGHT];
glm::vec3 river_color_dark = skies->color_set[RIVER_COLOR_DARK];
_lighting_ubo_data.DiffuseColor_FogStart = {diffuse.x,diffuse.y,diffuse.z, skies->fog_distance_start()};

View File

@@ -97,21 +97,21 @@ public:
void update_models_emitters(float dt);
void draw (math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& cursor_pos
, glm::vec3 const& cursor_pos
, float cursorRotation
, glm::vec4 const& cursor_color
, CursorType cursor_type
, float brush_radius
, bool show_unpaintable_chunks
, float inner_radius_ratio
, math::vector_3d const& ref_pos
, glm::vec3 const& ref_pos
, float angle
, float orientation
, bool use_ref_pos
, bool angled_mode
, bool draw_paintability_overlay
, editing_mode terrainMode
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, bool camera_moved
, bool draw_mfbo
, bool draw_terrain
@@ -130,8 +130,8 @@ public:
, bool draw_occlusion_boxes = false
);
unsigned int getAreaID (math::vector_3d const&);
void setAreaID(math::vector_3d const& pos, int id, bool adt, float radius = -1.0f);
unsigned int getAreaID (glm::vec3 const&);
void setAreaID(glm::vec3 const& pos, int id, bool adt, float radius = -1.0f);
noggit::NoggitRenderContext getRenderContext() { return _context; };
@@ -145,18 +145,18 @@ public:
, bool draw_hidden_models
);
MapChunk* getChunkAt(math::vector_3d const& pos);
MapChunk* getChunkAt(glm::vec3 const& pos);
private:
// Information about the currently selected model / WMO / triangle.
int _selected_model_count = 0;
boost::optional<math::vector_3d> _multi_select_pivot;
boost::optional<glm::vec3> _multi_select_pivot;
public:
void unload_shaders();
void update_selection_pivot();
boost::optional<math::vector_3d> const& multi_select_pivot() const { return _multi_select_pivot; }
boost::optional<glm::vec3> const& multi_select_pivot() const { return _multi_select_pivot; }
// Selection related methods.
bool is_selected(selection_type selection) const;
@@ -172,7 +172,7 @@ public:
void remove_from_selection(std::uint32_t uid);
void reset_selection();
void delete_selected_models();
void range_add_to_selection(math::vector_3d const& pos, float radius, bool remove);
void range_add_to_selection(glm::vec3 const& pos, float radius, bool remove);
noggit::world_model_instances_storage& getModelInstanceStorage() { return _model_instance_storage; };
enum class m2_scaling_type
@@ -185,7 +185,7 @@ public:
void snap_selected_models_to_the_ground();
void scale_selected_models(float v, m2_scaling_type type);
void move_selected_models(float dx, float dy, float dz);
void move_selected_models(math::vector_3d const& delta)
void move_selected_models(glm::vec3 const& delta)
{
move_selected_models(delta.x, delta.y, delta.z);
}
@@ -193,7 +193,7 @@ public:
{
return set_selected_models_pos({x,y,z}, change_height);
}
void set_selected_models_pos(math::vector_3d const& pos, bool change_height = true);
void set_selected_models_pos(glm::vec3 const& pos, bool change_height = true);
void rotate_selected_models(math::degrees rx, math::degrees ry, math::degrees rz, bool use_pivot);
void rotate_selected_models_randomly(float minX, float maxX, float minY, float maxY, float minZ, float maxZ);
void set_selected_models_rotation(math::degrees rx, math::degrees ry, math::degrees rz);
@@ -201,118 +201,118 @@ public:
// Checks the normal of the terrain on model origin and rotates to that spot.
void rotate_selected_models_to_ground_normal(bool smoothNormals);
bool GetVertex(float x, float z, math::vector_3d *V) const;
bool GetVertex(float x, float z, glm::vec3 *V) const;
// check if the cursor is under map or in an unloaded tile
bool isUnderMap(math::vector_3d const& pos);
bool isUnderMap(glm::vec3 const& pos);
template<typename Fun>
bool for_all_chunks_in_range ( math::vector_3d const& pos
bool for_all_chunks_in_range ( glm::vec3 const& pos
, float radius
, Fun&& /* MapChunk* -> bool changed */
);
template<typename Fun, typename Post>
bool for_all_chunks_in_range ( math::vector_3d const& pos
bool for_all_chunks_in_range ( glm::vec3 const& pos
, float radius
, Fun&& /* MapChunk* -> bool changed */
, Post&& /* MapChunk* -> void; called for all changed chunks */
);
template<typename Fun>
bool for_all_chunks_in_rect ( math::vector_3d const& pos
bool for_all_chunks_in_rect ( glm::vec3 const& pos
, float radius
, Fun&& /* MapChunk* -> bool changed */
);
template<typename Fun, typename Post>
bool for_all_chunks_in_rect ( math::vector_3d const& pos
bool for_all_chunks_in_rect (glm::vec3 const& pos
, float radius
, Fun&& /* MapChunk* -> bool changed */
, Post&& /* MapChunk* -> void; called for all changed chunks */
);
template<typename Fun>
void for_all_chunks_on_tile (math::vector_3d const& pos, Fun&&);
void for_all_chunks_on_tile (glm::vec3 const& pos, Fun&&);
template<typename Fun>
void for_chunk_at(math::vector_3d const& pos, Fun&& fun);
void for_chunk_at(glm::vec3 const& pos, Fun&& fun);
template<typename Fun>
auto for_maybe_chunk_at (math::vector_3d const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>;
auto for_maybe_chunk_at (glm::vec3 const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>;
template<typename Fun>
void for_tile_at(const tile_index& pos, Fun&&);
void changeTerrain(math::vector_3d const& pos, float change, float radius, int BrushType, float inner_radius);
void changeShader(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode);
void stampShader(math::vector_3d const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
math::vector_3d pickShaderColor(math::vector_3d const& pos);
void flattenTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const math::vector_3d& origin, math::degrees angle, math::degrees orientation);
void blurTerrain(math::vector_3d const& pos, float remain, float radius, int BrushType, flatten_mode const& mode);
bool paintTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
bool stampTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
bool sprayTexture(math::vector_3d const& pos, Brush *brush, float strength, float pressure, float spraySize, float sprayPressure, scoped_blp_texture_reference texture);
bool replaceTexture(math::vector_3d const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
void changeTerrain(glm::vec3 const& pos, float change, float radius, int BrushType, float inner_radius);
void changeShader(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode);
void stampShader(glm::vec3 const& pos, glm::vec4 const& color, float change, float radius, bool editMode, QImage* img, bool paint, bool use_image_colors);
glm::vec3 pickShaderColor(glm::vec3 const& pos);
void flattenTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode, const glm::vec3& origin, math::degrees angle, math::degrees orientation);
void blurTerrain(glm::vec3 const& pos, float remain, float radius, int BrushType, flatten_mode const& mode);
bool paintTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture);
bool stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint);
bool sprayTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, float spraySize, float sprayPressure, scoped_blp_texture_reference texture);
bool replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture);
void eraseTextures(math::vector_3d const& pos);
void overwriteTextureAtCurrentChunk(math::vector_3d const& pos, scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture);
void setBaseTexture(math::vector_3d const& pos);
void clear_shadows(math::vector_3d const& pos);
void clearTextures(math::vector_3d const& pos);
void swapTexture(math::vector_3d const& pos, scoped_blp_texture_reference tex);
void removeTexDuplicateOnADT(math::vector_3d const& pos);
void change_texture_flag(math::vector_3d const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add);
void eraseTextures(glm::vec3 const& pos);
void overwriteTextureAtCurrentChunk(glm::vec3 const& pos, scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture);
void setBaseTexture(glm::vec3 const& pos);
void clear_shadows(glm::vec3 const& pos);
void clearTextures(glm::vec3 const& pos);
void swapTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex);
void removeTexDuplicateOnADT(glm::vec3 const& pos);
void change_texture_flag(glm::vec3 const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add);
void setHole(math::vector_3d const& pos, float radius, bool big, bool hole);
void setHoleADT(math::vector_3d const& pos, bool hole);
void setHole(glm::vec3 const& pos, float radius, bool big, bool hole);
void setHoleADT(glm::vec3 const& pos, bool hole);
void exportADTAlphamap(math::vector_3d const& pos);
void exportADTNormalmap(math::vector_3d const& pos);
void exportADTAlphamap(math::vector_3d const& pos, std::string const& filename);
void exportADTHeightmap(math::vector_3d const& pos, float min_height, float max_height);
void exportADTVertexColorMap(math::vector_3d const& pos);
void exportADTAlphamap(glm::vec3 const& pos);
void exportADTNormalmap(glm::vec3 const& pos);
void exportADTAlphamap(glm::vec3 const& pos, std::string const& filename);
void exportADTHeightmap(glm::vec3 const& pos, float min_height, float max_height);
void exportADTVertexColorMap(glm::vec3 const& pos);
void exportAllADTsAlphamap();
void exportAllADTsAlphamap(std::string const& filename);
void exportAllADTsHeightmap();
void exportAllADTsVertexColorMap();
void importADTAlphamap(math::vector_3d const& pos, QImage const& image, unsigned layer);
void importADTAlphamap(math::vector_3d const& pos);
void importADTHeightmap(math::vector_3d const& pos, QImage const& image, float multiplier, unsigned mode);
void importADTHeightmap(math::vector_3d const& pos, float multiplier, unsigned mode);
void importADTVertexColorMap(math::vector_3d const& pos, int mode);
void importADTVertexColorMap(math::vector_3d const& pos, QImage const& image, int mode);
void importADTAlphamap(glm::vec3 const& pos, QImage const& image, unsigned layer);
void importADTAlphamap(glm::vec3 const& pos);
void importADTHeightmap(glm::vec3 const& pos, QImage const& image, float multiplier, unsigned mode);
void importADTHeightmap(glm::vec3 const& pos, float multiplier, unsigned mode);
void importADTVertexColorMap(glm::vec3 const& pos, int mode);
void importADTVertexColorMap(glm::vec3 const& pos, QImage const& image, int mode);
void importAllADTsAlphamaps();
void importAllADTsHeightmaps(float multiplier, unsigned mode);
void importAllADTVertexColorMaps(unsigned mode);
void ensureAllTilesetsADT(math::vector_3d const& pos);
void ensureAllTilesetsADT(glm::vec3 const& pos);
void ensureAllTilesetsAllADTs();
void notifyTileRendererOnSelectedTextureChange();
void addM2 ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, float scale, math::degrees::vec3 rotation
, noggit::object_paste_params*
);
void addWMO ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, math::degrees::vec3 rotation
);
ModelInstance* addM2AndGetInstance ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, float scale, math::degrees::vec3 rotation
, noggit::object_paste_params*
);
WMOInstance* addWMOAndGetInstance ( std::string const& filename
, math::vector_3d newPos
, glm::vec3 newPos
, math::degrees::vec3 rotation
);
auto stamp(math::vector_3d const& pos, float dt, QImage const* img, float radiusOuter
auto stamp(glm::vec3 const& pos, float dt, QImage const* img, float radiusOuter
, float radiusInner, int BrushType, bool sculpt) -> void;
// add a m2 instance to the world (needs to be positioned already), return the uid
@@ -335,7 +335,7 @@ public:
void drawMinimap ( MapTile *tile
, math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, math::vector_3d const& camera_pos
, glm::vec3 const& camera_pos
, MinimapRenderSettings* settings
);
@@ -349,18 +349,18 @@ public:
static bool IsEditableWorld(int pMapId);
void clearHeight(math::vector_3d const& pos);
void clearHeight(glm::vec3 const& pos);
void clearAllModelsOnADT(tile_index const& tile);
// liquids
void paintLiquid( math::vector_3d const& pos
void paintLiquid( glm::vec3 const& pos
, float radius
, int liquid_id
, bool add
, math::radians const& angle
, math::radians const& orientation
, bool lock
, math::vector_3d const& origin
, glm::vec3 const& origin
, bool override_height
, bool override_liquid_id
, float opacity_factor
@@ -375,10 +375,10 @@ public:
void convert_alphamap(bool to_big_alpha);
bool deselectVertices(math::vector_3d const& pos, float radius);
void selectVertices(math::vector_3d const& pos, float radius);
bool deselectVertices(glm::vec3 const& pos, float radius);
void selectVertices(glm::vec3 const& pos, float radius);
void moveVertices(float h);
void orientVertices ( math::vector_3d const& ref_pos
void orientVertices ( glm::vec3 const& ref_pos
, math::degrees vertex_angle
, math::degrees vertex_orientation
);
@@ -392,7 +392,7 @@ public:
float getMaxTileHeight(const tile_index& tile);
math::vector_3d const& vertexCenter();
glm::vec3 const& vertexCenter();
void initShaders();
@@ -417,7 +417,7 @@ private:
void update_models_by_filename();
void updateMVPUniformBlock(const math::matrix_4x4& model_view, const math::matrix_4x4& projection);
void updateLightingUniformBlock(bool draw_fog, math::vector_3d const& camera_pos);
void updateLightingUniformBlock(bool draw_fog, glm::vec3 const& camera_pos);
std::unordered_set<MapChunk*>& vertexBorderChunks();
@@ -430,8 +430,8 @@ private:
std::unordered_set<MapTile*> _vertex_tiles;
std::unordered_set<MapChunk*> _vertex_chunks;
std::unordered_set<MapChunk*> _vertex_border_chunks;
std::unordered_set<math::vector_3d*> _vertices_selected;
math::vector_3d _vertex_center;
std::unordered_set<glm::vec3*> _vertices_selected;
glm::vec3 _vertex_center;
bool _vertex_center_updated = false;
bool _vertex_border_updated = false;

View File

@@ -7,7 +7,7 @@
#include <forward_list>
template<typename Fun>
void World::for_all_chunks_on_tile (math::vector_3d const& pos, Fun&& fun)
void World::for_all_chunks_on_tile (glm::vec3 const& pos, Fun&& fun)
{
MapTile* tile (mapIndex.getTile (pos));
@@ -26,7 +26,7 @@ void World::for_all_chunks_on_tile (math::vector_3d const& pos, Fun&& fun)
}
template<typename Fun>
void World::for_chunk_at(math::vector_3d const& pos, Fun&& fun)
void World::for_chunk_at(glm::vec3 const& pos, Fun&& fun)
{
MapTile* tile(mapIndex.getTile(pos));
@@ -38,7 +38,7 @@ void World::for_chunk_at(math::vector_3d const& pos, Fun&& fun)
}
template<typename Fun>
auto World::for_maybe_chunk_at(math::vector_3d const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>
auto World::for_maybe_chunk_at(glm::vec3 const& pos, Fun&& fun) -> boost::optional<decltype (fun (nullptr))>
{
MapTile* tile (mapIndex.getTile (pos));
if (tile && tile->finishedLoading())
@@ -63,7 +63,7 @@ void World::for_tile_at(tile_index const& pos, Fun&& fun)
}
template<typename Fun>
bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, Fun&& fun)
bool World::for_all_chunks_in_range (glm::vec3 const& pos, float radius, Fun&& fun)
{
bool changed (false);
@@ -87,7 +87,7 @@ bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, F
return changed;
}
template<typename Fun, typename Post>
bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, Fun&& fun, Post&& post)
bool World::for_all_chunks_in_range (glm::vec3 const& pos, float radius, Fun&& fun, Post&& post)
{
std::forward_list<MapChunk*> modified_chunks;
@@ -115,7 +115,7 @@ bool World::for_all_chunks_in_range (math::vector_3d const& pos, float radius, F
template<typename Fun>
bool World::for_all_chunks_in_rect (math::vector_3d const& pos, float radius, Fun&& fun)
bool World::for_all_chunks_in_rect (glm::vec3 const& pos, float radius, Fun&& fun)
{
bool changed (false);
@@ -140,7 +140,7 @@ bool World::for_all_chunks_in_rect (math::vector_3d const& pos, float radius, Fu
}
template<typename Fun, typename Post>
bool World::for_all_chunks_in_rect (math::vector_3d const& pos, float radius, Fun&& fun, Post&& post)
bool World::for_all_chunks_in_rect (glm::vec3 const& pos, float radius, Fun&& fun, Post&& post)
{
std::forward_list<MapChunk*> modified_chunks;

View File

@@ -4,7 +4,7 @@
namespace noggit
{
camera::camera ( math::vector_3d const& position
camera::camera ( glm::vec3 const& position
, math::degrees yaw_
, math::degrees pitch_
)
@@ -65,20 +65,16 @@ namespace noggit
return _fov;
}
math::vector_3d camera::look_at() const
glm::vec3 camera::look_at() const
{
return position + direction();
}
math::vector_3d camera::direction() const
glm::vec3 camera::direction() const
{
math::vector_3d const forward (1.0f, 0.0f, 0.0f);
glm::vec3 forward (1.0f, 0.0f, 0.0f);
return ( math::matrix_4x4 ( math::matrix_4x4::rotation_yzx
, math::degrees::vec3 (_roll, _yaw, _pitch)
)
* forward
).normalize();
return glm::normalize((math::matrix_4x4(math::matrix_4x4::rotation_yzx, math::degrees::vec3(_roll._, _yaw._, _pitch._)) * forward));
}
math::matrix_4x4 camera::look_at_matrix() const
@@ -98,15 +94,16 @@ namespace noggit
void camera::move_horizontal (float sign, float dt)
{
math::vector_3d const up (0.0f, 1.0f, 0.0f);
math::vector_3d const right ( (direction() % up).normalize());
glm::vec3 up (0.0f, 1.0f, 0.0f);
auto cross = glm::cross(direction(), up);
glm::vec3 right = glm::normalize(cross);
position += right * sign * move_speed * dt;
}
void camera::move_vertical (float sign, float dt)
{
math::vector_3d const up (0.0f, 1.0f, 0.0f);
glm::vec3 const up (0.0f, 1.0f, 0.0f);
position += up * sign * move_speed * dt;
}

View File

@@ -10,7 +10,7 @@ namespace noggit
class camera
{
public:
camera ( math::vector_3d const& position
camera ( glm::vec3 const& position
, math::degrees yaw_
, math::degrees pitch_
);
@@ -25,8 +25,8 @@ namespace noggit
math::radians fov() const;
math::vector_3d look_at() const;
math::vector_3d direction() const;
glm::vec3 look_at() const;
glm::vec3 direction() const;
math::matrix_4x4 look_at_matrix() const;
@@ -38,7 +38,7 @@ namespace noggit
void reset(float x, float y, float z, float roll, float yaw, float pitch);
math::vector_3d position;
glm::vec3 position;
float move_speed;
private:

View File

@@ -6,7 +6,7 @@
namespace noggit
{
void cursor_render::draw(mode cursor_mode, math::matrix_4x4 const& mvp, glm::vec4 color, math::vector_3d const& pos, float radius, float inner_radius_ratio)
void cursor_render::draw(mode cursor_mode, math::matrix_4x4 const& mvp, glm::vec4 color, glm::vec3 const& pos, float radius, float inner_radius_ratio)
{
if (!_uploaded)
{
@@ -55,7 +55,7 @@ namespace noggit
void cursor_render::create_circle_buffer(opengl::scoped::use_program& shader)
{
std::vector<math::vector_3d> vertices;
std::vector<glm::vec3> vertices;
std::vector<std::uint16_t> indices;
int segment = 60;
@@ -90,7 +90,7 @@ namespace noggit
void cursor_render::create_sphere_buffer(opengl::scoped::use_program& shader)
{
std::vector<math::vector_3d> vertices;
std::vector<glm::vec3> vertices;
std::vector<std::uint16_t> indices;
int segment = 60;
@@ -102,14 +102,14 @@ namespace noggit
{
math::degrees rotation(360.f*r / static_cast<float>(rotation_plane));
math::matrix_4x4 m(math::matrix_4x4::rotation_xyz, math::degrees::vec3(math::degrees(0.f), math::degrees(0.f), rotation));
math::matrix_4x4 m(math::matrix_4x4::rotation_xyz, math::degrees::vec3(math::degrees(0.f)._, math::degrees(0.f)._, rotation._));
for (int i = 0; i < segment; ++i)
{
float x = math::cos(math::degrees(i * 360 / segment));
float z = math::sin(math::degrees(i * 360 / segment));
math::vector_3d v(x, 0.f, z);
glm::vec3 v(x, 0.f, z);
vertices.emplace_back(m*v);
if (r < rotation_plane)
@@ -152,7 +152,7 @@ namespace noggit
void cursor_render::create_square_buffer(opengl::scoped::use_program& shader)
{
std::vector<math::vector_3d> vertices =
std::vector<glm::vec3> vertices =
{
{-0.5f,0.f,-0.5f}
,{ 0.5f,0.f,-0.5f}
@@ -185,7 +185,7 @@ namespace noggit
void cursor_render::create_cube_buffer(opengl::scoped::use_program& shader)
{
std::vector<math::vector_3d> vertices =
std::vector<glm::vec3> vertices =
{
{-0.5f,-0.5f,-0.5f}
, { 0.5f,-0.5f,-0.5f}

View File

@@ -23,7 +23,7 @@ namespace noggit
mode_count
};
void draw(mode cursor_mode, math::matrix_4x4 const& mvp, glm::vec4 color, math::vector_3d const& pos, float radius, float inner_radius_ratio = 0.f);
void draw(mode cursor_mode, math::matrix_4x4 const& mvp, glm::vec4 color, glm::vec3 const& pos, float radius, float inner_radius_ratio = 0.f);
void unload();

View File

@@ -20,7 +20,7 @@ namespace
}
}
liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float height, int liquid_id)
liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, float height, int liquid_id)
: _liquid_id(liquid_id)
, _liquid_vertex_format(0)
, _minimum(height)
@@ -36,7 +36,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float
unsigned v_index = z * 9 + x;
_tex_coords[v_index] = default_uv(x, z);
_depth[v_index] = 1.0f;
_vertices[v_index] = math::vector_3d(
_vertices[v_index] = glm::vec3(
pos.x + UNITSIZE * x
, height
, pos.z + UNITSIZE * z
@@ -48,7 +48,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float
}
liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq& liquid, int liquid_id)
liquid_layer::liquid_layer(ChunkWater* chunk, glm::vec3 const& base, mclq& liquid, int liquid_id)
: _liquid_id(liquid_id)
, _minimum(liquid.min_height)
, _maximum(liquid.max_height)
@@ -84,7 +84,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq&
_tex_coords[v_index] = default_uv(x, z);
}
_vertices[v_index] = math::vector_3d(
_vertices[v_index] = glm::vec3(
pos.x + UNITSIZE * x
// sometimes there's garbage data on unused tiles that mess things up
, std::max(std::min(v.height, _maximum), _minimum)
@@ -95,7 +95,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq&
}
liquid_layer::liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, math::vector_3d const& base, MH2O_Information const& info, std::uint64_t infomask)
liquid_layer::liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, glm::vec3 const& base, MH2O_Information const& info, std::uint64_t infomask)
: _liquid_id(info.liquid_id)
, _liquid_vertex_format(info.liquid_vertex_format)
, _minimum(info.minHeight)
@@ -122,7 +122,7 @@ liquid_layer::liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos,
const unsigned v_index = z * 9 + x;
_tex_coords[v_index] = default_uv(x, z);
_depth[v_index] = 1.0f;
_vertices[v_index] = math::vector_3d(
_vertices[v_index] = glm::vec3(
pos.x + UNITSIZE * x
, _minimum
, pos.z + UNITSIZE * z
@@ -452,21 +452,21 @@ void liquid_layer::setSubchunk(int x, int z, bool water)
misc::set_bit(_subchunks, x, z, water);
}
void liquid_layer::paintLiquid( math::vector_3d const& cursor_pos
void liquid_layer::paintLiquid( glm::vec3 const& cursor_pos
, float radius
, bool add
, math::radians const& angle
, math::radians const& orientation
, bool lock
, math::vector_3d const& origin
, glm::vec3 const& origin
, bool override_height
, MapChunk* chunk
, float opacity_factor
)
{
math::vector_3d ref ( lock
glm::vec3 ref ( lock
? origin
: math::vector_3d (cursor_pos.x, cursor_pos.y + 1.0f, cursor_pos.z)
: glm::vec3 (cursor_pos.x, cursor_pos.y + 1.0f, cursor_pos.z)
);
int id = 0;
@@ -512,7 +512,7 @@ void liquid_layer::update_min_max()
_maximum = std::numeric_limits<float>::lowest();
int x = 0, z = 0;
for (math::vector_3d& v : _vertices)
for (glm::vec3& v : _vertices)
{
if (hasSubchunk(std::min(x, 7), std::min(z, 7)))
{
@@ -557,7 +557,7 @@ void liquid_layer::update_vertex_opacity(int x, int z, MapChunk* chunk, float fa
_depth[z * 9 + x] = diff < 0.0f ? 0.0f : (std::min(1.0f, std::max(0.0f, (diff + 1.0f) * factor)));
}
int liquid_layer::get_lod_level(math::vector_3d const& camera_pos) const
int liquid_layer::get_lod_level(glm::vec3 const& camera_pos) const
{
auto const& center_vertex (_vertices[5 * 9 + 4]);
auto const dist ((center_vertex - camera_pos).length());

View File

@@ -28,9 +28,9 @@ class liquid_layer
public:
liquid_layer() = delete;
liquid_layer(ChunkWater* chunk, math::vector_3d const& base, float height, int liquid_id);
liquid_layer(ChunkWater* chunk, math::vector_3d const& base, mclq& liquid, int liquid_id);
liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, math::vector_3d const& base, MH2O_Information const& info, std::uint64_t infomask);
liquid_layer(ChunkWater* chunk, glm::vec3 const& base, float height, int liquid_id);
liquid_layer(ChunkWater* chunk, glm::vec3 const& base, mclq& liquid, int liquid_id);
liquid_layer(ChunkWater* chunk, MPQFile &f, std::size_t base_pos, glm::vec3 const& base, MH2O_Information const& info, std::uint64_t infomask);
liquid_layer(liquid_layer const& other);
liquid_layer(liquid_layer&&);
@@ -45,7 +45,7 @@ public:
void crop(MapChunk* chunk);
void update_opacity(MapChunk* chunk, float factor);
std::array<math::vector_3d, 9 * 9>& getVertices() { return _vertices; };
std::array<glm::vec3, 9 * 9>& getVertices() { return _vertices; };
std::array<float, 9 * 9>& getDepth() { return _depth; };
std::array<glm::vec2, 9 * 9>& getTexCoords() { return _tex_coords; };
@@ -62,13 +62,13 @@ public:
bool full() const { return _subchunks == std::uint64_t(-1); }
void clear() { _subchunks = std::uint64_t(0); }
void paintLiquid(math::vector_3d const& pos
void paintLiquid(glm::vec3 const& pos
, float radius
, bool add
, math::radians const& angle
, math::radians const& orientation
, bool lock
, math::vector_3d const& origin
, glm::vec3 const& origin
, bool override_height
, MapChunk* chunk
, float opacity_factor
@@ -81,7 +81,7 @@ public:
private:
void update_min_max();
void update_vertex_opacity(int x, int z, MapChunk* chunk, float factor);
int get_lod_level(math::vector_3d const& camera_pos) const;
int get_lod_level(glm::vec3 const& camera_pos) const;
void set_lod_level(int lod_level);
int _liquid_id;
@@ -90,7 +90,7 @@ private:
float _maximum;
std::uint64_t _subchunks;
std::array<math::vector_3d, 9 * 9> _vertices;
std::array<glm::vec3, 9 * 9> _vertices;
std::array<float, 9 * 9> _depth;
std::array<glm::vec2, 9 * 9> _tex_coords;
@@ -98,6 +98,6 @@ private:
private:
math::vector_3d pos;
glm::vec3 pos;
ChunkWater* _chunk;
};

View File

@@ -245,7 +245,7 @@ map_horizon::minimap::minimap(const map_horizon& horizon)
map_horizon::render::render(const map_horizon& horizon)
{
std::vector<math::vector_3d> vertices;
std::vector<glm::vec3> vertices;
for (size_t y (0); y < 64; ++y)
{
@@ -280,7 +280,7 @@ map_horizon::render::render(const map_horizon& horizon)
}
}
gl.bufferData<GL_ARRAY_BUFFER, math::vector_3d> (_vertex_buffer, vertices, GL_STATIC_DRAW);
gl.bufferData<GL_ARRAY_BUFFER, glm::vec3> (_vertex_buffer, vertices, GL_STATIC_DRAW);
}
static inline uint32_t outer_index(const map_horizon_batch &batch, int y, int x)
@@ -296,10 +296,10 @@ static inline uint32_t inner_index(const map_horizon_batch &batch, int y, int x)
void map_horizon::render::draw( math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, MapIndex *index
, const math::vector_3d& color
, const glm::vec3& color
, const float& cull_distance
, const math::frustum& frustum
, const math::vector_3d& camera
, const glm::vec3& camera
, display_mode display
)
{

View File

@@ -51,10 +51,10 @@ public:
void draw( math::matrix_4x4 const& model_view
, math::matrix_4x4 const& projection
, MapIndex *index
, const math::vector_3d& color
, const glm::vec3& color
, const float& cull_distance
, const math::frustum& frustum
, const math::vector_3d& camera
, const glm::vec3& camera
, display_mode display
);

View File

@@ -332,7 +332,7 @@ bool MapIndex::has_unsaved_changes(const tile_index& tile) const
return (tileLoaded(tile) ? getTile(tile)->changed.load() : false);
}
void MapIndex::setFlag(bool to, math::vector_3d const& pos, uint32_t flag)
void MapIndex::setFlag(bool to, glm::vec3 const& pos, uint32_t flag)
{
tile_index tile(pos);
@@ -727,7 +727,7 @@ uid_fix_status MapIndex::fixUIDs (World* world, bool cancel_on_model_loading_err
continue;
}
std::array<math::vector_3d, 2> tileExtents;
std::array<glm::vec3, 2> tileExtents;
tileExtents[0] = { x*TILESIZE, 0, z*TILESIZE };
tileExtents[1] = { (x+1)*TILESIZE, 0, (z+1)*TILESIZE };
misc::minmax(&tileExtents[0], &tileExtents[1]);

View File

@@ -140,7 +140,7 @@ public:
([] (tile_index const&, MapTile* tile) { return !!tile && tile->finishedLoading(); });
}
auto tiles_in_range (math::vector_3d const& pos, float radius)
auto tiles_in_range (glm::vec3 const& pos, float radius)
{
return tiles<true>
( [this, pos, radius] (tile_index const& index, MapTile*)
@@ -151,7 +151,7 @@ public:
);
}
auto tiles_in_rect (math::vector_3d const& pos, float radius)
auto tiles_in_rect (glm::vec3 const& pos, float radius)
{
glm::vec2 l_chunk{pos.x - radius, pos.z - radius};
glm::vec2 r_chunk{pos.x + radius, pos.z + radius};
@@ -183,7 +183,7 @@ public:
void setChanged(MapTile* tile);
void unsetChanged(const tile_index& tile);
void setFlag(bool to, math::vector_3d const& pos, uint32_t flag);
void setFlag(bool to, glm::vec3 const& pos, uint32_t flag);
bool has_unsaved_changes(const tile_index& tile) const;
void saveTile(const tile_index& tile, World*, bool save_unloaded = false);

View File

@@ -12,14 +12,14 @@ namespace noggit {
namespace scripting {
script_brush_event::script_brush_event(
script_settings * settings
, math::vector_3d const& pos
, glm::vec3 const& pos
, float dt)
: _settings(settings)
, _pos(pos)
, _dt(dt)
{}
math::vector_3d script_brush_event::pos()
glm::vec3 script_brush_event::pos()
{
return _pos;
}

View File

@@ -32,9 +32,9 @@ namespace noggit {
{
public:
script_brush_event( script_settings * settings
, math::vector_3d const& pos
, glm::vec3 const& pos
, float dt);
math::vector_3d pos();
glm::vec3 pos();
float outer_radius();
float inner_radius();
@@ -44,7 +44,7 @@ namespace noggit {
float dt();
private:
script_settings * _settings;
math::vector_3d _pos;
glm::vec3 _pos;
float _dt;
};

View File

@@ -25,7 +25,7 @@ namespace noggit
void chunk::set_hole(bool hole)
{
_chunk->setHole(math::vector_3d(0, 0, 0), 10.f, true, hole); // todo: fake const
_chunk->setHole(glm::vec3(0, 0, 0), 10.f, true, hole); // todo: fake const
_chunk->registerChunkUpdate(ChunkUpdateFlags::HOLES);
}
@@ -137,7 +137,7 @@ namespace noggit
std::fill (
_chunk->mccv,
_chunk->mccv + mapbufsize,
math::vector_3d (1.f, 1.f, 1.f)
glm::vec3 (1.f, 1.f, 1.f)
);
}
@@ -158,7 +158,7 @@ namespace noggit
void register_chunk(script_context * state)
{
state->set_function("get_chunk", [state](math::vector_3d const& pos) {
state->set_function("get_chunk", [state](glm::vec3 const& pos) {
return chunk(state,state->tool()->get_view()->_world->getChunkAt(pos));
});

View File

@@ -21,9 +21,9 @@ namespace noggit {
state->set_function("add_m2",[global](
std::string const& filename
, math::vector_3d const& pos
, glm::vec3 const& pos
, float scale
, math::vector_3d const& rotation)
, glm::vec3 const& rotation)
{
// note: we set both min/max random scale and the normal scale parameter,
// because noggit picks one based on random scale settings in the object tool
@@ -35,13 +35,13 @@ namespace noggit {
});
state->set_function("vec",[](float x, float y, float z){
return math::vector_3d(x,y,z);
return glm::vec3(x,y,z);
});
state->set_function("add_wmo",[global](
std::string const& filename
, math::vector_3d const& pos
, math::vector_3d const& rotation)
, glm::vec3 const& pos
, glm::vec3 const& rotation)
{
global->get_view()->_world.get()->addWMO(
filename
@@ -55,7 +55,7 @@ namespace noggit {
});
state->set_function("get_area_id",[global](
math::vector_3d const& pos)
glm::vec3 const& pos)
{
return global->get_view()->_world.get()->getAreaID(pos);
});

View File

@@ -33,19 +33,19 @@ namespace noggit
float sqrt(float arg) { return ::sqrt(arg); }
float abs(float arg) { return ::abs(arg); }
float lerp(float from, float to, float ratio) { return from + ratio * (to - from); }
float dist_2d(math::vector_3d const& from, math::vector_3d const& to)
float dist_2d(glm::vec3 const& from, glm::vec3 const& to)
{
return std::sqrt(std::pow(from.x - to.x, 2) + std::pow(from.z - to.z, 2));
}
int dist_2d_compare(math::vector_3d const& from, math::vector_3d const& to, float compare)
int dist_2d_compare(glm::vec3 const& from, glm::vec3 const& to, float compare)
{
float dist = std::pow(from.x - to.x, 2) + std::pow(from.z - to.z, 2);
compare = std::pow(compare, 2);
return dist > compare ? 1 : dist == compare ? 0 : -1;
}
math::vector_3d rotate_2d(math::vector_3d const& point, math::vector_3d const& origin, float angle)
glm::vec3 rotate_2d(glm::vec3 const& point, glm::vec3 const& origin, float angle)
{
float s = std::sin(angle * 0.0174532925);
float c = std::cos(angle * 0.0174532925);
@@ -56,7 +56,7 @@ namespace noggit
float nx = lx * c - lz * s + origin.x;
float nz = lx * s + lz * c + origin.z;
return math::vector_3d(nx, point.y, nz);
return glm::vec3(nx, point.y, nz);
}
void register_math(script_context * state)
@@ -88,10 +88,10 @@ namespace noggit
state->set_function("dist_2d_compare",dist_2d_compare);
state->set_function("rotate_2d",rotate_2d);
state->new_usertype<math::vector_3d>("vector_3d"
, "x", &math::vector_3d::x
, "y", &math::vector_3d::y
, "z", &math::vector_3d::z
state->new_usertype<glm::vec3>("vector_3d"
, "x", &glm::vec3::x
, "y", &glm::vec3::y
, "z", &glm::vec3::z
);
}
} // namespace scripting

View File

@@ -35,9 +35,9 @@ namespace noggit
float sqrt(float arg);
float abs(float arg);
float lerp(float from, float to, float amount);
float dist_2d(math::vector_3d const& from, math::vector_3d const& to);
int dist_2d_compare(math::vector_3d const& from, math::vector_3d const& to, float dist);
math::vector_3d rotate_2d(math::vector_3d const& point, math::vector_3d const& origin, float angleDeg);
float dist_2d(glm::vec3 const& from, glm::vec3 const& to);
int dist_2d_compare(glm::vec3 const& from, glm::vec3 const& to, float dist);
glm::vec3 rotate_2d(glm::vec3 const& point, glm::vec3 const& origin, float angleDeg);
void register_math(script_context * state);
} // namespace scripting

View File

@@ -23,12 +23,12 @@ namespace noggit
{}
math::vector_3d model::get_pos()
glm::vec3 model::get_pos()
{
return _object->pos;
}
void model::set_pos(math::vector_3d& pos)
void model::set_pos(glm::vec3& pos)
{
world()->updateTilesEntry(_object, model_update::remove);
_object->pos = pos;
@@ -36,12 +36,12 @@ namespace noggit
world()->updateTilesEntry(_object, model_update::add);
}
math::vector_3d model::get_rot()
glm::vec3 model::get_rot()
{
return {_object->dir.x._, _object->dir.y._, _object->dir.z._};
return _object->dir;
}
void model::set_rot(math::vector_3d& rot)
void model::set_rot(glm::vec3& rot)
{
math::degrees::vec3 dir = math::degrees::vec3{ rot };
world()->updateTilesEntry(_object, model_update::remove);
@@ -115,8 +115,8 @@ namespace noggit
void collect_models(
script_context * ctx
, World * world
, math::vector_3d const& min
, math::vector_3d const& max
, glm::vec3 const& min
, glm::vec3 const& max
, std::vector<model> & vec
)
{

View File

@@ -22,11 +22,11 @@ namespace noggit
public:
model(script_context * ctx, SceneObject* object);
math::vector_3d get_pos();
void set_pos(math::vector_3d& pos);
glm::vec3 get_pos();
void set_pos(glm::vec3& pos);
math::vector_3d get_rot();
void set_rot(math::vector_3d& rot);
glm::vec3 get_rot();
void set_rot(glm::vec3& rot);
float get_scale();
void set_scale(float scale);
@@ -47,8 +47,8 @@ namespace noggit
void collect_models(
script_context * ctx
, World * world
, math::vector_3d const& min
, math::vector_3d const& max
, glm::vec3 const& min
, glm::vec3 const& max
, std::vector<model>& vec
);

View File

@@ -29,12 +29,12 @@ namespace noggit
return get_map()[index];
}
float noisemap::get(math::vector_3d& pos)
float noisemap::get(glm::vec3& pos)
{
return get_index("noise_get",std::round(pos.x) - _start_x, std::round(pos.z) - _start_y);
}
bool noisemap::is_highest(math::vector_3d& pos, int check_radius)
bool noisemap::is_highest(glm::vec3& pos, int check_radius)
{
int x = std::round(pos.x) - _start_x;
int z = std::round(pos.z) - _start_y;
@@ -149,9 +149,9 @@ namespace noggit
);
}
math::vector_3d noisemap::start()
glm::vec3 noisemap::start()
{
return math::vector_3d(_start_x,0,_start_y);
return glm::vec3(_start_x,0,_start_y);
}
unsigned noisemap::width()

View File

@@ -28,10 +28,10 @@ namespace noggit
, std::string const& algorithm
, std::string const& seed);
float get(math::vector_3d &pos);
bool is_highest(math::vector_3d &pos, int check_radius);
float get(glm::vec3 &pos);
bool is_highest(glm::vec3 &pos, int check_radius);
void set(int x, int y, float value);
math::vector_3d start();
glm::vec3 start();
unsigned width();
unsigned height();

View File

@@ -17,7 +17,7 @@ namespace noggit {
, float angle
)
{
auto center = math::vector_3d(sel.min().x + (sel.max().x - sel.min().x) / 2, 0, sel.min().z + (sel.max().z - sel.min().z) / 2);
auto center = glm::vec3(sel.min().x + (sel.max().x - sel.min().x) / 2, 0, sel.min().z + (sel.max().z - sel.min().z) / 2);
auto outer_radius = (sel.max().x - sel.min().x) / 2;
int width = img.width();
int height = img.height();

View File

@@ -14,37 +14,37 @@ namespace noggit
{
namespace scripting
{
selection::selection(script_context * ctx, std::string const&,math::vector_3d const& point1, math::vector_3d const& point2)
selection::selection(script_context * ctx, std::string const&,glm::vec3 const& point1, glm::vec3 const& point2)
: script_object(ctx)
, _world(ctx->world())
{
_min = math::vector_3d(
_min = glm::vec3(
std::min(point1.x, point2.x),
std::min(point1.y, point2.y),
std::min(point1.z, point2.z));
_max = math::vector_3d(
_max = glm::vec3(
std::max(point1.x, point2.x),
std::max(point1.y, point2.y),
std::max(point1.z, point2.z));
_size = _max - _min;
_center = _min + (_size / 2);
_center = _min + glm::vec3(_size.x / 2, _size.y / 2, _size.z / 2);
}
math::vector_3d selection::center()
glm::vec3 selection::center()
{
return _center;
}
math::vector_3d selection::min()
glm::vec3 selection::min()
{
return _min;
}
math::vector_3d selection::max()
glm::vec3 selection::max()
{
return _max;
}
math::vector_3d selection::size()
glm::vec3 selection::size()
{
return _size;
}
@@ -156,7 +156,7 @@ namespace noggit
);
state->set_function("select_origin", [state](
math::vector_3d const& origin
glm::vec3 const& origin
, float xRadius
, float zRadius = -1
)
@@ -166,13 +166,13 @@ namespace noggit
zRadius = xRadius;
}
return std::make_shared<selection>(state, "select_origin",
math::vector_3d(origin.x - xRadius, 0, origin.z - zRadius),
math::vector_3d(origin.x + xRadius, 0, origin.z + zRadius));
glm::vec3(origin.x - xRadius, 0, origin.z - zRadius),
glm::vec3(origin.x + xRadius, 0, origin.z + zRadius));
});
state->set_function("select_between", [state](
math::vector_3d const& point1
, math::vector_3d const& point2
glm::vec3 const& point1
, glm::vec3 const& point2
)
{
return std::make_shared<selection>(state, "select_between",

View File

@@ -29,8 +29,8 @@ namespace noggit
public:
selection( script_context * ctx
, std::string const& caller
, math::vector_3d const& point1
, math::vector_3d const& point2
, glm::vec3 const& point1
, glm::vec3 const& point2
);
std::shared_ptr<noisemap> make_noise(
@@ -39,10 +39,10 @@ namespace noggit
, std::string const& seed
);
math::vector_3d center();
math::vector_3d min();
math::vector_3d max();
math::vector_3d size();
glm::vec3 center();
glm::vec3 min();
glm::vec3 max();
glm::vec3 size();
std::vector<chunk> chunks_raw();
std::vector<vert> verts_raw();
@@ -58,10 +58,10 @@ namespace noggit
private:
World* _world;
math::vector_3d _center;
math::vector_3d _min;
math::vector_3d _max;
math::vector_3d _size;
glm::vec3 _center;
glm::vec3 _min;
glm::vec3 _max;
glm::vec3 _size;
};
void register_selection(script_context * state);

View File

@@ -15,7 +15,7 @@ namespace noggit {
: script_object(ctx)
{}
void standard_brush::set_area_id(math::vector_3d const& pos
void standard_brush::set_area_id(glm::vec3 const& pos
, int id
, bool adt
)
@@ -24,8 +24,8 @@ namespace noggit {
}
void standard_brush::change_vertex_color(
math::vector_3d const& pos
, math::vector_3d const& color
glm::vec3 const& pos
, glm::vec3 const& color
, float alpha
, float change
, float radius
@@ -37,19 +37,19 @@ namespace noggit {
pos, glm::vec4(v.x, v.y, v.z, alpha), change, radius, editMode);
}
math::vector_3d standard_brush::get_vertex_color(
math::vector_3d const& pos)
glm::vec3 standard_brush::get_vertex_color(
glm::vec3 const& pos)
{
return world()->pickShaderColor(pos);
}
void standard_brush::flatten_terrain(math::vector_3d const& pos
void standard_brush::flatten_terrain(glm::vec3 const& pos
, float remain
, float radius
, int brush_type
, bool lower
, bool raise
, math::vector_3d const& origin
, glm::vec3 const& origin
, double angle
, double orientation
)
@@ -64,7 +64,7 @@ namespace noggit {
, math::degrees(orientation));
}
void standard_brush::blur_terrain(math::vector_3d const& pos
void standard_brush::blur_terrain(glm::vec3 const& pos
, float remain
, float radius
, int brush_type
@@ -79,27 +79,27 @@ namespace noggit {
, flatten_mode(raise, lower));
}
void standard_brush::erase_textures(math::vector_3d const& pos)
void standard_brush::erase_textures(glm::vec3 const& pos)
{
world()->eraseTextures(pos);
}
void standard_brush::clear_shadows(math::vector_3d const& pos)
void standard_brush::clear_shadows(glm::vec3 const& pos)
{
world()->clear_shadows(pos);
}
void standard_brush::clear_textures(math::vector_3d const& pos)
void standard_brush::clear_textures(glm::vec3 const& pos)
{
world()->clearTextures(pos);
}
void standard_brush::clear_height(math::vector_3d const& pos)
void standard_brush::clear_height(glm::vec3 const& pos)
{
world()->clearHeight(pos);
}
void standard_brush::set_hole( math::vector_3d const& pos
void standard_brush::set_hole( glm::vec3 const& pos
, bool big
, bool hole
)
@@ -107,7 +107,7 @@ namespace noggit {
world()->setHole(pos, 1.0f, big, hole);
}
void standard_brush::set_hole_adt( math::vector_3d const& pos
void standard_brush::set_hole_adt( glm::vec3 const& pos
, bool hole
)
{
@@ -120,7 +120,7 @@ namespace noggit {
world()->updateSelectedVertices();
}
void standard_brush::deselect_vertices( math::vector_3d const& pos
void standard_brush::deselect_vertices( glm::vec3 const& pos
, float radius
)
{
@@ -142,7 +142,7 @@ namespace noggit {
world()->clearVertexSelection();
}
void standard_brush::paint_texture( math::vector_3d const& pos
void standard_brush::paint_texture( glm::vec3 const& pos
, float strength
, float pressure
, float hardness
@@ -160,7 +160,7 @@ namespace noggit {
, scoped_blp_texture_reference(texture, noggit::NoggitRenderContext::MAP_VIEW));
}
void standard_brush::change_terrain( math::vector_3d const& pos
void standard_brush::change_terrain( glm::vec3 const& pos
, float change
, float radius
, float inner_radius

View File

@@ -16,37 +16,37 @@ namespace noggit
class standard_brush : public script_object {
public:
standard_brush(script_context * ctx);
void change_terrain(math::vector_3d const&
void change_terrain(glm::vec3 const&
, float change
, float radius
, float inner_radius
, int brush_type
);
void set_area_id(math::vector_3d const&, int id, bool adt);
void set_area_id(glm::vec3 const&, int id, bool adt);
void change_vertex_color(math::vector_3d const& pos
, math::vector_3d const& color
void change_vertex_color(glm::vec3 const& pos
, glm::vec3 const& color
, float alpha
, float change
, float radius
, bool editMode
);
math::vector_3d get_vertex_color(math::vector_3d const& pos);
glm::vec3 get_vertex_color(glm::vec3 const& pos);
void flatten_terrain(math::vector_3d const& pos
void flatten_terrain(glm::vec3 const& pos
, float remain
, float radius
, int brush_type
, bool lower
, bool raise
, math::vector_3d const& origin
, glm::vec3 const& origin
, double angle
, double orientation
);
void blur_terrain(math::vector_3d const& pos
void blur_terrain(glm::vec3 const& pos
, float remain
, float radius
, int brush_type
@@ -54,18 +54,18 @@ namespace noggit
, bool raise
);
void erase_textures(math::vector_3d const& pos);
void clear_shadows(math::vector_3d const& pos);
void clear_textures(math::vector_3d const& pos);
void clear_height(math::vector_3d const& pos);
void set_hole(math::vector_3d const& pos, bool big, bool hole);
void set_hole_adt(math::vector_3d const& pos, bool hole);
void deselect_vertices(math::vector_3d const& pos, float radius);
void erase_textures(glm::vec3 const& pos);
void clear_shadows(glm::vec3 const& pos);
void clear_textures(glm::vec3 const& pos);
void clear_height(glm::vec3 const& pos);
void set_hole(glm::vec3 const& pos, bool big, bool hole);
void set_hole_adt(glm::vec3 const& pos, bool hole);
void deselect_vertices(glm::vec3 const& pos, float radius);
void clear_vertex_selection ();
void move_vertices(float h);
void flatten_vertices(float h);
void update_vertices ();
void paint_texture(math::vector_3d const& pos
void paint_texture(glm::vec3 const& pos
, float strength
, float pressure
, float hardness

View File

@@ -45,17 +45,17 @@ namespace noggit {
}
namespace {
math::vector_3d tex_location(MapChunk* chnk, int index)
glm::vec3 tex_location(MapChunk* chnk, int index)
{
float cx = chnk->xbase;
float cz = chnk->zbase;
float x = index % TEXTURE_UNITS_WIDTH;
float z = (float(index) / float(TEXTURE_UNITS_WIDTH));
return math::vector_3d(cx + x * TEXDETAILSIZE, 0, cz + z * TEXDETAILSIZE);
return glm::vec3(cx + x * TEXDETAILSIZE, 0, cz + z * TEXDETAILSIZE);
}
}
math::vector_3d tex::get_pos_2d()
glm::vec3 tex::get_pos_2d()
{
return tex_location(_chunk, _index);
}
@@ -64,13 +64,13 @@ namespace noggit {
script_context * ctx
, MapChunk* chnk
, std::vector<tex>& vec
, math::vector_3d const& min
, math::vector_3d const& max
, glm::vec3 const& min
, glm::vec3 const& max
)
{
for (int i = 0; i < TEXTURE_UNITS_PER_CHUNK; ++i)
{
math::vector_3d loc = tex_location(chnk, i);
glm::vec3 loc = tex_location(chnk, i);
if (loc.x >= min.x && loc.x <= max.x && loc.z >= min.z && loc.z <= max.z)
{
vec.emplace_back(ctx, chnk, i);

View File

@@ -19,7 +19,7 @@ namespace noggit {
tex(script_context * ctx, MapChunk* chunk, int index);
void set_alpha(int index, float alpha);
float get_alpha(int index);
math::vector_3d get_pos_2d();
glm::vec3 get_pos_2d();
private:
MapChunk* _chunk;
@@ -30,16 +30,16 @@ namespace noggit {
script_context* ctx
, MapChunk* chnk
, std::vector<tex>& vec
, math::vector_3d const& min
, math::vector_3d const& max
, glm::vec3 const& min
, glm::vec3 const& max
);
class tex_iterator : public script_object {
public:
tex_iterator( script_context * ctx
, std::shared_ptr<std::vector<MapChunk*>> chunks
, math::vector_3d const& min
, math::vector_3d const& max
, glm::vec3 const& min
, glm::vec3 const& max
);
bool next();
tex get();
@@ -50,8 +50,8 @@ namespace noggit {
int _tex_iter = -1;
std::shared_ptr<std::vector<MapChunk*>> _chunks;
std::vector<MapChunk*>::iterator _chunk_iter;
math::vector_3d const& _min;
math::vector_3d const& _max;
glm::vec3 const& _min;
glm::vec3 const& _max;
};
void register_tex(script_context * state);

View File

@@ -46,18 +46,18 @@ namespace noggit
void vert::set_color(float r, float g, float b)
{
// todo create MCCV
_chunk->mccv[_index] = math::vector_3d(r, g, b);
_chunk->mccv[_index] = glm::vec3(r, g, b);
}
math::vector_3d vert::get_color()
glm::vec3 vert::get_color()
{
if (!_chunk->hasColors())
{
return math::vector_3d(1, 1, 1);
return glm::vec3(1, 1, 1);
}
else
{
return math::vector_3d(_chunk->mccv[_index]);
return glm::vec3(_chunk->mccv[_index]);
}
}
@@ -69,7 +69,7 @@ namespace noggit
}
// TODO: Extremely inefficient
_chunk->liquid_chunk()->paintLiquid(get_pos(), 1, type, true, math::radians(0), math::radians(0), true, math::vector_3d(0, height, 0), true, true, _chunk, 1);
_chunk->liquid_chunk()->paintLiquid(get_pos(), 1, type, true, math::radians(0), math::radians(0), true, glm::vec3(0, height, 0), true, true, _chunk, 1);
}
void vert::set_hole(bool add)
@@ -77,7 +77,7 @@ namespace noggit
_chunk->setHole(get_pos(), 1.f, false, add);
}
math::vector_3d vert::get_pos()
glm::vec3 vert::get_pos()
{
return _chunk->mVertices[_index];
}

View File

@@ -18,12 +18,12 @@ namespace noggit
{
public:
vert(script_context * ctx, MapChunk* chunk, int index);
math::vector_3d get_pos();
glm::vec3 get_pos();
void set_height(float y);
void add_height(float y);
void sub_height(float y);
math::vector_3d get_color();
glm::vec3 get_color();
void set_color(float r, float g, float b);
void set_water(int type, float height);
void set_hole(bool add);

View File

@@ -208,7 +208,7 @@ namespace noggit
get_settings()->save_json();
}
void scripting_tool::sendBrushEvent(math::vector_3d const& pos, float dt)
void scripting_tool::sendBrushEvent(glm::vec3 const& pos, float dt)
{
bool new_left = get_view()->leftMouse;
bool new_right = get_view()->rightMouse;

View File

@@ -49,7 +49,7 @@ namespace noggit
void resetLogScroll();
void clearLog();
void doReload();
void sendBrushEvent(math::vector_3d const& pos,float dt);
void sendBrushEvent(glm::vec3 const& pos,float dt);
MapView* get_view();
script_context* get_context();

View File

@@ -400,7 +400,7 @@ bool TextureSet::stampTexture(float xbase, float zbase, float x, float z, Brush*
dist = misc::dist(x, z, xPos + TEXDETAILSIZE / 2.0f, zPos + TEXDETAILSIZE / 2.0f);
math::vector_3d const diff{math::vector_3d{xPos + TEXDETAILSIZE / 2.0f, 0.f, zPos + TEXDETAILSIZE / 2.0f} - math::vector_3d{x, 0.f, z}};
glm::vec3 const diff{glm::vec3{xPos + TEXDETAILSIZE / 2.0f, 0.f, zPos + TEXDETAILSIZE / 2.0f} - glm::vec3{x, 0.f, z}};
int pixel_x = std::round(((diff.x + radius) / (2.f * radius)) * image->width());
int pixel_y = std::round(((diff.z + radius) / (2.f * radius)) * image->height());
@@ -574,7 +574,7 @@ bool TextureSet::stampTexture(float xbase, float zbase, float x, float z, Brush*
dist = misc::dist(x, z, xPos + TEXDETAILSIZE / 2.0f, zPos + TEXDETAILSIZE / 2.0f);
math::vector_3d const diff{math::vector_3d{xPos + TEXDETAILSIZE / 2.0f, 0.f, zPos + TEXDETAILSIZE / 2.0f} - math::vector_3d{x, 0.f, z}};
glm::vec3 const diff{glm::vec3{xPos + TEXDETAILSIZE / 2.0f, 0.f, zPos + TEXDETAILSIZE / 2.0f} - glm::vec3{x, 0.f, z}};
int pixel_x = std::floor(diff.x + radius);
int pixel_y = std::floor(diff.z + radius);

Some files were not shown because too many files have changed in this diff Show More