Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions include/rwsdk/rwplcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,23 @@ struct rwGameCube2DVertex
RwRGBA emissiveColor;
RwReal u;
RwReal v;

rwGameCube2DVertex& operator=(const rwGameCube2DVertex& rhs)
{
this->x = rhs.x;
this->y = rhs.y;
this->z = rhs.z;

this->emissiveColor.red = rhs.emissiveColor.red;
this->emissiveColor.green = rhs.emissiveColor.green;
this->emissiveColor.blue = rhs.emissiveColor.blue;
this->emissiveColor.alpha = rhs.emissiveColor.alpha;

this->u = rhs.u;
this->v = rhs.v;

return *this;
}
};

typedef rwGameCube2DVertex RwIm2DVertex;
Expand Down
30 changes: 15 additions & 15 deletions src/SB/Core/x/xBound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ static void xBoundOBBIsectRay(const xBox* b, const xMat4x3* m, const xRay3* r, x
{
F32 len2 = SQR(m->right.x) + SQR(m->right.y) + SQR(m->right.z);

if ((F32)iabs(len2 - 1.0f) <= 0.0000099999997f)
if ((F32)iabs(len2 - 1.0f) <= 0.00001f)
{
// non-matching: incorrect instruction + order

scale.x = 1.0f;

mnormal.right.x = m->right.x;
mnormal.right.y = m->right.y;
mnormal.right.z = m->right.z;
mnormal.right.x = SQR(m->right.x);
mnormal.right.y = SQR(m->right.y);
mnormal.right.z = SQR(m->right.z);
}
else if ((F32)iabs(len2) <= 0.0000099999997f)
else if ((F32)iabs(len2) <= 0.00001f)
{
// non-matching: incorrect order

Expand All @@ -203,17 +203,17 @@ static void xBoundOBBIsectRay(const xBox* b, const xMat4x3* m, const xRay3* r, x
{
F32 len2 = SQR(m->up.x) + SQR(m->up.y) + SQR(m->up.z);

if ((F32)iabs(len2 - 1.0f) <= 0.0000099999997f)
if ((F32)iabs(len2 - 1.0f) <= 0.00001f)
{
// non-matching: incorrect instruction + order

scale.y = 1.0f;

mnormal.up.x = m->up.x;
mnormal.up.y = m->up.y;
mnormal.up.z = m->up.z;
mnormal.up.x = SQR(m->up.x);
mnormal.up.y = SQR(m->up.y);
mnormal.up.z = SQR(m->up.z);
}
else if ((F32)iabs(len2) <= 0.0000099999997f)
else if ((F32)iabs(len2) <= 0.00001f)
{
// non-matching: incorrect order

Expand All @@ -238,17 +238,17 @@ static void xBoundOBBIsectRay(const xBox* b, const xMat4x3* m, const xRay3* r, x
{
F32 len2 = SQR(m->at.x) + SQR(m->at.y) + SQR(m->at.z);

if ((F32)iabs(len2 - 1.0f) <= 0.0000099999997f)
if ((F32)iabs(len2 - 1.0f) <= 0.00001f)
{
// non-matching: incorrect instruction + order

scale.z = 1.0f;

mnormal.at.x = m->at.x;
mnormal.at.y = m->at.y;
mnormal.at.z = m->at.z;
mnormal.at.x = SQR(m->at.x);
mnormal.at.y = SQR(m->at.y);
mnormal.at.z = SQR(m->at.z);
}
else if ((F32)iabs(len2) <= 0.0000099999997f)
else if ((F32)iabs(len2) <= 0.00001f)
{
// non-matching: incorrect order

Expand Down
8 changes: 4 additions & 4 deletions src/SB/Core/x/xCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,11 +1240,11 @@ F32 xrmod(F32 ang)

xVec3& xVec3::operator/=(F32 f)
{
F32 f2 = 1.0f;
F32 f2 = 1.0f / f;

this->x *= f2 / f;
this->y *= f2 / f;
this->z *= f2 / f;
this->x *= f2;
this->y *= f2;
this->z *= f2;

return *this;
}
Expand Down
39 changes: 39 additions & 0 deletions src/SB/Core/x/xFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,45 @@ struct xtextbox

static callback text_cb;

xtextbox& operator=(const xtextbox& rhs)
{
this->font.id = rhs.font.id;

*(S32*)(&this->font.width) = *(S32*)(&rhs.font.width);
*(S32*)(&this->font.height) = *(S32*)(&rhs.font.height);
*(S32*)(&this->font.space) = *(S32*)(&rhs.font.space);

*(S32*)(&this->font.color) = *(S32*)(&rhs.font.color);

*(S32*)(&this->font.clip.x) = *(S32*)(&rhs.font.clip.x);
*(S32*)(&this->font.clip.y) = *(S32*)(&rhs.font.clip.y);
*(S32*)(&this->font.clip.w) = *(S32*)(&rhs.font.clip.w);
*(S32*)(&this->font.clip.h) = *(S32*)(&rhs.font.clip.h);

*(S32*)(&this->bounds.x) = *(S32*)(&rhs.bounds.x);
*(S32*)(&this->bounds.y) = *(S32*)(&rhs.bounds.y);
*(S32*)(&this->bounds.w) = *(S32*)(&rhs.bounds.w);
*(S32*)(&this->bounds.h) = *(S32*)(&rhs.bounds.h);

this->flags = rhs.flags;

this->line_space = rhs.line_space;
this->tab_stop = rhs.tab_stop;
this->left_indent = rhs.left_indent;
this->right_indent = rhs.right_indent;

this->cb = rhs.cb;
this->context = rhs.context;
this->texts = rhs.texts;
this->text_sizes = rhs.text_sizes;
this->texts_size = rhs.texts_size;
this->text.text = rhs.text.text;
this->text.size = rhs.text.size;
this->text_hash = rhs.text_hash;

return *this;
}

static void text_render(const jot& j, const xtextbox& tb, F32 x, F32 y);
static tag_entry_list read_tag(const substr& s);
static tag_entry* find_entry(const tag_entry_list& el, const substr& name);
Expand Down
36 changes: 20 additions & 16 deletions src/SB/Core/x/xMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ F32 xDangleClamp(F32 a)

void xAccelMove(F32& x, F32& v, F32 a, F32 dt, F32 endx, F32 maxv)
{
// Todo: These variable names aren't all right.
F32 var_f31;
F32 offset;
F32 t1;
F32 t2;
Expand All @@ -248,28 +250,27 @@ void xAccelMove(F32& x, F32& v, F32 a, F32 dt, F32 endx, F32 maxv)
F32 dx;

F32 temp_f1_2;
F32 temp_f28;
F32 temp_f29;
F32 var_f0;
F32 var_f2;
F32 var_f31;
S32 var_r0;
S32 var_r0_2;
S32 var_r0_3;
S32 var_r0_4;
S32 var_r3_2;
S32 var_r3_3;
S32 var_r0;
S32 var_r0_2;
S32 var_r0_3;
S32 var_r3;
S32 var_r3_4;
S32 var_r4;
S8 var_r3;
F32 var_f0;
F32 var_f2;
F32 temp_f29;
F32 temp_f28;

temp_f29 = endx - x;
var_r3 = 1;
var_r3 = 1; // Possible missing debug subroutine
if (!((F32)__fabs(v) < 0.001f))
{
if (v < 0.0f)
{
var_r4 = 1;
var_r4 = var_r3;
}
else
{
Expand All @@ -288,7 +289,7 @@ void xAccelMove(F32& x, F32& v, F32 a, F32 dt, F32 endx, F32 maxv)
var_r3 = 0;
}
}
if (var_r3 != 0)
if (var_r3 & 0xff)
{
var_f31 = 1e38f;
}
Expand All @@ -309,14 +310,14 @@ void xAccelMove(F32& x, F32& v, F32 a, F32 dt, F32 endx, F32 maxv)
oldv = v;
newv = oldv + dv;

if ((F32)__fabs(newv) == maxv)
if ((F32)__fabs(newv) <= maxv)
{
v = newv;
var_f0 = 0.5f * dv * dt;
}
else
{
if ((F32)__fabs(oldv) == maxv)
if ((F32)__fabs(oldv) <= maxv)
{
v = range_limit(newv, -maxv, maxv);
if (oldv != v)
Expand Down Expand Up @@ -527,11 +528,14 @@ void xAccelStop(F32& x, F32& v, F32 a, F32 dt)

void xFuncPiece_EndPoints(xFuncPiece* func, F32 pi, F32 pf, F32 fi, F32 ff)
{
F32 xfinv; // from DWARF data
F32 xfinv; // from DWARF data
F32 df; // not from DWARF data

func->end = pf - pi;
xfinv = (1.0f / func->end);
df = ff - fi;
func->order = 1;
func->coef[0] = fi;
func->coef[1] = (ff - fi) * (1.0f / func->end);
func->coef[1] = df * xfinv;
xFuncPiece_ShiftPiece(func, func, -pi);
}
92 changes: 33 additions & 59 deletions src/SB/Core/x/xMath3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,43 +94,33 @@ void xMat3x3Euler(xMat3x3* m, F32 yaw, F32 pitch, F32 roll)
/* xMat3x3RotC (xMat3x3 *, float, float, float, float) */
void xMat3x3RotC(xMat3x3* m, F32 _x, F32 _y, F32 _z, F32 t)
{
F32 temp_f0;
F32 temp_f0_2;
F32 temp_f1;
F32 temp_f28;
F32 temp_f2;
F32 temp_f3;
F32 temp_f4;
F32 temp_f5;
F32 temp_f6;
F32 temp_f7;
F32 temp_f8;
F32 sin;
F32 cos;
F32 c;

if (t == 0.0f)
{
xMat3x3Identity(m);
return;
}
temp_f28 = icos(t);
temp_f1 = isin(t);
temp_f5 = -temp_f1;
temp_f2 = 1.0f - temp_f28;
temp_f0 = temp_f2 * _x;
temp_f8 = temp_f2 * _z;
temp_f4 = temp_f2 * _y;
temp_f3 = _y * temp_f0;
temp_f6 = _x * temp_f8;
temp_f0_2 = (temp_f1 * _z) + temp_f3;
m->right.x = (_x * temp_f0) + temp_f28;
temp_f7 = _z * temp_f4;
m->right.y = temp_f0_2;
m->right.z = (temp_f5 * _y) + temp_f6;
m->up.x = (temp_f5 * _z) + temp_f3;
m->up.y = (_y * temp_f4) + temp_f28;
m->up.z = (temp_f1 * _x) + temp_f7;
m->at.x = (temp_f1 * _y) + temp_f6;
m->at.y = (temp_f5 * _x) + temp_f7;
m->at.z = (_z * temp_f8) + temp_f28;

cos = icos(t);
sin = isin(t);

c = 1.0f - cos;

m->right.x = (c * _x * _x) + cos;
m->right.y = (sin * _z) + (c * _x * _y);
m->right.z = (-sin * _y) + (c * _z * _x);

m->up.x = (-sin * _z) + (c * _x * _y);
m->up.y = (c * _y * _y) + cos;
m->up.z = (sin * _x) + (c * _y * _z);

m->at.x = (sin * _y) + (c * _z * _x);
m->at.y = (-sin * _x) + (c * _y * _z);
m->at.z = (c * _z * _z) + cos;

m->flags = 0;
}

Expand Down Expand Up @@ -180,35 +170,13 @@ void xMat3x3Normalize(xMat3x3* o, const xMat3x3* m)
/* xMat3x3Tolocal (xVec3 *, xMat3x3 const *, xVec3 const *) */
void xMat3x3Tolocal(xVec3* o, const xMat3x3* m, const xVec3* v)
{
F32 temp_f0;
F32 temp_f0_2;
F32 temp_f1;
F32 temp_f1_2;
F32 temp_f29;
F32 temp_f2;
F32 temp_f30;
F32 temp_f31;
F32 temp_f6;
F32 temp_f7;
F32 temp_f8;
F32 temp_f8_2;

temp_f1 = m->right.x;
temp_f0 = m->right.y;
temp_f2 = m->up.x;
temp_f1_2 = m->up.y;
temp_f8 = m->at.x;
temp_f0_2 = m->at.y;
temp_f6 = m->right.z;
temp_f7 = m->up.z;
temp_f8_2 = m->at.z;
temp_f31 = (temp_f6 * temp_f6) + ((temp_f1 * temp_f1) + (temp_f0 * temp_f0));
temp_f30 = (temp_f7 * temp_f7) + ((temp_f2 * temp_f2) + (temp_f1_2 * temp_f1_2));
temp_f29 = (temp_f8_2 * temp_f8_2) + ((temp_f8 * temp_f8) + (temp_f0_2 * temp_f0_2));
F32 sumRt = (m->right.x * m->right.x) + (m->right.y * m->right.y) + (m->right.z * m->right.z);
F32 sumUp = (m->up.x * m->up.x) + (m->up.y * m->up.y) + (m->up.z * m->up.z);
F32 sumAt = (m->at.x * m->at.x) + (m->at.y * m->at.y) + (m->at.z * m->at.z);
xMat3x3LMulVec(o, m, v);
o->x /= temp_f31;
o->y /= temp_f30;
o->z /= temp_f29;
o->x /= sumRt;
o->y /= sumUp;
o->z /= sumAt;
}

/* xMat4x3MoveLocalRight (xMat4x3 *, float) */
Expand Down Expand Up @@ -720,4 +688,10 @@ void xBoxUnion(xBox& a, const xBox& b, const xBox& c)

void xMat3x3LMulVec(xVec3* o, const xMat3x3* m, const xVec3* v)
{
F32 y = (m->up.x * v->x) + (m->up.y * v->y) + (m->up.z * v->z);
F32 z = (m->at.x * v->x) + (m->at.y * v->y) + (m->at.z * v->z);

o->x = (m->right.x * v->x) + (m->right.y * v->y) + (m->right.z * v->z);
o->y = y;
o->z = z;
}
Loading