Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Turn off rotation in physics engine..?.

Author
Message
Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 25th Apr 2012 23:36
Hi to all knowledgeable people of agk!

I want simulate some kind of sand wich you can write in...and for that purpose i ned a lot of sprites. Im talking 1000s of small dots. The sprites will be really small. And I want to use physics to control them. I have tried this and of course it slows down with too many of them. 1000 flows alright but anything over that starts to slow down.

What im wondering is that since the physics engine also calculates the angles of the sprites....wich i dont need.. Is it possible to turn ofF the angular calculations in the physics engine to relief the engine and perhaps speed things up?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Apr 2012 01:11 Edited at: 26th Apr 2012 01:12
You can try setSpritePhysicsCanRotate set to 0 but I doubt it will give much of a speed increase.

Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 26th Apr 2012 10:18
Just what I was looking for.
But as you said, it didn't help much.

Thank you.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 26th Apr 2012 13:27
You need to wait for 107 update to get some sprite creation commands. Physics for sand is way too much overhead
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Apr 2012 13:41
Maybe there's a way to turn physics off in chunks / groups of sprites. Maybe you could only turn on physics for sprites that are within a certain distance of the person's finger?

Maybe you could only make some physics sprites as the person draws and the other sprites are just deleted?

I can think of a number of ways of making this work without having thousands of active physics sprites.

Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 26th Apr 2012 16:06
baxslash, you are right...
I should probably make an invisible rectangle around my finger sprite and check this for collisions and only turn on physics for the sprites inside this rectangle...or?

If I'm thinking right which command is the best to use to check this rectangle?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Apr 2012 16:10
getSpriteInCircle()

kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 26th Apr 2012 17:31 Edited at: 26th Apr 2012 17:37
I think that commands like getSpriteInCircle() & getSpriteInBox() are making things even too easy sometimes, as it's basically:



Weird, but I'd prefer coding it myself (and I always do).
As for getSpriteInBox() it's probably:



Althrough, there can be some checks if x2 is bigger than x1 && y2 is bigger than y1. (Also those samples I've gave probably don't show how those functions look like in real AppGameKit library).


Too many small functions are hard to remember.

Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 29th Apr 2012 15:18
Thank you Kamac. Great help and great insight.

Login to post a reply

Server time is: 2024-05-04 12:32:23
Your offset time is: 2024-05-04 12:32:23