Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Trunk: Sub Entites of Sub Entities are not drawing,

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Trunk: Sub Entites of Sub Entities are not drawing,

Post by Frame »

As the subject writes...

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];
		}
	}
}
If we go about as I read it, it runs through the subentities and draws them from the first to the last...

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
		
}
Now for ordinary solid entities of mesh type, this would be fine since all we would need to do was to move the subentity to the Parent.. However
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
it listed nothing... and it should at least have listed the viper, but maybe it is not listed, since it is not being drawn.. I do not know..

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...
Bounty Scanner
Number 935
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Sub-subentities are not supported. Last time I checked, there were a number of places in the code where they would cause serious problems (but I didn’t note the details).
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Ahruman wrote:
Sub-subentities are not supported. Last time I checked, there were a number of places in the code where they would cause serious problems (but I didn’t note the details).
Even simple subentities cause serious problems. Everytime I shall visit a Thargoid hive, I've got to remove the engines of my ship :?

Screet
User avatar
Nemoricus
---- E L I T E ----
---- E L I T E ----
Posts: 388
Joined: Mon May 18, 2009 8:51 pm

Post by Nemoricus »

Screet wrote:
Ahruman wrote:
Sub-subentities are not supported. Last time I checked, there were a number of places in the code where they would cause serious problems (but I didn’t note the details).
Even simple subentities cause serious problems. Everytime I shall visit a Thargoid hive, I've got to remove the engines of my ship :?

Screet
Don't you mean turrets?

But yeah, that is a serious problem. There are multiple player ships that use turrets and fixing the collision issues associated with them is important.

While I can't help you there (I've looked at the code, but could find neither the head nor the tail), I wish the best of luck in fixing this issue.
Dream as if you'll live forever
Live as if you'll die tomorrow
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Nemoricus wrote:
Don't you mean turrets?

But yeah, that is a serious problem. There are multiple player ships that use turrets and fixing the collision issues associated with them is important
No, not turrets. If I only remove the turrets, my ship still blows up. I need to disable ALL subentities of my ship, including the engines, to make it work. That's really strange. From first encounters with this problem, I only remember turrets being the problem. The reason might be that I first saw it flying a Caduceus (old style) which only has turret subentities. The new Caduceus has subentities for engines and such - and they cause the same problems as turrets. It's not a turreted ship issue, it's an issue for ships with subentities in general. I guess even flashers would cause the ships to blow up, but did not try it yet.

Screet
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Screet wrote:
Ahruman wrote:
Sub-subentities are not supported. Last time I checked, there were a number of places in the code where they would cause serious problems (but I didn’t note the details).
Even simple subentities cause serious problems. Everytime I shall visit a Thargoid hive, I've got to remove the engines of my ship :?

Screet
one fair bet is that the subEntity of type engine is making your ship to large ?. I do not know as I have never visited a hive. As i also know that you are not entirely a new commer, but i'll suggest it anyway pause then press d..

the little boxes you see when viewing your or any other ship.. is close quarter collision boxes... These are not used for entities a certain distance away from the player.. prolly the socalled infamous ship zero_distance... that is a hard code thing... not a java thing..

@Ahruman: would it not be logical then to move the flashers to a similar setup like exhausts and laser positions, since its whole reason for being a subEntity is non existant... at least to me it is... Of course this is something for your or someone elses TODO after 1.73... ;-)
Bounty Scanner
Number 935
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Frame wrote:
one fair bet is that the subEntity of type engine is making your ship to large ?. I do not know as I have never visited a hive. As i also know that you are not entirely a new commer, but i'll suggest it anyway pause then press d..
If those boxes would show the truth, there would be no difference with subentities on or off.

All turrets boxes are well within the boxes of the ship itself, and the same accounts for the engines.

However, I don't really understand what is being shown there, as the subentities also show up in a strange style with other colors (cyan, green and yellow).

Image
Image

Screet
User avatar
ClymAngus
---- E L I T E ----
---- E L I T E ----
Posts: 2508
Joined: Tue Jul 08, 2008 12:31 am
Location: London England
Contact:

Post by ClymAngus »

Frame wrote:
Screet wrote:
Ahruman wrote:
Sub-subentities are not supported. Last time I checked, there were a number of places in the code where they would cause serious problems (but I didn’t note the details).
Even simple subentities cause serious problems. Everytime I shall visit a Thargoid hive, I've got to remove the engines of my ship :?

Screet
one fair bet is that the subEntity of type engine is making your ship to large ?. I do not know as I have never visited a hive. As i also know that you are not entirely a new commer, but i'll suggest it anyway pause then press d..

the little boxes you see when viewing your or any other ship.. is close quarter collision boxes... These are not used for entities a certain distance away from the player.. prolly the socalled infamous ship zero_distance... that is a hard code thing... not a java thing..

@Ahruman: would it not be logical then to move the flashers to a similar setup like exhausts and laser positions, since its whole reason for being a subEntity is non existant... at least to me it is... Of course this is something for your or someone elses TODO after 1.73... ;-)
I did check the bound in box and it's smaller than the original ship. Also the neocad has 3 hard mount sub-entities around the neck of the craft. So removing the engines (damn I spent a lot of time working on those engines) might not be enough.

I've really got to get to the bottom of this, It's crippling the usefulness of my ships! The Cyan lines are the object facings (or normals). Blue boxes denote containment in oblong form (I think they also relate to collision detection too but I'm not sure).
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

Another one, this time flying into a fuel station at minimum speed. The crash is imminent, less than one second to live...and to me it looks like everything is perfectly well.

Image
User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Post by Cmdr James »

Im pretty sure something funny is going on here, the bounding boxes are "square", I cant think of a better word. Flat sided. But I am pretty sure that collision detection is done using spheres (radius). Does anyone know what critical bit of understanding has slipped my mind?
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

In order to have the series complete, here's three such shots with all subentities removed. In this case, there's no problem and the bounding boxes virtually look the same, concerning the size of the ship.

My impression is that not the bounding boxes shown are used in crash calculations, but that all subentities somehow make the ship 2-3 times larger than it normally is.

Image
Image
Image

Screet
User avatar
Nemoricus
---- E L I T E ----
---- E L I T E ----
Posts: 388
Joined: Mon May 18, 2009 8:51 pm

Post by Nemoricus »

You know, while I'm thinking about it, a free camera mode might also be useful.

Thoughts?
Dream as if you'll live forever
Live as if you'll die tomorrow
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Nemoricus wrote:
You know, while I'm thinking about it, a free camera mode might also be useful.

Thoughts?
I believe it's been on the wish/suggestion list of various people at least a few times...
User avatar
Nemoricus
---- E L I T E ----
---- E L I T E ----
Posts: 388
Joined: Mon May 18, 2009 8:51 pm

Post by Nemoricus »

Cmdr James wrote:
Im pretty sure something funny is going on here, the bounding boxes are "square", I cant think of a better word. Flat sided. But I am pretty sure that collision detection is done using spheres (radius). Does anyone know what critical bit of understanding has slipped my mind?
It makes some sense that the bounding areas are rectangular rather than spherical as a computer cannot display the surface of a sphere with complete precision. A series of boxes is closest approximation it can give.

Someone please correct me if I'm wrong with this.
Dream as if you'll live forever
Live as if you'll die tomorrow
User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Post by Cmdr James »

Kind of true, except it quite clear that oolite can draw decent circles and spheres -- look at planets ;)
Post Reply