Merge branch 'master' into 'noggit-shadowlands'
Master See merge request prophecy-rp/noggit-red!8
This commit is contained in:
@@ -3,23 +3,24 @@
|
||||
#include <math/frustum.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <external/glm/glm.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_access.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
frustum::frustum (glm::mat4x4 const& matrix)
|
||||
{
|
||||
const glm::vec4 column_0 = matrix[0];
|
||||
const glm::vec4 column_1 = matrix[1];
|
||||
const glm::vec4 column_2 = matrix[2];
|
||||
const glm::vec4 column_3 = matrix[3];
|
||||
const glm::vec4 row_0 = glm::row(matrix, 0);
|
||||
const glm::vec4 row_1 = glm::row(matrix, 1);
|
||||
const glm::vec4 row_2 = glm::row(matrix, 2);
|
||||
const glm::vec4 row_3 = glm::row(matrix, 3);
|
||||
|
||||
_planes[RIGHT] = column_3 - column_0;
|
||||
_planes[LEFT] = column_3 + column_0;
|
||||
_planes[TOP] = column_3 - column_1;
|
||||
_planes[BOTTOM] = column_3 + column_1;
|
||||
_planes[BACK] = column_3 - column_2;
|
||||
_planes[FRONT] = column_3 + column_2;
|
||||
_planes[RIGHT] = row_3 - row_0;
|
||||
_planes[LEFT] = row_3 + row_0;
|
||||
_planes[TOP] = row_3 - row_1;
|
||||
_planes[BOTTOM] = row_3 + row_1;
|
||||
_planes[BACK] = row_3 - row_2;
|
||||
_planes[FRONT] = row_3 + row_2;
|
||||
}
|
||||
|
||||
bool frustum::contains (const glm::vec3& point) const
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <map>
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
#include <limits>
|
||||
|
||||
MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
tile_mode mode, noggit::NoggitRenderContext context, bool init_empty, int chunk_idx)
|
||||
@@ -28,12 +29,15 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
, mt(maintile)
|
||||
, use_big_alphamap(bigAlpha)
|
||||
, _context(context)
|
||||
, vmin(std::numeric_limits<float>::max())
|
||||
, vmax(std::numeric_limits<float>::lowest())
|
||||
, _chunk_update_flags(ChunkUpdateFlags::VERTEX | ChunkUpdateFlags::ALPHAMAP
|
||||
| ChunkUpdateFlags::SHADOW | ChunkUpdateFlags::MCCV
|
||||
| ChunkUpdateFlags::NORMALS| ChunkUpdateFlags::HOLES
|
||||
| ChunkUpdateFlags::AREA_ID| ChunkUpdateFlags::FLAGS)
|
||||
{
|
||||
|
||||
|
||||
if (init_empty)
|
||||
{
|
||||
|
||||
@@ -76,10 +80,6 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
zbase = zbase*-1.0f + ZEROPOINT;
|
||||
xbase = xbase*-1.0f + ZEROPOINT;
|
||||
|
||||
vmin.y = 0.0f;
|
||||
vmin = glm::vec3(9999999.0f, 9999999.0f, 9999999.0f);
|
||||
vmax = glm::vec3(-9999999.0f, -9999999.0f, -9999999.0f);
|
||||
|
||||
glm::vec3 *ttv = mVertices;
|
||||
|
||||
for (int j = 0; j < 17; ++j) {
|
||||
@@ -145,9 +145,6 @@ MapChunk::MapChunk(MapTile *maintile, MPQFile *f, bool bigAlpha,
|
||||
// correct the x and z values ^_^
|
||||
zbase = zbase*-1.0f + ZEROPOINT;
|
||||
xbase = xbase*-1.0f + ZEROPOINT;
|
||||
|
||||
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,
|
||||
|
||||
@@ -59,9 +59,8 @@ MapTile::MapTile( int pX
|
||||
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}
|
||||
, _object_instance_extents{glm::vec3{std::numeric_limits<float>::max()}, glm::vec3{std::numeric_limits<float>::lowest()}}
|
||||
, _center{pX * TILESIZE + TILESIZE / 2.f, 0.f, pZ * TILESIZE + TILESIZE / 2.f}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ ModelInstance::ModelInstance(std::string const& filename, noggit::NoggitRenderCo
|
||||
: SceneObject(SceneObjectTypes::eMODEL, context, filename)
|
||||
, model (filename, context)
|
||||
{
|
||||
pos = glm::vec3(0.f, 0.f, 0.f);
|
||||
dir = math::degrees::vec3(0, 0, 0);
|
||||
}
|
||||
|
||||
ModelInstance::ModelInstance(std::string const& filename, ENTRY_MDDF const*d, noggit::NoggitRenderContext context)
|
||||
@@ -191,15 +189,15 @@ void ModelInstance::recalcExtents()
|
||||
auto points = relative_to_model.all_corners();
|
||||
for (auto& point : points)
|
||||
{
|
||||
point = transform(point);
|
||||
corners_in_world.push_back(point);
|
||||
point = transform(point);
|
||||
corners_in_world.push_back(point);
|
||||
}
|
||||
|
||||
auto rotated_corners_in_world = std::vector<glm::vec3>();
|
||||
auto transposedMat = _transform_mat;
|
||||
for (auto const& point : corners_in_world)
|
||||
{
|
||||
rotated_corners_in_world.push_back(transposedMat * glm::vec4(point,0));
|
||||
rotated_corners_in_world.push_back(transposedMat * glm::vec4(point, 1.f));
|
||||
}
|
||||
|
||||
math::aabb const bounding_of_rotated_points (rotated_corners_in_world);
|
||||
|
||||
@@ -6,12 +6,18 @@
|
||||
#include <glm/gtx/euler_angles.hpp>
|
||||
#include <noggit/Misc.h>
|
||||
#include <math/trig.hpp>
|
||||
#include <limits>
|
||||
|
||||
SceneObject::SceneObject(SceneObjectTypes type, noggit::NoggitRenderContext context, std::string filename)
|
||||
: _type(type)
|
||||
, _filename(filename)
|
||||
, _context(context)
|
||||
, pos(0.f, 0.f, 0.f)
|
||||
, dir(0.f, 0.f, 0.f)
|
||||
{
|
||||
// min and max initialized to their opposites
|
||||
extents[0] = glm::vec3(std::numeric_limits<float>::max());
|
||||
extents[1] = glm::vec3(std::numeric_limits<float>::lowest());
|
||||
}
|
||||
|
||||
bool SceneObject::isInsideRect(std::array<glm::vec3, 2> const* rect) const
|
||||
@@ -29,15 +35,9 @@ bool SceneObject::isDuplicateOf(SceneObject const& other)
|
||||
|
||||
void SceneObject::updateTransformMatrix()
|
||||
{
|
||||
auto rotationVector = glm::vec3(0);
|
||||
rotationVector.x = glm::radians(dir.x);
|
||||
rotationVector.y = glm::radians(dir.y - math::degrees(90.0)._);
|
||||
rotationVector.z = glm::radians(dir.z);
|
||||
|
||||
auto matrix = glm::mat4x4(1);
|
||||
matrix = glm::translate(matrix, pos);
|
||||
glm::quat roationQuat = glm::quat(rotationVector);
|
||||
matrix = matrix * glm::toMat4(roationQuat);
|
||||
matrix = matrix * glm::eulerAngleYZX(glm::radians(dir.y - math::degrees(90.0)._), glm::radians(-dir.x), glm::radians(dir.z));
|
||||
matrix = glm::scale(matrix, glm::vec3(scale, scale, scale));
|
||||
|
||||
_transform_mat = matrix;
|
||||
|
||||
@@ -215,7 +215,7 @@ void WMOInstance::recalcExtents()
|
||||
|
||||
for (auto const& point : root_points)
|
||||
{
|
||||
adjustedPoints.push_back(_transform_mat * glm::vec4(point,0));
|
||||
adjustedPoints.push_back(_transform_mat * glm::vec4(point, 1.f));
|
||||
}
|
||||
|
||||
points.insert(points.end(), adjustedPoints.begin(), adjustedPoints.end());
|
||||
@@ -229,7 +229,7 @@ void WMOInstance::recalcExtents()
|
||||
|
||||
for (auto const& point : group_points)
|
||||
{
|
||||
adjustedGroupPoints.push_back(_transform_mat * glm::vec4(point, 0));
|
||||
adjustedGroupPoints.push_back(_transform_mat * glm::vec4(point, 1.f));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1298,17 +1298,17 @@ void World::draw (glm::mat4x4 const& model_view
|
||||
{
|
||||
opengl::scoped::use_program mcnk_shader{ *_mcnk_program.get() };
|
||||
|
||||
mcnk_shader.uniform ("camera", glm::vec3(camera_pos.x, camera_pos.y, camera_pos.z));
|
||||
mcnk_shader.uniform ("animtime", static_cast<int>(animtime));
|
||||
mcnk_shader.uniform("camera", glm::vec3(camera_pos.x, camera_pos.y, camera_pos.z));
|
||||
mcnk_shader.uniform("animtime", static_cast<int>(animtime));
|
||||
|
||||
if (cursor_type != CursorType::NONE)
|
||||
{
|
||||
mcnk_shader.uniform("draw_cursor_circle", static_cast<int>(cursor_type));
|
||||
mcnk_shader.uniform ("cursor_position", glm::vec3(cursor_pos.x, cursor_pos.y, cursor_pos.z));
|
||||
mcnk_shader.uniform("cursor_position", glm::vec3(cursor_pos.x, cursor_pos.y, cursor_pos.z));
|
||||
mcnk_shader.uniform("cursorRotation", cursorRotation);
|
||||
mcnk_shader.uniform ("outer_cursor_radius", brush_radius);
|
||||
mcnk_shader.uniform ("inner_cursor_ratio", inner_radius_ratio);
|
||||
mcnk_shader.uniform ("cursor_color", cursor_color);
|
||||
mcnk_shader.uniform("outer_cursor_radius", brush_radius);
|
||||
mcnk_shader.uniform("inner_cursor_ratio", inner_radius_ratio);
|
||||
mcnk_shader.uniform("cursor_color", cursor_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1516,7 +1516,7 @@ void World::draw (glm::mat4x4 const& model_view
|
||||
, draw_fog
|
||||
, current_selection()
|
||||
, animtime
|
||||
,skies->hasSkies()
|
||||
, skies->hasSkies()
|
||||
, display
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user