Skip to content

Commit

Permalink
c_xyz closer
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Sep 10, 2023
1 parent 3831945 commit 3ec5a9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/JSystem/JUtility/JUTAssert.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
#define JUT_WARN(LINE, ...) \
JUTAssertion::setWarningMessage_f(JUTAssertion::getSDevice(), __FILE__, LINE, __VA_ARGS__); \

#define JUT_CONFIRM(LINE, COND) \
JUTAssertion::setConfirmMessage(JUTAssertion::getSDevice(), __FILE__, LINE, COND, #COND)

namespace JUTAssertion {
u32 getSDevice();
void showAssert(u32 device, const char * file, int line, const char * assertion);
void setWarningMessage_f(u32 device, char * file, int line, const char * fmt, ...);
void setConfirmMessage(u32 device, char * file, int line, bool cond, const char * msg);
void create();
u32 flush_subroutine();
void flushMessage();
Expand Down
20 changes: 16 additions & 4 deletions src/SSystem/SComponent/c_xyz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@

#include "SSystem/SComponent/c_xyz.h"
#include "SSystem/SComponent/c_math.h"
#include "dolphin/types.h"
#include "MSL_C/float.h"
#include "JSystem/JUtility/JUTAssert.h"

const cXyz cXyz::Zero(0, 0, 0);
const cXyz cXyz::BaseX(1, 0, 0);
const cXyz cXyz::BaseY(0, 1, 0);
const cXyz cXyz::BaseZ(0, 0, 1);
const cXyz cXyz::BaseXY(1, 1, 0);
const cXyz cXyz::BaseXZ(1, 0, 1);
const cXyz cXyz::BaseYZ(0, 1, 1);
const cXyz cXyz::BaseXYZ(1, 1, 1);

/* 80245674-802456C4 .text __pl__4cXyzCFRC3Vec */
cXyz cXyz::operator+(const Vec& vec) const {
Expand Down Expand Up @@ -63,6 +73,7 @@ cXyz cXyz::outprod(const Vec& vec) const {
/* 80245874-80245918 .text norm__4cXyzCFv */
cXyz cXyz::norm(void) const {
Vec ret;
JUT_CONFIRM(233, isNearZeroSquare() == 0);
VECNormalize(this, &ret);
return cXyz(ret);
}
Expand Down Expand Up @@ -102,6 +113,7 @@ cXyz cXyz::normZC(void) const {

/* 80245ADC-80245B80 .text normalize__4cXyzFv */
cXyz cXyz::normalize(void) {
JUT_ASSERT(267, isNearZeroSquare() == 0);
VECNormalize(this, this);
return *this;
}
Expand Down Expand Up @@ -138,7 +150,7 @@ bool cXyz::operator!=(const Vec& vec) const {

/* 80245CE4-80245D48 .text isZero__4cXyzCFv */
bool cXyz::isZero(void) const {
return fabsf(this->x) < 32.0f * FLT_EPSILON &&
fabsf(this->y) < 32.0f * FLT_EPSILON &&
fabsf(this->z) < 32.0f * FLT_EPSILON;
return fabsf(this->x) < 3.814697e-06 &&
fabsf(this->y) < 3.814697e-06 &&
fabsf(this->z) < 3.814697e-06;
}

0 comments on commit 3ec5a9e

Please sign in to comment.