[SOLVED]love.physics world performance

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

[SOLVED]love.physics world performance

Post by AdrianN »

Hi all, I've been experimenting with love.physics and I was to reestructure my game
I was to restructure my game, because I want to add more physics and make in HC is equal to use box2d module.

I use windfield library to administrate the world and check the collisions, also collisions class is a good option for my game.

The problem is the performance, becausa my game in HC require only 30 or 40 kb of memory, but with box2d memory is very more, like 120kb.

Any way to limite the logic for only bodies into camera, and sleep others to liberate memory?

I used this function but doesn't work.

Code: Select all

body:setActive( false )
With HC I only need check if body stay in camera range.

Update : ASDW to move player box

Image
Attachments
game.love
(123.77 KiB) Downloaded 173 times
Last edited by AdrianN on Thu Jan 31, 2019 12:10 am, edited 3 times in total.
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

Re: love.physics world performance

Post by AdrianN »

Pd: Added more details
monkyyy
Citizen
Posts: 52
Joined: Fri Mar 16, 2012 5:29 pm

Re: love.physics world performance

Post by monkyyy »

>Any way to limite the logic for only bodies into camera, and sleep others to liberate memory?

https://love2d.org/wiki/Body:setAwake ?
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

Re: love.physics world performance

Post by AdrianN »

monkyyy wrote: Tue Jan 29, 2019 9:47 am >Any way to limite the logic for only bodies into camera, and sleep others to liberate memory?

https://love2d.org/wiki/Body:setAwake ?

Code: Select all

body:setType('static')
body:setSleepingAllowed( true )
body:setActive( false )
body:setAwake(false)
Stil use a lot of memory, even if I don't draw bodies.

Image
Last edited by AdrianN on Tue Jan 29, 2019 4:14 pm, edited 1 time in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: love.physics world performance

Post by grump »

150 kb is not "a lot of memory".
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

Re: love.physics world performance

Post by AdrianN »

grump wrote: Tue Jan 29, 2019 4:10 pm 150 kb is not "a lot of memory".
Sure, but I was already used to using a third of that memory, and I thought that sleeping bodies and deactivate would lower memory usage.

But fps in my game is medium, around 30 and only drawing the map.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: love.physics world performance

Post by grump »

AdrianN wrote: Tue Jan 29, 2019 4:35 pm Sure, but I was already used to using a third of that memory
But you've also gained full-fledged physics simulation.
and I thought that sleeping bodies and deactivate would lower memory usage.
Deactivating bodies does not remove them from memory. You have to destroy them completely and force a GC cycle if you want that memory back.

120 kb of memory consumption is no reason to act IMHO. I mean, your screenshot alone requires over 50 times that amount of memory.
But fps is medium, around 30 and nothing drawing (no world:draw()), only map.
There is no direct correlation between memory usage and fps.
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

Re: love.physics world performance

Post by AdrianN »

There is no direct correlation between memory usage and fps.
I did not know.

Haha, sure, I understand. Thanks for explain.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: love.physics world performance

Post by ivan »

Looking at your screenshot I really hope each of those squares is not a separate body, right?
That would explain the wasted memory.
For static stuff you can put all of your fixtures in a single "ground" body (bodies can have multiple fixtures).
Better yet - just use "edge shapes" to define the collision platforms and static geometry of your game.
Hope this helps!
User avatar
AdrianN
Citizen
Posts: 73
Joined: Wed Mar 28, 2018 5:13 pm
Location: Lima

Re: love.physics world performance

Post by AdrianN »

ivan wrote: Tue Jan 29, 2019 5:54 pm Looking at your screenshot I really hope each of those squares is not a separate body, right?
That would explain the wasted memory.
For static stuff you can put all of your fixtures in a single "ground" body (bodies can have multiple fixtures).
Better yet - just use "edge shapes" to define the collision platforms and static geometry of your game.
Hope this helps!
Yes, I know, but the mechanics of my game is destroy the map.

Image

"Like 1 2 and 3 case"
Because if join shapes in one like 4 case, the destruction would be limited.

I thinking about join bodies in one, like the 5 case, but I not yet tried. Using object layers in tiled to make ground and walls.

Thanks for you reply.
Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests