- Field names from the 12340 type library (x/y/z/w, a0..d3, minY/minX/maxY/maxX, b/t, c/r, n/d, origin/dir) - Files renamed to match their class; CRay -> C3Ray; C3Segment, CRect, CiRect, C2iVector, C3iVector split out - MouseEventData, CharacterInfo, M2Bounds moved out of Tempest headers - 107 functions: C2/C3/C4Vector, C33/C34/C44Matrix, C4Quaternion, C4Plane, CAaBox, CAaSphere, C3Ray, CRect, CiRect, CImVector, NTempest - 0x4C1C40 is cdecl (q, out): ported as static C44Matrix::FromQuaternion (guessed) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
24 lines
752 B
C++
24 lines
752 B
C++
#include <cmath>
|
|
#include "Engine/Source/Tempest/C4Plane.h"
|
|
|
|
// VERIFY: 1c5486e7 manual
|
|
// OFFSET: 0x007912C0
|
|
void C4Plane::From3Pos(const C3Vector& p0, const C3Vector& p1, const C3Vector& p2) {
|
|
float ex = p2.x - p0.x;
|
|
float ey = p2.y - p0.y;
|
|
float ez = p2.z - p0.z;
|
|
float fx = p1.x - p0.x;
|
|
float fy = p1.y - p0.y;
|
|
float fz = p1.z - p0.z;
|
|
|
|
this->n.x = fy * ez - fz * ey;
|
|
this->n.y = fz * ex - ez * fx;
|
|
this->n.z = ey * fx - ex * fy;
|
|
|
|
float scale = 1.0f / sqrt(this->n.z * this->n.z + this->n.y * this->n.y + this->n.x * this->n.x);
|
|
this->n.x = this->n.x * scale;
|
|
this->n.y = this->n.y * scale;
|
|
this->n.z = scale * this->n.z;
|
|
this->d = -(this->n.z * p0.z + this->n.x * p0.x + this->n.y * p0.y);
|
|
}
|