matiasah / shadows

Shädows - A Shadows & Lights engine for löve
MIT License
169 stars 11 forks source link

Merge-sort and draw #20

Closed matiasah closed 7 years ago

matiasah commented 7 years ago

Since every object contains 'Z' attribute, I should possibly implement a table that contains all the bodies sorted by their 'Z' component.

However, I should do this every time a body changes it's 'Z' component, or every time a body is added or removed from the light world so that this table doesn't need to be generated too often.

Merge-sort would probably come in handy for this operation as it's needed to generate a output with a new table. Afterwards I would only have to iterate this table once to draw all the objects.

matiasah commented 7 years ago

I'm uploading the changes, could you try it again? I seem to have missed a minor detail.

The way I was setting the child to a parent object was via Parent[self.ID] = self and the correct way is Parent.Children[self.ID] = self

Skeletonxf commented 7 years ago

Fixed, and body destruction no longer causes problems as far as I can tell

Also omg the fps jumped up by 30 again to 130 in game! I can even get 150 fps in the main menu now. Whatever changes you made in the last few hours made a huge difference

matiasah commented 7 years ago

We seem to be cool! I'll close this issue then. If we figure out more problems we can just open up a new one, this has taken a long conversation that we barely manage to reach it's end.

Skeletonxf commented 7 years ago

Thank you very much.

TangentFoxy commented 7 years ago

Question..

I would re-implement this feature on the code if I knew how not to break the multiple layers feature.

Is there a way that feature could be toggled to get that back? Or is it not relevant with the changes made over the course of working on this issue?

matiasah commented 7 years ago

The multiple layers feature is still present on the current version and it seems to be working just fine.

The only change we made for good was to make the code memorize the shadow casted by unchanged shapes.