2 registered members (VoroneTZ, TipmyPip),
1,333
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Newton 2 wrapper
[Re: BigM]
#224492
08/30/08 14:19
08/30/08 14:19
|
Joined: Aug 2004
Posts: 1,345 Kyiv, Ukraine
VeT
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
|
greetings yes, now i'm working now on compounds, but have some problems there... okay, what about destructor.. i made some tests and must to say that you are right, engine craches if i remove entity after several tests, i change code to this: here is new destructor
void onsetdestructor(NewtonBody *body)
{
ENTITY *entity = (ENTITY*)NewtonBodyGetUserData(body);
if (entity) {ent_remove(entity);}
}
here is a process of destruction
if (key_x)
{
if (my.skill99!=0) {NewtonDestroyBody(nworld,(NewtonBody*) my.skill99);}
}
i think, its the best and simplest way: graphical entity is removed in destructor of newtons body, so we just may delete only NewtonBody destructor would be changed in v.9 why dont you download the last versions: i added only new levels, but the core of wrapper is unchanged(till now :)) anyway, thanks for gelp in debuging
Last edited by VeT; 08/30/08 14:21.
|
|
|
Re: Newton 2 wrapper
[Re: VeT]
#224568
08/30/08 21:54
08/30/08 21:54
|
Joined: Oct 2005
Posts: 57
picoder
Junior Member
|
Junior Member
Joined: Oct 2005
Posts: 57
|
Nice job VeT!
Keep up the good work!
Last edited by picoder; 01/20/10 07:09.
|
|
|
Re: Newton 2 wrapper
[Re: VeT]
#224719
08/31/08 21:34
08/31/08 21:34
|
Joined: Oct 2006
Posts: 36
BigM
Newbie
|
Newbie
Joined: Oct 2006
Posts: 36
|
Thanks, will do that. Actually there are not that many changes: mostly I changed the NewtonUpdate call. If you find any of this interesting please add it to the wrapper:
void newton_start()
{
newton_running = 1;
nworld = NewtonCreate(0, 0);
newton_addstaticcollisiongeometry();
while(newton_running) // newton has to update every frame
{
advance = time_frame/16;
slices = integer((advance / MIN_NEWTON_ADVANCE) + 1);
for (slices_left = slices; slices_left > 0; slices_left--){
NewtonUpdate(nworld, advance/slices);
}
wait(1);
proc_mode = PROC_LATE;
}
}
I implemented time slicing because I wanted precise control over the fineness of the simulation and felt NewtonSetMinimumFrameRate didn't work quite like I expected back in newton 1.53. Maybe this is useless now. I also set proc_mode to PROC_LATE: this way the simulation is performed right after the main cycle, instead of before. I believe this way to be better as the time_frame value used in calculations in main() (in my case acceleration calculations based on user input) refers to the same frame as the time_frame used to compute the update time. Hope this are useful 2 cents! Please let me know what you think.
|
|
|
|