Moved axis_angle_from_vectors to vec3 definition

This commit is contained in:
korenkonder
2025-04-18 19:21:22 +03:00
parent f945af1be1
commit a7ae5bee02
7 changed files with 14 additions and 34 deletions
-17
View File
@@ -11,23 +11,6 @@
namespace Glitter {
const float_t min_emission = 0.01f;
void axis_angle_from_vectors(vec3& axis, float_t& angle, const vec3& vec1, const vec3& vec2) {
axis = vec3::cross(vec1, vec2);
angle = vec3::length(axis);
if (angle >= 0.000001f)
angle = asinf(clamp_def(angle, -1.0f, 1.0f));
else {
angle = 0.0f;
axis = vec3::cross(vec3(0.0f, 1.0f, 0.0f), vec1);
if (vec3::length(axis) < 0.000001f)
axis = vec3::cross(vec3(0.0f, 0.0f, 1.0f), vec1);
}
if (vec3::dot(vec1, vec2) < 0.0f)
angle = (float_t)M_PI - angle;
}
void CreateBuffer(size_t max_count, bool is_quad,
Buffer*& buffer, GLuint& vao, GL::ArrayBuffer& vbo, GL::ElementArrayBuffer& ebo) {
if (buffer) {
-2
View File
@@ -1500,8 +1500,6 @@ namespace Glitter {
extern RandomX random_x;
extern Counter& counter;
extern void axis_angle_from_vectors(vec3& axis, float_t& angle, const vec3& vec0, const vec3& vec1);
extern void CreateBuffer(size_t max_count, bool is_quad,
Buffer*& buffer, GLuint& vao, GL::ArrayBuffer& vbo, GL::ElementArrayBuffer& ebo);
extern void DeleteBuffer(Buffer*& buffer, GLuint& vao, GL::ArrayBuffer& vbo, GL::ElementArrayBuffer& ebo);
+6 -6
View File
@@ -24,7 +24,7 @@ namespace Glitter {
vec3 axis;
float_t angle;
axis_angle_from_vectors(axis, angle, vec1, vec2);
vec3::axis_angle_from_vectors(axis, angle, vec1, vec2);
mat4_mul_rotation(&mat, &axis, angle, &mat);
}
else
@@ -47,7 +47,7 @@ namespace Glitter {
vec3 axis;
float_t angle;
axis_angle_from_vectors(axis, angle, vec1, vec2);
vec3::axis_angle_from_vectors(axis, angle, vec1, vec2);
mat4_mul_rotation(&mat, &axis, angle, &mat);
}
return mat;
@@ -467,7 +467,7 @@ namespace Glitter {
vec3 axis;
float_t angle;
axis_angle_from_vectors(axis, angle, vec1, vec2);
vec3::axis_angle_from_vectors(axis, angle, vec1, vec2);
mat4 mat = mat4_identity;
mat4_mul_rotation(&mat, &axis, angle, &mat);
@@ -487,7 +487,7 @@ namespace Glitter {
vec3 axis;
float_t angle;
axis_angle_from_vectors(axis, angle, vec1, vec2);
vec3::axis_angle_from_vectors(axis, angle, vec1, vec2);
mat4 mat = mat4_identity;
mat4_mul_rotation(&mat, &axis, angle, &mat);
@@ -509,7 +509,7 @@ namespace Glitter {
vec3 axis;
float_t angle;
axis_angle_from_vectors(axis, angle, vec1, vec2);
vec3::axis_angle_from_vectors(axis, angle, vec1, vec2);
mat4 mat = mat4_identity;
mat4_mul_rotation(&mat, &axis, angle, &mat);
@@ -529,7 +529,7 @@ namespace Glitter {
vec3 axis;
float_t angle;
axis_angle_from_vectors(axis, angle, vec1, vec2);
vec3::axis_angle_from_vectors(axis, angle, vec1, vec2);
mat4 mat = mat4_identity;
mat4_mul_rotation(&mat, &axis, angle, &mat);
+4 -5
View File
@@ -12,9 +12,8 @@
#include "../../AFTModsShared/canonical_properties.hpp"
#include "../../AFTModsShared/dw.hpp"
#include "../../AFTModsShared/resolution_mode.hpp"
#include "../Glitter/glitter.hpp"
#include "../rob/rob.hpp"
#include "../render_context.hpp"
#include "../../AFTModsShared/file_handler.hpp"
#include "../mdl/disp_manager.hpp"
#include <Helpers.h>
class RobOsageTestDw : public dw::Shell {
@@ -1105,7 +1104,7 @@ void RobOsageTest::disp_coli_cls_list(ExNodeBlock* ex_node, SkinParam::Collision
const vec3 up = { 0.0f, 1.0f, 0.0f };
vec3 axis;
float_t angle;
Glitter::axis_angle_from_vectors(axis, angle, up, dir);
vec3::axis_angle_from_vectors(axis, angle, up, dir);
mat4 mat_rot = mat4_identity;
mat4_mul_rotation(&mat_rot, &axis, angle, &mat_rot);
@@ -1140,7 +1139,7 @@ void RobOsageTest::disp_coli_cls_list(ExNodeBlock* ex_node, SkinParam::Collision
const vec3 up = { 0.0f, 1.0f, 0.0f };
vec3 axis;
float_t angle;
Glitter::axis_angle_from_vectors(axis, angle, up, dir);
vec3::axis_angle_from_vectors(axis, angle, up, dir);
mat4 m = mat4_identity;
mat4_mul_rotation(&m, &axis, angle, &m);
+1 -1
View File
@@ -7,9 +7,9 @@
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/prj/vector_pair.hpp"
#include "../../AFTModsShared/rob/rob.hpp"
#include "../../AFTModsShared/task.hpp"
#include "../../AFTModsShared/types.hpp"
#include "../rob/rob.hpp"
class RobOsageTest : public app::Task {
public:
+2 -2
View File
@@ -1542,7 +1542,7 @@ namespace mdl {
const vec3 up = { 0.0f, 1.0f, 0.0f };
vec3 axis;
float_t angle;
Glitter::axis_angle_from_vectors(axis, angle, up, dir);
vec3::axis_angle_from_vectors(axis, angle, up, dir);
mat4 m = mat4_identity;
mat4_mul_rotation(&m, &axis, angle, &m);
@@ -1563,7 +1563,7 @@ namespace mdl {
const vec3 up = { 0.0f, 1.0f, 0.0f };
vec3 axis;
float_t angle;
Glitter::axis_angle_from_vectors(axis, angle, up, dir);
vec3::axis_angle_from_vectors(axis, angle, up, dir);
mat4 m = mat4_identity;
mat4_mul_rotation(&m, &axis, angle, &m);