Files
Cyd 2b8ca921cb Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS
Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
2026-06-24 21:28:16 -05:00

182 lines
4.6 KiB
C++

#include "ProxyHeaders.hpp"
//
//############################################################################
//######################## ChildProxy ###########################
//############################################################################
//
ChildProxy::ClassData*
ChildProxy::DefaultData = NULL;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
ChildProxy::InitializeClass()
{
Verify(!DefaultData);
DefaultData =
new ClassData(
ChildProxyClassID,
"ChildProxy",
GenericProxy::DefaultData
);
Register_Object(DefaultData);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
ChildProxy::TerminateClass()
{
Unregister_Object(DefaultData);
delete DefaultData;
DefaultData = NULL;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
ChildProxy::ChildProxy(
ClassData *data,
SceneProxy *scene,
GroupProxy *parent
):
GenericProxy(data),
sceneProxy(scene),
parentProxy(parent)
{
Check_Pointer(this);
//
//-----------------------------------------------------------------------
// If we have a parent proxy, bump its reference count and add ourself to
// its active list. If no parent, add to the scene list
//-----------------------------------------------------------------------
//
Check_Object(sceneProxy);
if (parentProxy)
{
sceneProxy->AttachReference();
Check_Object(parentProxy);
parentProxy->AttachChildProxy(this);
}
else
sceneProxy->AttachChildProxy(this);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
ChildProxy::~ChildProxy()
{
Check_Object(this);
//
//-----------------------------------------------------------------------
// If we have a parent proxy, bump its reference count and add ourself to
// its active list. If no parent, add to the scene list
//-----------------------------------------------------------------------
//
Check_Object(sceneProxy);
if (parentProxy)
{
Check_Object(parentProxy);
parentProxy->DetachChildProxy(this);
sceneProxy->DetachReference();
}
else
sceneProxy->DetachChildProxy(this);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
ChildProxy::TestInstance() const
{
Verify(IsDerivedFrom(DefaultData));
Check_Object(sceneProxy);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
ChildProxy::GetLocalToWorld(LinearMatrix4D *matrix)
{
Check_Object(this);
Check_Pointer(matrix);
//
//------------------------------------------------------------------
// If we don't have a parent, just return our local to parent matrix
//------------------------------------------------------------------
//
GroupProxy *parent = GetParentGroupProxy();
if (!parent)
{
GetLocalToParent(matrix);
return;
}
//
//------------------------------------------------------------------------
// If we have the identity matrix, just return our parent's local to world
//------------------------------------------------------------------------
//
Check_Object(parent);
LinearMatrix4D local_to_parent;
if (!GetLocalToParent(&local_to_parent))
{
parent->GetLocalToWorld(matrix);
return;
}
//
//----------------------------------
// Concatenate and return the matrix
//----------------------------------
//
LinearMatrix4D parent_to_world;
parent->GetLocalToWorld(&parent_to_world);
Check_Object(&parent_to_world);
matrix->Multiply(local_to_parent, parent_to_world);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
ChildProxy::TransformLocalToParent(const LinearMatrix4D &matrix)
{
Check_Object(this);
Check_Object(&matrix);
//
//---------------------------
// Ignore identity transforms
//---------------------------
//
if (matrix == LinearMatrix4D::Identity)
return;
//
//--------------------------------------------------------------------
// Get our old matrix, and if it was identity, replace it with the new
// matrix
//--------------------------------------------------------------------
//
LinearMatrix4D old;
if (!GetLocalToParent(&old))
{
SetLocalToParent(matrix);
return;
}
//
//----------------------------------------------------------
// We now have to multiply the matrices and store the result
//----------------------------------------------------------
//
LinearMatrix4D transformed;
transformed.Multiply(old, matrix);
SetLocalToParent(transformed);
}