Merge pull request #83 from IMXNOOBX/main
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
#pragma once
|
||||
#ifndef _VECTOR_ESP_
|
||||
#define _VECTOR_ESP_
|
||||
#include <numbers>
|
||||
#include <cmath>
|
||||
|
||||
#include "globals.hpp"
|
||||
|
||||
struct view_matrix_t {
|
||||
float* operator[ ](int index) {
|
||||
return matrix[index];
|
||||
}
|
||||
|
||||
float matrix[4][4];
|
||||
};
|
||||
|
||||
struct Vector3
|
||||
{
|
||||
// constructor
|
||||
@@ -80,25 +72,6 @@ struct Vector3
|
||||
return x == 0.f && y == 0.f && z == 0.f;
|
||||
}
|
||||
|
||||
Vector3 world_to_screen(view_matrix_t matrix) const {
|
||||
float _x = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z + matrix[0][3];
|
||||
float _y = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z + matrix[1][3];
|
||||
|
||||
float w = matrix[3][0] * x + matrix[3][1] * y + matrix[3][2] * z + matrix[3][3];
|
||||
|
||||
float inv_w = 1.f / w;
|
||||
_x *= inv_w;
|
||||
_y *= inv_w;
|
||||
|
||||
float x = g::gameBounds.right * .5f;
|
||||
float y = g::gameBounds.bottom * .5f;
|
||||
|
||||
x += 0.5f * _x * g::gameBounds.right + 0.5f;
|
||||
y -= 0.5f * _y * g::gameBounds.bottom + 0.5f;
|
||||
|
||||
return { x, y, w };
|
||||
}
|
||||
|
||||
float calculate_distance(const Vector3& point) const {
|
||||
float dx = point.x - x;
|
||||
float dy = point.y - y;
|
||||
@@ -109,4 +82,5 @@ struct Vector3
|
||||
|
||||
// struct data
|
||||
float x, y, z;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user