The reconstructed tree now produces a runnable binary with the authentic 1995 toolchain (BC4.52 / tlink32 / DPMI32): - BTL4.CPP main TU reconstructed from the 4.11 Ghidra decomp (FUN_0040109c) + the 4.10 binary's own string pool + surviving RPL4TOOL.CPP house style; probe_main.cpp scaffold retired (BTL4.NOTES.md documents every decoded call) - L4NET.CPP staged: L4NetworkManager ctor/dtor + 10 vtable-pulled virtuals (standalone-benign ones no-op, network ones Fail loudly) + NetNub client globals (Net_Common_Ptr=NULL routes L4File to its plain-DOS path) - build410.sh: libs now built in the AUTHENTIC makefile member order (MUNGA.MAK / mungal4.mak / BT.MAK / BTL4.MAK). Order is load-bearing: tlink emits static-init records in module pull order, and alphabetical order booted into a null-vptr crash (IcomManager::ClassDerivations constructing before parent NetworkClient::ClassDerivations). Also fixed stage_link to the proven 32-bit lib set (SOSDBXC+SOSMBXC, no WATTCPLG) - BOXTREE.HPP MemoryBlock unify, BTL4GRND notify stubs, remaining engine backfills (audio/gauge/resource/stream TUs) that closed the deep ledger Smoke test (DOSBox-X + 32RTM, copy of the pod BT tree, our exe swapped in): BattleTech v4.10 BTL4Application::BTL4Application l4net.cpp(22): L4NetworkManager -- l4net.cpp not yet reconstructed Static init, main, -egg parse, BTL4.RES load (version 1.0.6 check passes), ApplicationManager and the BTL4Application ctor chain all execute real reconstructed code; boot halts at the first staged Fail() as designed. Next brick: the real l4net.cpp body. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
177 lines
5.3 KiB
C++
177 lines
5.3 KiB
C++
# if !defined(MUNGA_HPP)
|
|
# include <munga.hpp>
|
|
# endif
|
|
#pragma hdrstop
|
|
|
|
# if !defined(RAY_HPP)
|
|
# include <ray.hpp>
|
|
# endif
|
|
# if !defined(PLANE_HPP)
|
|
# include <plane.hpp>
|
|
# endif
|
|
# if !defined(SPHERE_HPP)
|
|
# include <sphere.hpp>
|
|
# endif
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void Ray::Project(Scalar length, Point3D *result)
|
|
{
|
|
Check(this);
|
|
Check(result);
|
|
|
|
Vector3D temp;
|
|
|
|
temp.Multiply(direction,length);
|
|
result->Add(origin,temp);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Scalar Ray::LengthToClosestPointTo(const Point3D &point)
|
|
{
|
|
Check(this);
|
|
Check(&point);
|
|
|
|
Vector3D temp;
|
|
|
|
temp.Subtract(point,origin);
|
|
return temp*direction;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Scalar Ray::DistanceTo(const Plane &plane, Scalar *product) const
|
|
{
|
|
Scalar t;
|
|
|
|
//
|
|
//------------------------------------------------------------------
|
|
// Compute the dot product of the ray and plane normal, and find the
|
|
// distance from the origin of the ray to the plane
|
|
//------------------------------------------------------------------
|
|
//
|
|
*product = plane.normal * direction;
|
|
t = plane.DistanceTo(origin);
|
|
|
|
//
|
|
//----------------------------------------------------------------------
|
|
// If the ray is not parallel to the plane, determine how far to proceed
|
|
// along the ray until we hit the plane
|
|
//----------------------------------------------------------------------
|
|
//
|
|
if (!Small_Enough(*product))
|
|
t /= -*product;
|
|
return t;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Scalar Ray::DistanceTo(const Sphere &sphere, Scalar *penetration) const
|
|
{
|
|
Scalar b, c;
|
|
Vector3D temp;
|
|
|
|
//
|
|
//-------------------------------------------------------------------------
|
|
// Set up to solve a quadratic equation for the intersection of the ray and
|
|
// sphere. The solution is based on finding the closest point on the line
|
|
// to the sphere, and then calculating the interval between the entry and
|
|
// exit points of the ray
|
|
//-------------------------------------------------------------------------
|
|
//
|
|
temp.Subtract(origin,sphere.center);
|
|
b = 2.0f * (direction * temp);
|
|
c = temp.LengthSquared() - sphere.radius*sphere.radius;
|
|
|
|
//
|
|
//--------------------------------------------------------------------------
|
|
// Compute the squared interval to use for the solution. If it is negative,
|
|
// then the ray misses the sphere
|
|
//--------------------------------------------------------------------------
|
|
//
|
|
*penetration = b*b - 4.0f*c;
|
|
if (*penetration<SMALL)
|
|
return 0.0f;
|
|
else
|
|
{
|
|
//-------------------------------------------------------------------------
|
|
// Otherwise, find the linear distance along the line of the entry point by
|
|
// subtracting half the interval between entry and exit points from the
|
|
// distance to the closest point on the sphere
|
|
//-------------------------------------------------------------------------
|
|
*penetration = Sqrt(*penetration);
|
|
return -0.5f*(b+*penetration);
|
|
}
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical Ray::TestInstance() const
|
|
{
|
|
return True;
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Scalar Find_Closest_Approach(const Point3D& origin1, const Vector3D& velocity1, Point3D *result1, const Point3D& origin2, const Vector3D& velocity2, Point3D *result2, Scalar *time, Logical *constant)
|
|
{
|
|
Vector3D a,b;
|
|
a.Subtract(origin1, origin2);
|
|
b.Subtract(velocity1, velocity2);
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// If the velocities are identical, any point will do for the test, so
|
|
// simply return the difference between the starting points
|
|
//--------------------------------------------------------------------
|
|
//
|
|
Scalar d = b.LengthSquared();
|
|
if (Small_Enough(d))
|
|
{
|
|
*constant = True;
|
|
d = a.Length();
|
|
Check_Fpu();
|
|
return d;
|
|
}
|
|
|
|
//
|
|
//-------------------------------------------------------------------------
|
|
// The velocities are not parallel, so figure out when the closest approach
|
|
// is via the derivative
|
|
//-------------------------------------------------------------------------
|
|
//
|
|
*constant = False;
|
|
*time = (a * b) / -d;
|
|
Check_Fpu();
|
|
|
|
//
|
|
//------------------------------------------------------
|
|
// Now, plot the resultant points of both line equations
|
|
//------------------------------------------------------
|
|
//
|
|
Vector3D closest;
|
|
closest.AddScaled(a, b, *time);
|
|
result1->AddScaled(origin1, velocity1, *time);
|
|
result2->AddScaled(origin2, velocity2, *time);
|
|
d = closest.Length();
|
|
Check_Fpu();
|
|
return d;
|
|
}
|
|
|
|
#if defined(TEST_CLASS)
|
|
# include "ray.tcp"
|
|
#endif
|