Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, AndrewAMD, Imhotep, TipmyPip, Edgar_Herrera), 809 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
code crash after level_load #455603
10/25/15 13:42
10/25/15 13:42
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
hi all

i'm not expert for physics and i have a few questions how to use physx in my game, of course on the proper way

everything works pretty well until the moment when i need to load second level and then return in the first
i get crash e1513 script crash in physX_open
i tried to clean up the pointers with ent_remove but is still something wrong
in this code when i change level over five times script crash (when i put this code in my game i get crash fist time when i back in level where is physic object)

Code:
#include <default.c>
#include <ackphysX.h>
#include <mtlFX.c>

ENTITY *pole;

action flag(){
	my.material = mtl_twosided_alpha;
	// attach flag to pole
	c_setminmax(pole);
	c_setminmax(my);
	vec_set(my.x,vector(pole.x, pole.y+(my.max_y-my.min_y)/2, pole.z+pole.max_z-(my.max_z-my.min_z)/2));
	
	// setup flag cloth	
	var cloth_options[40];
	memcpy(cloth_options,CLOTH_DEFAULT,40*sizeof(var));
	vec_set(cloth_options[25],vector(-10,20,0));  // external acceleration
	vec_set(cloth_options[28],vector(5,10,5));  // random wind acceleration
	cloth_options[9] = 4; // Tear Factor
	cloth_options[37] |= NX_CLF_GRAVITY|NX_CLF_BENDING|NX_CLF_COLLISION_TWOWAY|NX_CLF_SELFCOLLISION|NX_CLF_TEARABLE|NX_CLF_BENDING_ORTHO;
	
	pXent_cloth(my,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options);
}

action flag_pole(){
	pole = me;
	vec_set(pole.scale_x,vector(0.2,0.2,40));
	vec_set(pole.pan,vector(0,0,0));
	vec_set(pole.blue,COLOR_GREY);
	pXent_settype(pole,PH_STATIC,PH_BOX);
}

action act_flag_creator(){
	set(my,INVISIBLE);	
	ent_create(CUBE_MDL,vector(my.x,my.y,my.z),flag_pole);
	ent_create("clothflag.mdl",NULL,flag);
}

function main(){	
	fps_max = 60;
	level_load("test1.wmb");	
	physX_open();
	while(1){
		if(key_1){ level_load("test1.wmb");}
		if(key_2){ level_load("test2.wmb");}
		wait(1);	
	}
}



can someone show me where i wrong and explain what happens to physic objects after level load?

Re: code crash after level_load [Re: CodeMaster] #455604
10/25/15 14:03
10/25/15 14:03
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
I don´t think that it´s healthy to load a level in a loop. Try on_... events.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: code crash after level_load [Re: alibaba] #455605
10/25/15 14:13
10/25/15 14:13
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
yeah, written on the speed, it's just for test purpose but not related to the main problem

Re: code crash after level_load [Re: CodeMaster] #455607
10/25/15 18:09
10/25/15 18:09

M
Malice
Unregistered
Malice
Unregistered
M



well there is this

Quote:
Call physX_open() before loading the first level. This automatically registers level geometry and static models as physics obstacles.


However you open after level_load

http://www.conitec.net/beta/pX_intro.htm

Manual example

Code:
#include <default.c>
#include <ackphysx.h>

function main()
{
  physX_open();
  level_load(""); // load an empty level
  vec_set(camera.x,vector(-100,0,30));
  pXent_settype(NULL,PH_STATIC,PH_PLANE); // create a static plane at groundlevel zero
  
  ENTITY* ball = ent_create(SPHERE_MDL,vector(0,0,100),NULL);
  pXent_settype(ball,PH_RIGID,PH_SPHERE ); // create a ball
  pXent_setelasticity(ball,50);
  pXent_addvelcentral(ball,vector(0,-10,0)); // make it jump and roll sidewards

  while(1){
    pX_pick(); // pick and move the ball with the cursor
    wait(1);
  }
}


Last edited by Malice; 10/25/15 18:09.
Re: code crash after level_load [Re: ] #455612
10/25/15 18:44
10/25/15 18:44
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
it does not change a thing, the result is the same, crash after five level changes
i call physX_open after level load beacuse i see this in clothdemo script from a8 samples folder
how to nullify the physic object as if it had never been created? did is possible remove all physic activity from memory? it would perhaps prevent crashing physX_open function, because it happens only after level load

Re: code crash after level_load [Re: CodeMaster] #455613
10/25/15 19:06
10/25/15 19:06

M
Malice
Unregistered
Malice
Unregistered
M



If you open physX after the level_load - than this does not happen

Quote:
This function in ackphysX.h starts the physics simulation loop, and sets up level_load and ent_remove events for automatically registering and unregistering static objects.


Which would mean you are not unreg objects with level_load

try running
http://www.conitec.net/beta/physX_destroy.htm

phys_open
level_load

// new levels
physX_destroy ( )
level_load(...new level..)
physX_open
/// next time
physX_destroy ( )
level_load(...new level..)
physX_open

---However I'm troubleshooting guessing
Also while() if(key) level_load .. Will cause many calls to level_load. No matter how fast you touch the "key" the engine will read the key-press many time in one second. Bad code


Last edited by Malice; 10/25/15 19:09.
Re: code crash after level_load [Re: ] #455614
10/25/15 19:30
10/25/15 19:30

M
Malice
Unregistered
Malice
Unregistered
M



As a note - Just using your function main() and replacing the levels with my own... I can not repeat this error.. Would lead me to believe the error is elsewhere or with one of the levels themselves.
Code:
function main(){	
	fps_max = 60;
	level_load("test1.wmb");	
	physX_open();
	while(1){
		if(key_1){ level_load("my_test1.wmb");}
		if(key_2){ level_load("my_test2.wmb");}
		wait(1);	
	}
}



Possible - Loading a level the exceeds the current nexus limit..

Re: code crash after level_load [Re: ] #455615
10/25/15 19:35
10/25/15 19:35
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
I think the problem from the actions you need to add this in bigining of action flag
While(!pole){wait(1);}

We add this bec if action flag created before action pole this produce a crash

Last edited by Dico; 10/25/15 19:40.
Re: code crash after level_load [Re: Dico] #455622
10/25/15 22:16
10/25/15 22:16
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
thank you guys

with physX_destroy() and level change, crash e1513 in physX_open() is gone but now i can't run physX_open again and i don't know why?
the manual say
Quote:
make sure to call physX_destroy at the end of the program, or when you don't need the physics engine anymore
what this mean when is said "when you don't need the physics engine anymore"? did is possible after physx_destroy open physics engine again?

Re: code crash after level_load [Re: CodeMaster] #455627
10/26/15 00:27
10/26/15 00:27

M
Malice
Unregistered
Malice
Unregistered
M



Level_load removes all ents then loads the new level

If physX_open is called first then you should not need ph--destroy
Like I said I used your main() with my levels and could not repeat the error.

physX_open()
level_load(...)

if(!key && lock ==1)
lock =0;
if(key && lock==0)
{
lock=1;
level_load(..)
}
press key 20 times, no issue... You'r problem seems elsewhere.

Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1