rename + move to c++
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include <stdint.h>
|
||||
#include <forward_list>
|
||||
#include <mutex>
|
||||
#include <llmr/util/vec2.hpp>
|
||||
#include <llmr/util/vec.hpp>
|
||||
|
||||
namespace llmr {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define LLMR_MAP_TRANSFORM
|
||||
|
||||
|
||||
#include <llmr/util/vec2.hpp>
|
||||
#include <llmr/util/vec.hpp>
|
||||
#include <llmr/util/animation.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -20,23 +20,21 @@
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
#ifndef llmr_util_mat4_
|
||||
#define llmr_util_mat4_
|
||||
#ifndef LLMR_UTIL_MAT4
|
||||
#define LLMR_UTIL_MAT4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
namespace llmr {
|
||||
namespace mat4 {
|
||||
|
||||
void mat4_identity(float out[16]);
|
||||
void mat4_ortho(float out[16], float left, float right, float bottom, float top, float near, float far);
|
||||
void mat4_copy(float out[16], float a[16]);
|
||||
void mat4_translate(float out[16], float a[16], float x, float y, float z);
|
||||
void mat4_rotate_z(float out[16], float a[16], float rad);
|
||||
void mat4_scale(float out[16], float a[16], float x, float y, float z);
|
||||
void mat4_multiply(float out[16], float a[16], float b[16]);
|
||||
void identity(float out[16]);
|
||||
void ortho(float out[16], float left, float right, float bottom, float top, float near, float far);
|
||||
void copy(float out[16], float a[16]);
|
||||
void translate(float out[16], float a[16], float x, float y, float z);
|
||||
void rotate_z(float out[16], float a[16], float rad);
|
||||
void scale(float out[16], float a[16], float x, float y, float z);
|
||||
void multiply(float out[16], float a[16], float b[16]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@ SET(llmr_SOURCES
|
||||
renderer/shader.cpp
|
||||
shader/shaders.cpp
|
||||
util/animation.cpp
|
||||
util/mat4.c
|
||||
util/mat4.cpp
|
||||
)
|
||||
|
||||
SET(llmr_HEADERS
|
||||
@@ -31,6 +31,7 @@ SET(llmr_HEADERS
|
||||
../include/llmr/shader/shaders.hpp
|
||||
../include/llmr/util/animation.hpp
|
||||
../include/llmr/util/math.hpp
|
||||
../include/llmr/util/mat4.hpp
|
||||
../include/llmr/util/vec2.hpp
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <llmr/map/map.hpp>
|
||||
#include <llmr/map/tile.hpp>
|
||||
#include <llmr/util/vec2.hpp>
|
||||
//#include <llmr/util/vec2.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <thread>
|
||||
|
||||
#include <llmr/util/pbf.hpp>
|
||||
#include <llmr/util/vec2.hpp>
|
||||
#include <llmr/util/string.hpp>
|
||||
#include <llmr/geometry/geometry.hpp>
|
||||
#include <cmath>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <llmr/map/transform.hpp>
|
||||
#include <llmr/util/mat4.h>
|
||||
#include <llmr/util/mat4.hpp>
|
||||
#include <llmr/util/math.hpp>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
@@ -149,19 +149,19 @@ void transform::matrixFor(float matrix[16], const vec3<int32_t>& id) const {
|
||||
const double tile_scale = pow(2, id.z);
|
||||
const double tile_size = scale * size / tile_scale;
|
||||
|
||||
mat4_identity(matrix);
|
||||
mat4::identity(matrix);
|
||||
|
||||
mat4_translate(matrix, matrix, 0.5f * (float)width, 0.5f * (float)height, 0);
|
||||
mat4_rotate_z(matrix, matrix, angle);
|
||||
mat4_translate(matrix, matrix, -0.5f * (float)width, -0.5f * (float)height, 0);
|
||||
mat4::translate(matrix, matrix, 0.5f * (float)width, 0.5f * (float)height, 0);
|
||||
mat4::rotate_z(matrix, matrix, angle);
|
||||
mat4::translate(matrix, matrix, -0.5f * (float)width, -0.5f * (float)height, 0);
|
||||
|
||||
mat4_translate(matrix, matrix, pixel_x() + id.x * tile_size, pixel_y() + id.y * tile_size, 0);
|
||||
mat4::translate(matrix, matrix, pixel_x() + id.x * tile_size, pixel_y() + id.y * tile_size, 0);
|
||||
|
||||
// TODO: Get rid of the 8 (scaling from 4096 to 512 px tile size);
|
||||
mat4_scale(matrix, matrix, scale / tile_scale / 8, scale / tile_scale / 8, 1);
|
||||
mat4::scale(matrix, matrix, scale / tile_scale / 8, scale / tile_scale / 8, 1);
|
||||
|
||||
// Clipping plane
|
||||
mat4_translate(matrix, matrix, 0, 0, -1);
|
||||
mat4::translate(matrix, matrix, 0, 0, -1);
|
||||
}
|
||||
|
||||
int32_t transform::getZoom() const {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <llmr/renderer/painter.hpp>
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
#include <llmr/util/mat4.h>
|
||||
#include <llmr/util/mat4.hpp>
|
||||
#include <llmr/platform/platform.hpp>
|
||||
#include <llmr/map/transform.hpp>
|
||||
#include <llmr/map/tile.hpp>
|
||||
@@ -88,12 +88,12 @@ void painter::changeMatrix(const tile::ptr& tile) {
|
||||
|
||||
// Initialize projection matrix
|
||||
float projMatrix[16];
|
||||
mat4_ortho(projMatrix, 0, transform->width, transform->height, 0, 1, 10);
|
||||
mat4::ortho(projMatrix, 0, transform->width, transform->height, 0, 1, 10);
|
||||
|
||||
float mvMatrix[16];
|
||||
transform->matrixFor(mvMatrix, tile->id);
|
||||
|
||||
mat4_multiply(matrix, projMatrix, mvMatrix);
|
||||
mat4::multiply(matrix, projMatrix, mvMatrix);
|
||||
}
|
||||
|
||||
void painter::drawClippingMask() {
|
||||
|
||||
@@ -20,11 +20,13 @@
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
#include <llmr/util/mat4.h>
|
||||
#include <llmr/util/mat4.hpp>
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
void mat4_identity(float out[16]) {
|
||||
using namespace llmr;
|
||||
|
||||
void mat4::identity(float out[16]) {
|
||||
out[0] = 1.0f;
|
||||
out[1] = 0.0f;
|
||||
out[2] = 0.0f;
|
||||
@@ -43,7 +45,7 @@ void mat4_identity(float out[16]) {
|
||||
out[15] = 1.0f;
|
||||
}
|
||||
|
||||
void mat4_ortho(float out[16], float left, float right, float bottom, float top, float near, float far) {
|
||||
void mat4::ortho(float out[16], float left, float right, float bottom, float top, float near, float far) {
|
||||
float lr = 1.0f / (left - right),
|
||||
bt = 1.0f / (bottom - top),
|
||||
nf = 1.0f / (near - far);
|
||||
@@ -65,7 +67,7 @@ void mat4_ortho(float out[16], float left, float right, float bottom, float top,
|
||||
out[15] = 1.0f;
|
||||
}
|
||||
|
||||
void mat4_copy(float out[16], float a[16]) {
|
||||
void mat4::copy(float out[16], float a[16]) {
|
||||
out[0] = a[0];
|
||||
out[1] = a[1];
|
||||
out[2] = a[2];
|
||||
@@ -84,7 +86,7 @@ void mat4_copy(float out[16], float a[16]) {
|
||||
out[15] = a[15];
|
||||
}
|
||||
|
||||
void mat4_translate(float out[16], float a[16], float x, float y, float z) {
|
||||
void mat4::translate(float out[16], float a[16], float x, float y, float z) {
|
||||
float a00, a01, a02, a03,
|
||||
a10, a11, a12, a13,
|
||||
a20, a21, a22, a23;
|
||||
@@ -110,7 +112,7 @@ void mat4_translate(float out[16], float a[16], float x, float y, float z) {
|
||||
}
|
||||
}
|
||||
|
||||
void mat4_rotate_z(float out[16], float a[16], float rad) {
|
||||
void mat4::rotate_z(float out[16], float a[16], float rad) {
|
||||
float s = sin(rad),
|
||||
c = cos(rad),
|
||||
a00 = a[0],
|
||||
@@ -144,7 +146,7 @@ void mat4_rotate_z(float out[16], float a[16], float rad) {
|
||||
out[7] = a13 * c - a03 * s;
|
||||
}
|
||||
|
||||
void mat4_scale(float out[16], float a[16], float x, float y, float z) {
|
||||
void mat4::scale(float out[16], float a[16], float x, float y, float z) {
|
||||
out[0] = a[0] * x;
|
||||
out[1] = a[1] * x;
|
||||
out[2] = a[2] * x;
|
||||
@@ -163,7 +165,7 @@ void mat4_scale(float out[16], float a[16], float x, float y, float z) {
|
||||
out[15] = a[15];
|
||||
}
|
||||
|
||||
void mat4_multiply(float out[16], float a[16], float b[16]) {
|
||||
void mat4::multiply(float out[16], float a[16], float b[16]) {
|
||||
float a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
|
||||
a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
|
||||
a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
|
||||
Reference in New Issue
Block a user