Cleanup bucketAddTypeToList by inlining bucketCalculateState and simplifying the result.

master
safety0ff 2011-06-13 02:40:58 +00:00
parent 84fd40521b
commit 24a67fa1da
1 changed files with 52 additions and 95 deletions

View File

@ -341,103 +341,12 @@ static SDWORD bucketCalculateZ(RENDER_TYPE objectType, void* pObject)
return z;
}
static SDWORD bucketCalculateState(RENDER_TYPE objectType, void* pObject)
{
SDWORD z = 0;
const iIMDShape* pie;
if (bucketCalculateZ(objectType,pObject) < 0)
{
return -1;
}
switch(objectType)
{
case RENDER_EFFECT:
switch(((EFFECT*)pObject)->group)
{
case EFFECT_WAYPOINT:
case EFFECT_EXPLOSION:
case EFFECT_CONSTRUCTION:
pie = ((EFFECT*)pObject)->imd;
z = INT32_MAX - pie->texpage;
break;
case EFFECT_SMOKE:
case EFFECT_GRAVITON:
case EFFECT_BLOOD:
case EFFECT_STRUCTURE:
case EFFECT_DESTRUCTION:
default:
z = INT32_MAX - 42;
break;
}
break;
case RENDER_DROID:
pie = BODY_IMD(((DROID*)pObject),0);
z = INT32_MAX - pie->texpage;
break;
case RENDER_STRUCTURE:
pie = ((STRUCTURE*)pObject)->sDisplay.imd;
z = INT32_MAX - pie->texpage;
break;
case RENDER_FEATURE:
pie = ((FEATURE*)pObject)->sDisplay.imd;
z = INT32_MAX - pie->texpage;
break;
case RENDER_PROXMSG:
z = INT32_MAX - 40;
break;
case RENDER_PROJECTILE:
pie = ((PROJECTILE*)pObject)->psWStats->pInFlightGraphic;
z = INT32_MAX - pie->texpage;
break;
case RENDER_ANIMATION:
pie = ((COMPONENT_OBJECT*)pObject)->psShape;
z = INT32_MAX - pie->texpage;
break;
case RENDER_DELIVPOINT:
pie = pAssemblyPointIMDs[((FLAG_POSITION*)pObject)->
factoryType][((FLAG_POSITION*)pObject)->factoryInc];
z = INT32_MAX - pie->texpage;
break;
default:
break;
}
return z;
}
/* add an object to the current render list */
void bucketAddTypeToList(RENDER_TYPE objectType, void* pObject)
{
BUCKET_TAG newTag;
int32_t z;
bool useCalculateZ = false;
switch (objectType)
{
case RENDER_EFFECT:
switch (((EFFECT*)pObject)->group)
{
case EFFECT_EXPLOSION:
case EFFECT_CONSTRUCTION:
case EFFECT_SMOKE:
case EFFECT_FIREWORK:
useCalculateZ = true;
break;
default: break;
}
break;
case RENDER_SHADOW:
case RENDER_PROJECTILE:
case RENDER_PROXMSG:
useCalculateZ = true;
break;
default: break;
}
// NOTE bucketCalculateState calls bucketCalculateZ, don't know why not just use bucketCalculateZ.
z = useCalculateZ ? bucketCalculateZ(objectType, pObject) : bucketCalculateState(objectType, pObject);
const iIMDShape* pie;
BUCKET_TAG newTag;
int32_t z = bucketCalculateZ(objectType, pObject);
if (z < 0)
{
@ -447,10 +356,58 @@ void bucketAddTypeToList(RENDER_TYPE objectType, void* pObject)
/* Won't draw selection boxes */
((BASE_OBJECT *)pObject)->sDisplay.frameNumber = 0;
}
return;
}
switch(objectType)
{
case RENDER_EFFECT:
switch(((EFFECT*)pObject)->group)
{
case EFFECT_EXPLOSION:
case EFFECT_CONSTRUCTION:
case EFFECT_SMOKE:
case EFFECT_FIREWORK:
// Use calculated Z
break;
case EFFECT_WAYPOINT:
pie = ((EFFECT*)pObject)->imd;
z = INT32_MAX - pie->texpage;
break;
default:
z = INT32_MAX - 42;
break;
}
break;
case RENDER_DROID:
pie = BODY_IMD(((DROID*)pObject),0);
z = INT32_MAX - pie->texpage;
break;
case RENDER_STRUCTURE:
pie = ((STRUCTURE*)pObject)->sDisplay.imd;
z = INT32_MAX - pie->texpage;
break;
case RENDER_FEATURE:
pie = ((FEATURE*)pObject)->sDisplay.imd;
z = INT32_MAX - pie->texpage;
break;
case RENDER_ANIMATION:
pie = ((COMPONENT_OBJECT*)pObject)->psShape;
z = INT32_MAX - pie->texpage;
break;
case RENDER_DELIVPOINT:
pie = pAssemblyPointIMDs[((FLAG_POSITION*)pObject)->
factoryType][((FLAG_POSITION*)pObject)->factoryInc];
z = INT32_MAX - pie->texpage;
break;
default:
// Use calculated Z
break;
}
//put the object data into the tag
newTag.objectType = objectType;
newTag.pObject = pObject;