address feedback

move vec.h to thirdparty folder
update vec.h
move all realtime code to realtime folder
move calclocaltransform out of legoutil and into realtime
cast shift to MxS32
add additional unroll hack to CalcLocalTransform to prevent msvc entropy
This commit is contained in:
Ramen2X 2023-10-24 08:10:05 -04:00
parent 1a87f89e8b
commit 346c8387f5
10 changed files with 317 additions and 125 deletions

View File

@ -3,7 +3,7 @@
* for any combination of C scalar types. * for any combination of C scalar types.
* *
* Author: Don Hatch (hatch@sgi.com) * Author: Don Hatch (hatch@sgi.com)
* Last modified: Fri Sep 30 03:23:02 PDT 1994 * Last modified: Fri Dec 15 01:57:07 PST 1995
* *
* General description: * General description:
* *
@ -35,7 +35,8 @@
* VXM2l(v,v,m) if v's scalar type is long * VXM2l(v,v,m) if v's scalar type is long
* VXM2r(v,v,m) if v's scalar type is real * VXM2r(v,v,m) if v's scalar type is real
* VXM2safe(type,v,v,m) for other scalar types. * VXM2safe(type,v,v,m) for other scalar types.
* These "safe" macros do not evaluate to C expressions *
* These "safe" macros and INVERTMAT do not evaluate to C expressions
* (so, for example, they can't be used inside the parentheses of * (so, for example, they can't be used inside the parentheses of
* a for(...)). * a for(...)).
* *
@ -43,6 +44,8 @@
* *
* The "?"'s in the following can be 2, 3, or 4. * The "?"'s in the following can be 2, 3, or 4.
* *
* EXPAND?(v) comma-separated list of elements of v
*
* SET?(to,from) to = from * SET?(to,from) to = from
* SETMAT?(to,from) to = from * SETMAT?(to,from) to = from
* ROUNDVEC?(to,from) to = from with entries rounded * ROUNDVEC?(to,from) to = from with entries rounded
@ -60,15 +63,26 @@
* TRANSPOSE?(to,from) (matrix to) = (transpose of matrix from) * TRANSPOSE?(to,from) (matrix to) = (transpose of matrix from)
* ADJOINT?(to,from) (matrix to) = (adjoint of matrix from) * ADJOINT?(to,from) (matrix to) = (adjoint of matrix from)
* i.e. its determinant times its inverse * i.e. its determinant times its inverse
* INVERTMAT?{d,i,l,r}(to,from) (matrix to) = (inverse of matrix from)
* with temp adjoint and determinant type
* double, int, long, or real respectively
* *
* V{P,M}V?(to,v,w) to = v {+,-} w * V{P,M}V?(to,v,w) to = v {+,-} w
* M{P,M}M?(to,m1,m2) to = m1 {+,-} m2 * M{P,M}M?(to,m1,m2) to = m1 {+,-} m2
* SX{V,M}?(to,s,from) to = s * from * SX{V,M}?(to,s,from) to = s * from
* VPSXV?(to,v,s,w) to = v + s*w
* VPVXS?(to,v,w,s) to = v + w*s
* M{V,M}?(to,from) to = -from * M{V,M}?(to,from) to = -from
* {V,M}{X,D}S?(to,from,s) to = from {*,/} s * {V,M}{X,D}S?(to,from,s) to = from {*,/} s
* MXM?(to,m1,m2) to = m1 * m2 * MXM?(to,m1,m2) to = m1 * m2
* VXM?(to,v,m) (row vec to) = (row vec v) * m * VXM?(to,v,m) (row vec to) = (row vec v) * m
* MXV?(to,m,v) (column vec to) = m * (column vec v) * MXV?(to,m,v) (column vec to) = m * (column vec v)
* VMODS?(to,v,s) to = v mod s (always >= 0)
* VMODV?(to,v0,v1) to = v0 mod v1 componentwise
* VDIVS?(to,v,s) to = (v-(v mod s))/s
* VDIVV?(to,v0,v1) to = (v0-(v0 mod v1))/v1 componentwise
* V{MIN,MAX}S?(to,v,s) to = {MIN,MAX}(v, s)
* V{MIN,MAX}V?(to,v0,v1) to = {MIN,MAX}(v0, v1)
* LERP?(to,v0,v1,t) to = v0 + t*(v1-v0) * LERP?(to,v0,v1,t) to = v0 + t*(v1-v0)
* *
* DET?(m) determinant of m * DET?(m) determinant of m
@ -117,6 +131,9 @@
#ifndef VEC_H #ifndef VEC_H
#define VEC_H 4 #define VEC_H 4
#include <math.h> /* for definition of floor() */ #include <math.h> /* for definition of floor() */
#define EXPAND2(v) (v)[0], (v)[1]
#define EXPAND3(v) (v)[0], (v)[1], (v)[2]
#define EXPAND4(v) (v)[0], (v)[1], (v)[2], (v)[3]
#define SET2(to,from) \ #define SET2(to,from) \
((to)[0] = (from)[0], \ ((to)[0] = (from)[0], \
(to)[1] = (from)[1]) (to)[1] = (from)[1])
@ -156,6 +173,12 @@
#define TRANSPOSE2(to,from) \ #define TRANSPOSE2(to,from) \
(_SETcol2((to)[0], from, 0), \ (_SETcol2((to)[0], from, 0), \
_SETcol2((to)[1], from, 1)) _SETcol2((to)[1], from, 1))
#define VPSXV2(to,v,s,w) \
((to)[0] = (v)[0] + (s) * (w)[0], \
(to)[1] = (v)[1] + (s) * (w)[1])
#define VPVXS2(to,v,w,s) \
((to)[0] = (v)[0] + (w)[0] * (s), \
(to)[1] = (v)[1] + (w)[1] * (s))
#define VPV2(to,v,w) \ #define VPV2(to,v,w) \
((to)[0] = (v)[0] + (w)[0], \ ((to)[0] = (v)[0] + (w)[0], \
(to)[1] = (v)[1] + (w)[1]) (to)[1] = (v)[1] + (w)[1])
@ -201,6 +224,30 @@
#define MXV2(to,m,v) \ #define MXV2(to,m,v) \
((to)[0] = DOT2((m)[0], v), \ ((to)[0] = DOT2((m)[0], v), \
(to)[1] = DOT2((m)[1], v)) (to)[1] = DOT2((m)[1], v))
#define VMODS2(to,v,s) \
((to)[0] = SMODS1((v)[0], s), \
(to)[1] = SMODS1((v)[1], s))
#define VMODV2(to,v0,v1) \
((to)[0] = SMODS1((v0)[0], (v1)[0]), \
(to)[1] = SMODS1((v0)[1], (v1)[1]))
#define VDIVS2(to,v,s) \
((to)[0] = SDIVS1((v)[0], s), \
(to)[1] = SDIVS1((v)[1], s))
#define VDIVV2(to,v0,v1) \
((to)[0] = SDIVS1((v0)[0], (v1)[0]), \
(to)[1] = SDIVS1((v0)[1], (v1)[1]))
#define VMINS2(to,v,s) \
((to)[0] = SMINS1((v)[0], s), \
(to)[1] = SMINS1((v)[1], s))
#define VMINV2(to,v0,v1) \
((to)[0] = SMINS1((v0)[0], (v1)[0]), \
(to)[1] = SMINS1((v0)[1], (v1)[1]))
#define VMAXS2(to,v,s) \
((to)[0] = SMAXS1((v)[0], s), \
(to)[1] = SMAXS1((v)[1], s))
#define VMAXV2(to,v0,v1) \
((to)[0] = SMAXS1((v0)[0], (v1)[0]), \
(to)[1] = SMAXS1((v0)[1], (v1)[1]))
#define LERP2(to,v0,v1,t) \ #define LERP2(to,v0,v1,t) \
((to)[0]=(v0)[0]+(t)*((v1)[0]-(v0)[0]), \ ((to)[0]=(v0)[0]+(t)*((v1)[0]-(v0)[0]), \
(to)[1]=(v0)[1]+(t)*((v1)[1]-(v0)[1])) (to)[1]=(v0)[1]+(t)*((v1)[1]-(v0)[1]))
@ -243,6 +290,14 @@
(_DET2(v0,v1,0,1)) (_DET2(v0,v1,0,1))
#define DET2(m) \ #define DET2(m) \
(VXV2((m)[0],(m)[1])) (VXV2((m)[0],(m)[1]))
#define SMODS1(a,b) \
((((a)%(b)+(b))%(b)))
#define SDIVS1(a,b) \
((((a)-SMODS1(a,b))/(b)))
#define SMINS1(a,b) \
(((a) < (b) ? (a) : (b)))
#define SMAXS1(a,b) \
(((a) > (b) ? (a) : (b)))
#define ADJOINT2(to,m) \ #define ADJOINT2(to,m) \
( _ADJOINTcol2(to,0,m,1), \ ( _ADJOINTcol2(to,0,m,1), \
__ADJOINTcol2(to,1,m,0)) __ADJOINTcol2(to,1,m,0))
@ -304,6 +359,14 @@
(_SETcol3((to)[0], from, 0), \ (_SETcol3((to)[0], from, 0), \
_SETcol3((to)[1], from, 1), \ _SETcol3((to)[1], from, 1), \
_SETcol3((to)[2], from, 2)) _SETcol3((to)[2], from, 2))
#define VPSXV3(to,v,s,w) \
((to)[0] = (v)[0] + (s) * (w)[0], \
(to)[1] = (v)[1] + (s) * (w)[1], \
(to)[2] = (v)[2] + (s) * (w)[2])
#define VPVXS3(to,v,w,s) \
((to)[0] = (v)[0] + (w)[0] * (s), \
(to)[1] = (v)[1] + (w)[1] * (s), \
(to)[2] = (v)[2] + (w)[2] * (s))
#define VPV3(to,v,w) \ #define VPV3(to,v,w) \
((to)[0] = (v)[0] + (w)[0], \ ((to)[0] = (v)[0] + (w)[0], \
(to)[1] = (v)[1] + (w)[1], \ (to)[1] = (v)[1] + (w)[1], \
@ -364,6 +427,38 @@
((to)[0] = DOT3((m)[0], v), \ ((to)[0] = DOT3((m)[0], v), \
(to)[1] = DOT3((m)[1], v), \ (to)[1] = DOT3((m)[1], v), \
(to)[2] = DOT3((m)[2], v)) (to)[2] = DOT3((m)[2], v))
#define VMODS3(to,v,s) \
((to)[0] = SMODS1((v)[0], s), \
(to)[1] = SMODS1((v)[1], s), \
(to)[2] = SMODS1((v)[2], s))
#define VMODV3(to,v0,v1) \
((to)[0] = SMODS1((v0)[0], (v1)[0]), \
(to)[1] = SMODS1((v0)[1], (v1)[1]), \
(to)[2] = SMODS1((v0)[2], (v1)[2]))
#define VDIVS3(to,v,s) \
((to)[0] = SDIVS1((v)[0], s), \
(to)[1] = SDIVS1((v)[1], s), \
(to)[2] = SDIVS1((v)[2], s))
#define VDIVV3(to,v0,v1) \
((to)[0] = SDIVS1((v0)[0], (v1)[0]), \
(to)[1] = SDIVS1((v0)[1], (v1)[1]), \
(to)[2] = SDIVS1((v0)[2], (v1)[2]))
#define VMINS3(to,v,s) \
((to)[0] = SMINS1((v)[0], s), \
(to)[1] = SMINS1((v)[1], s), \
(to)[2] = SMINS1((v)[2], s))
#define VMINV3(to,v0,v1) \
((to)[0] = SMINS1((v0)[0], (v1)[0]), \
(to)[1] = SMINS1((v0)[1], (v1)[1]), \
(to)[2] = SMINS1((v0)[2], (v1)[2]))
#define VMAXS3(to,v,s) \
((to)[0] = SMAXS1((v)[0], s), \
(to)[1] = SMAXS1((v)[1], s), \
(to)[2] = SMAXS1((v)[2], s))
#define VMAXV3(to,v0,v1) \
((to)[0] = SMAXS1((v0)[0], (v1)[0]), \
(to)[1] = SMAXS1((v0)[1], (v1)[1]), \
(to)[2] = SMAXS1((v0)[2], (v1)[2]))
#define LERP3(to,v0,v1,t) \ #define LERP3(to,v0,v1,t) \
((to)[0]=(v0)[0]+(t)*((v1)[0]-(v0)[0]), \ ((to)[0]=(v0)[0]+(t)*((v1)[0]-(v0)[0]), \
(to)[1]=(v0)[1]+(t)*((v1)[1]-(v0)[1]), \ (to)[1]=(v0)[1]+(t)*((v1)[1]-(v0)[1]), \
@ -509,6 +604,16 @@
_SETcol4((to)[1], from, 1), \ _SETcol4((to)[1], from, 1), \
_SETcol4((to)[2], from, 2), \ _SETcol4((to)[2], from, 2), \
_SETcol4((to)[3], from, 3)) _SETcol4((to)[3], from, 3))
#define VPSXV4(to,v,s,w) \
((to)[0] = (v)[0] + (s) * (w)[0], \
(to)[1] = (v)[1] + (s) * (w)[1], \
(to)[2] = (v)[2] + (s) * (w)[2], \
(to)[3] = (v)[3] + (s) * (w)[3])
#define VPVXS4(to,v,w,s) \
((to)[0] = (v)[0] + (w)[0] * (s), \
(to)[1] = (v)[1] + (w)[1] * (s), \
(to)[2] = (v)[2] + (w)[2] * (s), \
(to)[3] = (v)[3] + (w)[3] * (s))
#define VPV4(to,v,w) \ #define VPV4(to,v,w) \
((to)[0] = (v)[0] + (w)[0], \ ((to)[0] = (v)[0] + (w)[0], \
(to)[1] = (v)[1] + (w)[1], \ (to)[1] = (v)[1] + (w)[1], \
@ -584,6 +689,46 @@
(to)[1] = DOT4((m)[1], v), \ (to)[1] = DOT4((m)[1], v), \
(to)[2] = DOT4((m)[2], v), \ (to)[2] = DOT4((m)[2], v), \
(to)[3] = DOT4((m)[3], v)) (to)[3] = DOT4((m)[3], v))
#define VMODS4(to,v,s) \
((to)[0] = SMODS1((v)[0], s), \
(to)[1] = SMODS1((v)[1], s), \
(to)[2] = SMODS1((v)[2], s), \
(to)[3] = SMODS1((v)[3], s))
#define VMODV4(to,v0,v1) \
((to)[0] = SMODS1((v0)[0], (v1)[0]), \
(to)[1] = SMODS1((v0)[1], (v1)[1]), \
(to)[2] = SMODS1((v0)[2], (v1)[2]), \
(to)[3] = SMODS1((v0)[3], (v1)[3]))
#define VDIVS4(to,v,s) \
((to)[0] = SDIVS1((v)[0], s), \
(to)[1] = SDIVS1((v)[1], s), \
(to)[2] = SDIVS1((v)[2], s), \
(to)[3] = SDIVS1((v)[3], s))
#define VDIVV4(to,v0,v1) \
((to)[0] = SDIVS1((v0)[0], (v1)[0]), \
(to)[1] = SDIVS1((v0)[1], (v1)[1]), \
(to)[2] = SDIVS1((v0)[2], (v1)[2]), \
(to)[3] = SDIVS1((v0)[3], (v1)[3]))
#define VMINS4(to,v,s) \
((to)[0] = SMINS1((v)[0], s), \
(to)[1] = SMINS1((v)[1], s), \
(to)[2] = SMINS1((v)[2], s), \
(to)[3] = SMINS1((v)[3], s))
#define VMINV4(to,v0,v1) \
((to)[0] = SMINS1((v0)[0], (v1)[0]), \
(to)[1] = SMINS1((v0)[1], (v1)[1]), \
(to)[2] = SMINS1((v0)[2], (v1)[2]), \
(to)[3] = SMINS1((v0)[3], (v1)[3]))
#define VMAXS4(to,v,s) \
((to)[0] = SMAXS1((v)[0], s), \
(to)[1] = SMAXS1((v)[1], s), \
(to)[2] = SMAXS1((v)[2], s), \
(to)[3] = SMAXS1((v)[3], s))
#define VMAXV4(to,v0,v1) \
((to)[0] = SMAXS1((v0)[0], (v1)[0]), \
(to)[1] = SMAXS1((v0)[1], (v1)[1]), \
(to)[2] = SMAXS1((v0)[2], (v1)[2]), \
(to)[3] = SMAXS1((v0)[3], (v1)[3]))
#define LERP4(to,v0,v1,t) \ #define LERP4(to,v0,v1,t) \
((to)[0]=(v0)[0]+(t)*((v1)[0]-(v0)[0]), \ ((to)[0]=(v0)[0]+(t)*((v1)[0]-(v0)[0]), \
(to)[1]=(v0)[1]+(t)*((v1)[1]-(v0)[1]), \ (to)[1]=(v0)[1]+(t)*((v1)[1]-(v0)[1]), \
@ -745,6 +890,16 @@
#define ADJOINT2i(to,m) ADJOINT2safe(int,to,m) #define ADJOINT2i(to,m) ADJOINT2safe(int,to,m)
#define ADJOINT2l(to,m) ADJOINT2safe(long,to,m) #define ADJOINT2l(to,m) ADJOINT2safe(long,to,m)
#define ADJOINT2r(to,m) ADJOINT2safe(real,to,m) #define ADJOINT2r(to,m) ADJOINT2safe(real,to,m)
#define INVERTMAT2safe(type,to,from) \
do {type _vec_h_temp_[2][2]; \
ADJOINT2(_vec_h_temp_, from); \
type _vec_h_temp_invdet_ = (type)1/(type)DET2(from); \
SXM2(to, _vec_h_temp_invdet_, _vec_h_temp_); \
} while (0)
#define INVERTMAT2d(to,from) INVERTMAT2safe(double,to,from)
#define INVERTMAT2i(to,from) INVERTMAT2safe(int,to,from)
#define INVERTMAT2l(to,from) INVERTMAT2safe(long,to,from)
#define INVERTMAT2r(to,from) INVERTMAT2safe(real,to,from)
#define TRANSPOSE3safe(type,to,from) \ #define TRANSPOSE3safe(type,to,from) \
do {type _vec_h_temp_[3][3]; \ do {type _vec_h_temp_[3][3]; \
TRANSPOSE3(_vec_h_temp_,from); \ TRANSPOSE3(_vec_h_temp_,from); \
@ -835,6 +990,16 @@
#define ADJOINT3i(to,m) ADJOINT3safe(int,to,m) #define ADJOINT3i(to,m) ADJOINT3safe(int,to,m)
#define ADJOINT3l(to,m) ADJOINT3safe(long,to,m) #define ADJOINT3l(to,m) ADJOINT3safe(long,to,m)
#define ADJOINT3r(to,m) ADJOINT3safe(real,to,m) #define ADJOINT3r(to,m) ADJOINT3safe(real,to,m)
#define INVERTMAT3safe(type,to,from) \
do {type _vec_h_temp_[3][3]; \
ADJOINT3(_vec_h_temp_, from); \
type _vec_h_temp_invdet_ = (type)1/(type)DET3(from); \
SXM3(to, _vec_h_temp_invdet_, _vec_h_temp_); \
} while (0)
#define INVERTMAT3d(to,from) INVERTMAT3safe(double,to,from)
#define INVERTMAT3i(to,from) INVERTMAT3safe(int,to,from)
#define INVERTMAT3l(to,from) INVERTMAT3safe(long,to,from)
#define INVERTMAT3r(to,from) INVERTMAT3safe(real,to,from)
#define TRANSPOSE4safe(type,to,from) \ #define TRANSPOSE4safe(type,to,from) \
do {type _vec_h_temp_[4][4]; \ do {type _vec_h_temp_[4][4]; \
TRANSPOSE4(_vec_h_temp_,from); \ TRANSPOSE4(_vec_h_temp_,from); \
@ -907,4 +1072,14 @@
#define ADJOINT4i(to,m) ADJOINT4safe(int,to,m) #define ADJOINT4i(to,m) ADJOINT4safe(int,to,m)
#define ADJOINT4l(to,m) ADJOINT4safe(long,to,m) #define ADJOINT4l(to,m) ADJOINT4safe(long,to,m)
#define ADJOINT4r(to,m) ADJOINT4safe(real,to,m) #define ADJOINT4r(to,m) ADJOINT4safe(real,to,m)
#define INVERTMAT4safe(type,to,from) \
do {type _vec_h_temp_[4][4]; \
ADJOINT4(_vec_h_temp_, from); \
type _vec_h_temp_invdet_ = (type)1/(type)DET4(from); \
SXM4(to, _vec_h_temp_invdet_, _vec_h_temp_); \
} while (0)
#define INVERTMAT4d(to,from) INVERTMAT4safe(double,to,from)
#define INVERTMAT4i(to,from) INVERTMAT4safe(int,to,from)
#define INVERTMAT4l(to,from) INVERTMAT4safe(long,to,from)
#define INVERTMAT4r(to,from) INVERTMAT4safe(real,to,from)
#endif /* VEC_H */ #endif /* VEC_H */

View File

@ -199,7 +199,8 @@ add_library(lego1 SHARED
LEGO1/racestate.cpp LEGO1/racestate.cpp
LEGO1/radio.cpp LEGO1/radio.cpp
LEGO1/radiostate.cpp LEGO1/radiostate.cpp
LEGO1/realtimeview.cpp LEGO1/realtime/realtime.cpp
LEGO1/realtime/realtimeview.cpp
LEGO1/registrationbook.cpp LEGO1/registrationbook.cpp
LEGO1/score.cpp LEGO1/score.cpp
LEGO1/scorestate.cpp LEGO1/scorestate.cpp
@ -209,6 +210,9 @@ add_library(lego1 SHARED
LEGO1/viewmanager.cpp LEGO1/viewmanager.cpp
) )
# Additional include directories for both targets
include_directories("${CMAKE_SOURCE_DIR}/3rdparty/vec")
if (ISLE_USE_SMARTHEAP) if (ISLE_USE_SMARTHEAP)
add_library(SmartHeap::SmartHeap STATIC IMPORTED) add_library(SmartHeap::SmartHeap STATIC IMPORTED)
set_target_properties(SmartHeap::SmartHeap PROPERTIES set_target_properties(SmartHeap::SmartHeap PROPERTIES

View File

@ -33,40 +33,6 @@ ExtraActionType MatchActionString(const char *p_str) {
return result; return result;
} }
// OFFSET: LEGO1 0x100a5b40
void CalcLocalTransform(const MxVector3 &p_posVec, const MxVector3 &p_dirVec,
const MxVector3 &p_upVec, MxMatrix &p_outMatrix)
{
MxFloat x_axis[3], y_axis[3], z_axis[3];
NORMVEC3(z_axis, p_dirVec)
NORMVEC3(y_axis, p_upVec)
VXV3(x_axis, y_axis, z_axis);
// This is an unrolled version of the "NORMVEC3" macro,
// used here to apply a silly hack to get a 100% match
{
const MxFloat axis2Operation = (x_axis)[2] * (x_axis)[2];
MxDouble len = sqrt(((x_axis)[0] * (x_axis)[0] + axis2Operation + (x_axis)[1] * (x_axis)[1]));
((x_axis)[0] = (x_axis)[0] / (len), (x_axis)[1] = (x_axis)[1] / (len), (x_axis)[2] = (x_axis)[2] / (len));
}
VXV3(y_axis, z_axis, x_axis);
// Exact same thing as pointed out by the above comment
{
const MxFloat axis2Operation = (y_axis)[2] * (y_axis)[2];
MxDouble len = sqrt(((y_axis)[0] * (y_axis)[0] + axis2Operation + (y_axis)[1] * (y_axis)[1]));
((y_axis)[0] = (y_axis)[0] / (len), (y_axis)[1] = (y_axis)[1] / (len), (y_axis)[2] = (y_axis)[2] / (len));
}
SET4from3(&p_outMatrix[0], x_axis, 0);
SET4from3(&p_outMatrix[4], y_axis, 0);
SET4from3(&p_outMatrix[8], z_axis, 0);
SET4from3(&p_outMatrix[12], p_posVec, 1);
}
// OFFSET: LEGO1 0x1003eae0 // OFFSET: LEGO1 0x1003eae0
void ConvertHSVToRGB(float h, float s, float v, float *r_out, float *b_out, float *g_out) void ConvertHSVToRGB(float h, float s, float v, float *r_out, float *b_out, float *g_out)
{ {

View File

@ -4,11 +4,6 @@
#include <windows.h> #include <windows.h>
#include "extra.h" #include "extra.h"
#include "mxmatrix.h"
#define NORMVEC3(dst, src) { \
MxDouble len = sqrt(NORMSQRD3(src)); \
VDS3(dst, src, len); }
template <class T> template <class T>
inline T Abs(T p_t) inline T Abs(T p_t)
@ -60,7 +55,5 @@ inline void GetString(char **p_source, const char *&p_dest, T *p_obj, void (T::*
ExtraActionType MatchActionString(const char *); ExtraActionType MatchActionString(const char *);
void ConvertHSVToRGB(float r, float g, float b, float* out_r, float* out_g, float* out_b); void ConvertHSVToRGB(float r, float g, float b, float* out_r, float* out_g, float* out_b);
void SetAppCursor(WPARAM p_wparam); void SetAppCursor(WPARAM p_wparam);
void CalcLocalTransform(const MxVector3 &p_posVec, const MxVector3 &p_dirVec,
const MxVector3 &p_upVec, MxMatrix &p_outMatrix);
#endif // LEGOUTIL_H #endif // LEGOUTIL_H

View File

@ -2,7 +2,7 @@
#define MXVECTOR_H #define MXVECTOR_H
#include "mxtypes.h" #include "mxtypes.h"
#include "vec.h" #include <vec.h>
// VTABLE 0x100d4288 // VTABLE 0x100d4288
// SIZE 0x8 // SIZE 0x8

View File

@ -135,8 +135,8 @@ MxVideoPresenter::AlphaMask::AlphaMask(const MxBitmap &p_bitmap)
for (MxS32 i = 0; i < m_width; i++) { for (MxS32 i = 0; i < m_width; i++) {
if (*t_ptr) { if (*t_ptr) {
// TODO: Second CDQ instruction for abs() should not be there. // TODO: Second CDQ instruction for abs() should not be there.
MxS32 shift = abs(offset) & 7; MxU32 shift = abs(offset) & 7;
m_bitmask[offset / 8] |= (1 << abs(shift)); m_bitmask[offset / 8] |= (1 << abs((MxS32)shift));
} }
t_ptr++; t_ptr++;
offset++; offset++;

View File

@ -0,0 +1,41 @@
#include "realtime.h"
// OFFSET: LEGO1 0x100a5b40
void CalcLocalTransform(const MxVector3 &p_posVec, const MxVector3 &p_dirVec,
const MxVector3 &p_upVec, MxMatrix &p_outMatrix)
{
MxFloat x_axis[3], y_axis[3], z_axis[3];
// This is an unrolled version of the "NORMVEC3" macro,
// used here to apply a silly hack to get a 100% match
{
const MxFloat dirVec1Operation = (p_dirVec)[1] * (p_dirVec)[1];
MxDouble len = sqrt(((p_dirVec)[0] * (p_dirVec)[0] + dirVec1Operation + (p_dirVec)[2] * (p_dirVec)[2]));
((z_axis)[0] = (p_dirVec)[0] / (len), (z_axis)[1] = (p_dirVec)[1] / (len), (z_axis)[2] = (p_dirVec)[2] / (len));
}
NORMVEC3(y_axis, p_upVec)
VXV3(x_axis, y_axis, z_axis);
// Exact same thing as pointed out by the above comment
{
const MxFloat axis2Operation = (x_axis)[2] * (x_axis)[2];
MxDouble len = sqrt(((x_axis)[0] * (x_axis)[0] + axis2Operation + (x_axis)[1] * (x_axis)[1]));
((x_axis)[0] = (x_axis)[0] / (len), (x_axis)[1] = (x_axis)[1] / (len), (x_axis)[2] = (x_axis)[2] / (len));
}
VXV3(y_axis, z_axis, x_axis);
// Again, the same thing
{
const MxFloat axis2Operation = (y_axis)[2] * (y_axis)[2];
MxDouble len = sqrt(((y_axis)[0] * (y_axis)[0] + axis2Operation + (y_axis)[1] * (y_axis)[1]));
((y_axis)[0] = (y_axis)[0] / (len), (y_axis)[1] = (y_axis)[1] / (len), (y_axis)[2] = (y_axis)[2] / (len));
}
SET4from3(&p_outMatrix[0], x_axis, 0);
SET4from3(&p_outMatrix[4], y_axis, 0);
SET4from3(&p_outMatrix[8], z_axis, 0);
SET4from3(&p_outMatrix[12], p_posVec, 1);
}

13
LEGO1/realtime/realtime.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef REALTIME_H
#define REALTIME_H
#include "../mxmatrix.h"
#define NORMVEC3(dst, src) { \
MxDouble len = sqrt(NORMSQRD3(src)); \
VDS3(dst, src, len); }
void CalcLocalTransform(const MxVector3 &p_posVec, const MxVector3 &p_dirVec,
const MxVector3 &p_upVec, MxMatrix &p_outMatrix);
#endif // REALTIME_H