0 registered members (),
1,094
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Newton 2 wrapper
[Re: VeT]
#273083
06/21/09 11:15
06/21/09 11:15
|
Joined: Apr 2009
Posts: 14 Poland, Germany
EnjoMitch
Newbie
|
Newbie
Joined: Apr 2009
Posts: 14
Poland, Germany
|
I got some help from Julio and Delfi on Newton forum. Problems with rolling objects, bouncing from edges can be solved by greatly increasing NewtonUpdate call frequency. So if the problem of GS is that it doesn't allow you to call a function in a while loop more often than once per frame, you can use a for loop in that while loop, which slices the current (time_frame / 16) into time intervals (subDt) so little, that when calling NewtonUpdate as many times as the count of slices, you get the necessary NewtonUpdate call frequency. Of course, you also you have to pass NewtonUpdate the correct sub delta time. Here's the code, adapted to your wrapper, for super precision required in simulations:
void newton_update()
{
var newtonFPS = 1000;
if ((newton_running) && (nworld!=0))
{
float dt = time_frame / 16;
var vratio = (dt * newtonFPS);
var n = integer(vratio) + 1;
float subDt = dt / n;
int i;
for ( i = 0; i < n; i++ )
NewtonUpdate(nworld, subDt);
// proc_mode = PROC_LATE;
}
}
You could pass the desired Newton FPS with newton_start() for example. Another problem is that while boosting Newton FPS to solve bouncing on edges problem solves it in case of models, it doesn't work for blocks. What do you suspect? Vertices set not precisely enough maybe? I'll investigate this myself after I fully integrate Newton into my game. Finally I have at least one firm solution. Thanks so far.
|
|
|
Re: Newton 2 wrapper
[Re: VeT]
#273104
06/21/09 13:14
06/21/09 13:14
|
Joined: Apr 2009
Posts: 14 Poland, Germany
EnjoMitch
Newbie
|
Newbie
Joined: Apr 2009
Posts: 14
Poland, Germany
|
Than 1000? No, I don't think so. Notice that my test case works with about 400 - 500 FPS, which gives 400 - 500 FPS for Newton. Setting it to 1000 gives two or three times that much FPS (three times because of that +1. It's AT LEAST 1000). It's suspicious that you need at least 1000 FPS, but it does make the difference. You can try lowering it for the test case below GS FPS and you'll see the ball bouncing then.
[EDIT] Lines var vratio = (dt * newtonFPS); var n = integer(vratio) + 1;
can be merged into one line var n = integer(dt * newtonFPS) + 1; of course.
Last edited by EnjoMitch; 06/21/09 13:27.
|
|
|
|