reman3/Rayman_X/cpa/tempgrp/TDE/tde_Hierarchy.c

96 lines
3.0 KiB
C

/**************************************************************************************
File : HIERARCHY.CPP
Author : Delattre Franck & Valérie Cluzel
Last update : 28 August 1996
***************************************************************************************/
#include "TDE.h"
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
NAME : TDE_vInitZList
VERSION : 2.0 / Valérie
1.0 / Franck
AIM : Initialize the Z List
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
void TDE_vInitZList(TDE_p_stSuperObject *ZList)
{
short i;
for (i=0; i<TDE_kMAXPRIORITY; i++)
{
ZList[i] = NULL;
}
}
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
NAME : TDE_vBuildModifiedMatrix
VERSION : 2.0 / Valérie
1.0 / Franck
AIM : Calculate the modified matrix
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
void TDE_vBuildModifiedMatrix(TDE_tdsSuperObject *p_stSuperObject)
{
p_stSuperObject->stModifiedMatrix = MatrixStack[MS_Position];
}
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
NAME : TDE_vBuildHierarchy
VERSION : 2.0 / Valérie
1.0 / Franck
AIM : Build the hierarchy by building modified matrix
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**/
void TDE_vBuildHierarchy(TDE_tdsSuperObject *p_stSuperObject, TDE_p_stSuperObject *ZList)
{
TDE_tdsSuperObject *p_stSuperObjectInter;
static int iPos=0;
// Test if priority exceeds bounds
if (p_stSuperObject->sPriority >= TDE_kMAXPRIORITY)
{
Erm_M_UpdateLastError (Tde,
C_ucErmDefaultChannel,
E_uwTdeWarningPriorityTooHigh,
C_lErmNoDebugData,
C_ucErmOpenInfoWindow,
C_ucAllowStopForDebug, NULL);
p_stSuperObject->sPriority = TDE_kMAXPRIORITY - 1;
}
// Fill Z list
if (ZList[p_stSuperObject->sPriority]==NULL)
{
ZList[p_stSuperObject->sPriority] = p_stSuperObject;
p_stSuperObject->p_stNextZList = NULL;
}
else
{
p_stSuperObjectInter = ZList[p_stSuperObject->sPriority];
while (p_stSuperObjectInter->p_stNextZList != NULL) p_stSuperObjectInter = p_stSuperObjectInter->p_stNextZList;
p_stSuperObjectInter->p_stNextZList = p_stSuperObject;
p_stSuperObject->p_stNextZList = NULL;
}
// parse the hierarchy
PushMatrix(&(p_stSuperObject->stMatrix));
TDE_vBuildModifiedMatrix(p_stSuperObject);
if (p_stSuperObject->p_stChild != NULL)
{
iPos++; // Go downstairs
for (p_stSuperObjectInter = p_stSuperObject->p_stChild; p_stSuperObjectInter!=NULL; p_stSuperObjectInter = p_stSuperObjectInter->p_stRightBrother)
{
TDE_vBuildHierarchy(p_stSuperObjectInter, ZList);
PopMatrix();
}
iPos--; // Go upstairs
}
return;
}