Files
SpaghettiKart/src/engine/editor/EditorMath.h
T
MegaMech 1dee7001f6 Updates
2025-03-21 20:38:02 -06:00

49 lines
1.3 KiB
C++

#pragma once
#include <libultraship.h>
#include <libultra/gbi.h>
#include <libultra/types.h>
#include "../CoreMath.h"
#include <vector>
#include "GameObject.h"
extern "C" {
#include "common_structs.h"
}
extern std::vector<Mtx> EditorMatrix;
struct Ray {
FVector Origin;
FVector Direction;
};
struct Triangle {
FVector v0, v1, v2;
};
/**
* Projects 2D cursor into the game world
*
* @return FVector ray direction
*
* ray.x = camera->pos[0] + direction.x * length;
* ray.y = camera->pos[1] + direction.y * length;
* ray.z = camera->pos[2] + direction.z * length;
*/
bool IsInGameScreen();
FVector ScreenRayTrace();
bool QueryCollisionRayActor(Vec3f rayOrigin, Vec3f rayDir, Vec3f actorMin, Vec3f actorMax, float* t);
FVector4 MultiplyMatrixVector(float matrix[4][4], float vector[4]);
s32 Inverse(MtxF* src, MtxF* dest);
void Copy(MtxF* src, MtxF* dest);
void Clear(MtxF* mf);
bool IntersectRayTriangle(const Ray& ray, const Triangle& tri, const FVector& objectPos, float& t);
bool IntersectRaySphere(const Ray& ray, const FVector& sphereCenter, float radius, float& t);
void Editor_AddMatrix(Mat4 mtx, int32_t flags);
float CalculateAngle(const FVector& start, const FVector& end);
void SetDirectionFromRotator(s16 rotator[3], s8 direction[3]);
FVector GetPositionAheadOfCamera(f32 dist);