smcameron / space-nerds-in-space

Multi-player spaceship bridge simulator game. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
GNU General Public License v2.0
733 stars 75 forks source link

When planets are deleted the atmosphere remains behind #56

Closed smcameron closed 9 years ago

smcameron commented 9 years ago

When planets are deleted (via the demon screen, either by selecting and deleting or via running the "clear all" command, or via lua script) their atmospheres remain behind.

jv4779 commented 9 years ago

The atmosphere entity isn't a child of the planet like the rings? On Apr 30, 2015 11:56 PM, "smcameron" notifications@github.com wrote:

When planets are deleted (via the demon screen, either by selecting and deleting or via running the "clear all" command, or via lua script) their atmospheres remain behind.

— Reply to this email directly or view it on GitHub https://github.com/smcameron/space-nerds-in-space/issues/56.

smcameron commented 9 years ago

No, that was the first thing I tried. Oddly, making the atmosphere entities children of the planet entities like the rings makes the atmospheres not render at all. Have not yet looked into why that is.

smcameron commented 9 years ago

I think it may be because the child is inheriting in some way the scale from the parent? In entity.c, in update_entity_child_state...

union vec3 scale = e->e_scale; ... while loop to walk the child/parent chain, only 1 level deep in this case... ... vec3_cwise_product_self(&scale, &parent->e_scale); ... e->scale = scale;

Curently I am setting the planet scale to planet->r * 1.03; so maybe the above code is setting it to (r * r * 1.03) which is quite huge, making it fail to render? Tried setting scale of atmosphere to just 1.03 hoping to have the above parent-child chain walking code do the multiply but did not seem to work. I am a little confused about the above code, as it looks like it will accumulate successive multiplies in e->scale, which does not seem like the right thing to do (but somehow the planet rings work, so I must be missing something.)

smcameron commented 9 years ago

Ok, I figured out part of the problem... was storing away things in go[-1], which doesn't work so well. Still having some problems with the parent/child entity system though, so for now I am not using it in this particular case. Need to revisit that though. For now, see commit: 780468f35ab4ab319d5d8b36d9da4dff9f8fbc6d

smcameron commented 9 years ago

Ok, fixed this properly with commit d8dd1f5ab87579ca0407793f1e6b579ff17b4e03