Welcome, Guest. Please Login.
Gravity Simulator
11/22/17 at 19:45:44
News: Registration for new users has been disabled to discourage spam. If you would like to join the forum please send me an email with your desired screen name to tony at gravitysimulator dot com.
Home Help Search Login


Pages: 1
Send Topic Print
Bug Report: Collisions. (Read 1695 times)
phoenixshade
Uploader



Proud to be an Ape

Posts: 26
Gender: male
Bug Report: Collisions.
02/05/11 at 10:56:52
 
I have discovered a bug in how gravsim handles collisions. It is a rare bug, because it only occurs when there are multiple collisions in a single integration step. Sometimes the wrong objects disappear, and furthermore mass is not always conserved.
 
The attached sim demonstrates the problem. (In order to reproduce the bug, make sure you run it with a 1 second timestep.) It contains 10 objects, with masses as follows:
 
Index . .Name . . . . . .Mass
1Object 11
2Object 21
3Object 31
4Object 44
5Object 53
6Object 62
7Object 71
8Object 81
9Object 92
10Object 101

Total mass: 17.
 
In a single iteration the following collisions occur: Object 2 collides with Object 9 AND Object 4 collides with Object 5. The simulation pauses immediately after these collisions are processed.
 
From collisions.dat:
Quote:
01 01 0  03 45 59, C:\Program Files\Gravity Simulator\simulations\collision_bug.gsim, Object 9, Object 2,  8932.15303863426,  6308.46827395514
01 01 0  03 45 59, C:\Program Files\Gravity Simulator\simulations\collision_bug.gsim, Object 5, Object 4,  14403.7388330637,  8458.8776239375

At this point, the following objects remain:
Index . .Name . . . . . .Mass
1Object 11
2Object 31
3Object 47
4Object 53
5Object 71
6Object 81
7Object 93
8Object 101

Total mass: 18.
 
The first collision (2 and 9) was handled properly, but the second (4 and 5) went horribly awry. It appears that the mass of 4 and 5 was properly combined, but for some reason, object SIX was deleted.
 
Also, note that Object 4 and Object 5 both still exist. Since they are still in contact, they are processed as a collision again on the next frame:
 
From collisions.dat:
Quote:
01 01 0  03 46 00, C:\Program Files\Gravity Simulator\simulations\collision_bug.gsim, Object 5, Object 4,  8240.6927447439,  16916.6173023384

Remaining objects:
Index . .Name . . . . . .Mass
1Object 11
2Object 31
3Object 410
4Object 71
5Object 81
6Object 93
7Object 101

Total mass: 18.
 
I'm pretty sure the problem comes from either the way objects are re-indexed after collisions, or the way the CollisionObjectA and CollisionObjectB arrays are modified after each collision. I think the best solution would be to handle all the collisions in a loop, and to collapse and re-index the Object arrays only after ALL collisions have been processed.
Back to top
« Last Edit: 02/05/11 at 17:21:10 by phoenixshade »  
View Profile   IP Logged
Tony
YaBB Administrator
*****




Posts: 1051
Gender: male
Re: Bug Report: Collisions.
Reply #1 - 02/13/11 at 21:31:06
 
Thanks for the detailed bug report which includes a gsim documenting the error.  I've been a bit busy lately, so I'm probably going to put this on the back burner for a little while.  It only happens when two collisions happen in the same iteration, which is rare.  But if this bug is interfering with simulations you're trying to create, let me know, and I'll push it higher on the priority list.  Otherwise, I'll add it to a list of things to fix/improve for the next time I get a solid block of time to do some coding.
Back to top
 
 
Email View Profile WWW   IP Logged
EDG
Ultimate Member
*****


oh, crumbs!!!

Posts: 611
Gender: male
Re: Bug Report: Collisions.
Reply #2 - 02/14/11 at 00:37:51
 
Quote from Tony on 02/13/11 at 21:31:06:
Otherwise, I'll add it to a list of things to fix/improve for the next time I get a solid block of time to do some coding.

 
Do you have anything else on that list, out of curiosity? Wink
Back to top
 
 

(formerly known as Mal)
View Profile WWW   IP Logged
Pages: 1
Send Topic Print