Sub Entities of Sub entities are not drawing.
here is the code for drawing Entities in shipEntity.h
Code: Select all
- (void)drawEntity:(BOOL)immediate :(BOOL)translucent
{
NSEnumerator *subEntityEnum = nil;
ShipEntity *subEntity = nil;
if ((no_draw_distance < zero_distance) || // Done redundantly to skip subentities
(cloaking_device_active && randf() > 0.10))
{
// Don't draw.
return;
}
// Draw self.
[super drawEntity:immediate :translucent];
#ifndef NDEBUG
// Draw bounding boxes if we have to before going for the subentities.
// TODO: the translucent flag here makes very little sense. Something's wrong with the matrices.
if (translucent) [self drawDebugStuff];
else if (gDebugFlags & DEBUG_BOUNDING_BOXES && ![self isSubEntity])
{
OODebugDrawBoundingBox([self boundingBox]);
OODebugDrawColoredBoundingBox(totalBoundingBox, [OOColor purpleColor]);
}
#endif
// Draw subentities.
if (!immediate) // TODO: is this relevant any longer?
{
for (subEntityEnum = [self subEntityEnumerator]; (subEntity = [subEntityEnum nextObject]); )
{
[subEntity setOwner:self]; // refresh ownership
[subEntity drawSubEntity:immediate :translucent];
}
}
}
so the drawing of sub entities of sub entities, should be found in the function
drawSubentity
that is this...
Code: Select all
- (void) drawSubEntity:(BOOL) immediate :(BOOL) translucent
{
Entity* my_owner = [self owner];
if (my_owner)
{
// this test provides an opportunity to do simple LoD culling
zero_distance = [my_owner zeroDistance];
if (zero_distance > no_draw_distance)
{
return; // TOO FAR AWAY
}
}
if ([self status] == STATUS_ACTIVE)
{
Vector abspos = position; // STATUS_ACTIVE means it is in control of it's own orientation
Entity *last = nil;
Entity *father = my_owner;
OOMatrix r_mat;
while ((father)&&(father != last) &&father != NO_TARGET)
{
r_mat = [father drawRotationMatrix];
abspos = vector_add(OOVectorMultiplyMatrix(abspos, r_mat), [father position]);
last = father;
if (![last isSubEntity]) break;
father = [father owner];
}
GLLoadOOMatrix([UNIVERSE viewMatrix]);
glPopMatrix();
glPushMatrix();
GLTranslateOOVector(abspos);
GLMultOOMatrix(rotMatrix);
[self drawEntity:immediate :translucent];
}
else
{
glPushMatrix();
GLTranslateOOVector(position);
GLMultOOMatrix(rotMatrix);
[self drawEntity:immediate :translucent];
glPopMatrix();
}
#ifndef NDEBUG
if (gDebugFlags & DEBUG_BOUNDING_BOXES)
{
OODebugDrawBoundingBox([self boundingBox]);
}
#endif
}
if this SubEntity is a Flasher and it is rotating in another direction than the parent model.. then we have problem...
One example is my jumpgate that had counter rotating models, but only the main models flashers where shown.. despite it had an AI.plist trying to switchLightsOn. Something not required for Entities of type station
So in short, the code is not prepared to receive a flasher on a sub Entity, since it never checks beneath the first level of sub entities, and since flashers are required to be SubEntities, then it is currently Impossible to put Flashers on Entities that are supposed to be Subentities...
I just tested again to be 100% sure... So in addition to the flashers, i added an viper that should be drawn-...
And I was reassured by this test, as the viper never got drawn, when it was a subentity of a sub entity.. just like flashers...
So I began speculating in how Todo this... first thing i needed to check was if the subentity was in the system at all.. so I called on the debug console and tried to write out the subEntities list of a subEntity...
For fun i tried in the debug console, while targeting my test entity
Code: Select all
player.ship.target.subEntities[0].subEntities
So now i fear that it was never parsed correctly, when shipdata.plist was parsed..
Note that flashers are never listed... only mesh entities are listed.. in the debug console
posting,, before something screws up like my wife pushing the wrong button.. (it has happend)
To be continued...