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 (Nymphodora, AndrewAMD, TipmyPip, Quad, Imhotep), 847 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
can't open physic engine after physX_destroy #455636
10/26/15 13:50
10/26/15 13:50
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
i have problem to run physic engine again after using physX_destroy, for what i'm not even sure that's possible
Code:
#include <default.c>
#include <ackphysX.h>
#include <mtlFX.c>

ENTITY *pole;
ENTITY *flag_ent;

action flag(){
	flag_ent = me;
	while(!pole){wait(1);}
	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);
}

void create_flag(){
	ent_create(CUBE_MDL,vector(0,0,0),flag_pole);
	ent_create("clothflag.mdl",NULL,flag);
}

void destroy_physic(){
	ent_remove(pole);
	ent_remove(flag_ent);
	physX_destroy();
}

function main(){	
	fps_max = 60;
	physX_open();
	level_load("");
	vec_set(sky_color,COLOR_BLUE);
	vec_set(sun_angle.pan,vector(300,60,5000));
	vec_set(camera.x,vector(-1200,100,500));
	vec_set(camera.pan,vector(0,-10,0));
	while(1){
		on_d = destroy_physic;
		on_o = physX_open;
		on_c = create_flag;
		wait(1);	
	}
}


how to test this code? put this script in a8 samples folder, run and press key c to create physic object. then on key d delate objects and close physic engine. after that try run physic engine on key o
what i make wrong? did anybody know how destroy and open physic engine again?

Re: can't open physic engine after physX_destroy [Re: CodeMaster] #455646
10/26/15 17:38
10/26/15 17:38

M
Malice
Unregistered
Malice
Unregistered
M



Good New I found your error 1513 in physX_open. It has nothing to do with physX_open()


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

ENTITY *pole;
ENTITY *flag_ent;

action flag(){
	flag_ent = me;
	while(!pole){wait(1);}
	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);
}

void create_flag(){
	ent_create(CUBE_MDL,vector(0,0,0),flag_pole);
	ent_create("clothflag.mdl",NULL,flag);
}

//void destroy_physic(){
//	ent_remove(pole);
//	ent_remove(flag_ent);
//	physX_destroy();
//}
void p_open()
{
	ent_remove(pole);
	ent_remove(flag_ent);
	
	physX_open();
	level_load("");
	vec_set(sky_color,COLOR_BLUE);
	vec_set(sun_angle.pan,vector(300,60,5000));
	vec_set(camera.x,vector(-1200,100,500));
	vec_set(camera.pan,vector(0,-10,0));
}

function main(){	
	fps_max = 60;
	physX_open();
	level_load("");
	vec_set(sky_color,COLOR_BLUE);
	vec_set(sun_angle.pan,vector(300,60,5000));
	vec_set(camera.x,vector(-1200,100,500));
	vec_set(camera.pan,vector(0,-10,0));
	while(1){
		//on_d = destroy_physic;
		on_o = p_open;
		on_c = create_flag;
		wait(1);	
	}
}



If you press C you create a pole/flag.. If you press o , you remove the pole/flag and open_phys and load a level. NOW press C --- CRASH.
So the crash is when creating the pole/flag again... WHY???

I'll do more testing

Re: can't open physic engine after physX_destroy [Re: ] #455647
10/26/15 17:42
10/26/15 17:42

M
Malice
Unregistered
Malice
Unregistered
M



ODD fast tap key_o and key_c it works, but wait 5 second to press key_c crash...

Re: can't open physic engine after physX_destroy [Re: ] #455649
10/26/15 18:10
10/26/15 18:10

M
Malice
Unregistered
Malice
Unregistered
M



Hello your e1513 happens when this line runs for a second time...

pXent_cloth(my,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options);

This replace solves the error
pXent_cloth(my,pole,NX_CLOTH_ATTACHMENT_TWOWAY,NULL,NULL,CLOTH_DEFAULT);

So then the problem is with this array set-up
Code:
// 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,NULL,NULL,cloth_options);




EDIT - MORE UPDATES - remove the pointer to the pole solves the crash... Working on a fix.. There is a error with the called pointer.
pXent_cloth(my,NULL,NX_CLOTH_ATTACHMENT_TWOWAY,NULL,NULL,cloth_options);

EDIT- Update - CRASH FIXED
pXent_cloth(my,pole,0,NULL,NULL,cloth_options);
this flag cause a crash NX_CLOTH_ATTACHMENT_TWOWAY
MANUAL-
Quote:
When using two way interaction, it is important to set the appropriate mass of the attached objects. If an object with a very low or high mass density is attached to a cloth, the simulation may behave poorly.

Why the flag my crash the phyx engine.

Last edited by Malice; 10/26/15 18:56.
Re: can't open physic engine after physX_destroy [Re: ] #455650
10/26/15 18:42
10/26/15 18: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
malice thanks for your help, it also happens with other physic object not only with cloth

but it is related to my previous topic, now i opened a new topic where i want to know why after physic destroy we can't open physic engine again
i hope that someone will know the answer, if not i'll ask jcl

Re: can't open physic engine after physX_destroy [Re: CodeMaster] #455651
10/26/15 18:54
10/26/15 18:54

M
Malice
Unregistered
Malice
Unregistered
M



You only need to open it once, ever! You can not reopen it, don't destroy it. You can unreg all physX ent's if you wish to global turn it off.

For level loaded ents pXent_settype (NULL, 0, 0 );
for script created ent's pXent_settype (ENT_NAME, 0, 0 );

Re: can't open physic engine after physX_destroy [Re: ] #455652
10/26/15 19:09
10/26/15 19:09

M
Malice
Unregistered
Malice
Unregistered
M



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

ENTITY *pole;
ENTITY *flag_ent;

action flag(){
	flag_ent = me;
//	while(!pole){wait(1);}
	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,0,NULL,NULL,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);
}

void create_flag(){
	ent_create(CUBE_MDL,vector(0,0,0),flag_pole);
	
	ent_create("clothflag.mdl",nullvector,flag);
}

//void destroy_physic(){
//	ent_remove(pole);
//	ent_remove(flag_ent);
//	physX_destroy();
//}
void p_open()
{
	pXent_settype(pole,0,0);
	pXent_settype(flag_ent,0,0);
	pXent_settype(NULL,0,0);
	wait(1);
	ptr_remove(pole);
   ptr_remove(flag_ent);
   wait(1);
	//physX_open();	
	level_load(NULL);
	vec_set(sun_angle.pan,vector(300,60,5000));
	vec_set(camera.x,vector(-1200,100,500));
	vec_set(camera.pan,vector(0,-10,0));
}

function main(){	
	fps_max = 60;
	physX_open();
	level_load("");
	vec_set(sky_color,COLOR_BLUE);
	vec_set(sun_angle.pan,vector(300,60,5000));
	vec_set(camera.x,vector(-1200,100,500));
	vec_set(camera.pan,vector(0,-10,0));
	
		//on_d = destroy_physic;
		on_o = p_open;
		on_c = create_flag;
	
}



Ok I'll stop - This runs and does not crash - however debug panel fnc - ticks up and up and performance chocks , I don't know why.

Re: can't open physic engine after physX_destroy [Re: ] #455657
10/26/15 19:41
10/26/15 19:41
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 i see, this is a reason why i want use physx_destroy to clean up memory beacuse i do not know what's cooking in the background
i don't want because of one flag that use physics, at some point the whole game crash

malice i noticed in your code that after second creation flag loses force and stop flying

Last edited by CodeMaster; 10/26/15 20:03.
Re: can't open physic engine after physX_destroy [Re: CodeMaster] #455661
10/26/15 21:34
10/26/15 21:34

M
Malice
Unregistered
Malice
Unregistered
M



Quote:
malice i noticed in your code that after second creation flag loses force and stop flying


Not sure why or how. Check the physX settings. Maybe the cloth_opinions arrays is not fill the second time, or maybe not updated.

The physX system is a mess, please check your version and I step out of the post, because I really have no more answers for you.

I can say, destroy can not be called till system_exit

The issue maybe ent_create a second time verse ent_clone

Nope - This is a issue solely related to the pXent_cloth. Or this exaction of it. I used wait(1); on_o =lload; lload function simply reloads my level. Reloaded 40 times, no errors no memory issues. My physics project has no cloth.

Last edited by Malice; 10/26/15 22:54.
Re: can't open physic engine after physX_destroy [Re: ] #455666
10/26/15 23:29
10/26/15 23:29

M
Malice
Unregistered
Malice
Unregistered
M



I tested and worked it all morning solving e1513 only to get e1514 solving all errors only to fnc running climb and chock engine.

personally this is a bug!
Mal

Last testing code
Click to reveal..
Code:
ENTITY* p_pole;
ENTITY*p_flag_ent;
void p_open()
{
//	pXent_settype(p_pole,0,0);
	pXent_settype(p_flag_ent,0,0);
//	pXent_settype(NULL,0,0);
	wait(5);
	ent_remove(p_pole);
   ent_remove(p_flag_ent);
   wait(5);
	//physX_open();	
	level_load(NULL);
	vec_set(sun_angle.pan,vector(300,60,5000));
	vec_set(camera.x,vector(-1200,100,500));
	vec_set(camera.pan,vector(0,-10,0));
		//////////////////////////////
	// Cloth #1
	//////////////////////////////
	
	// generate flag pole	
	ENTITY *pole = ent_create(CUBE_MDL,vector(0,400,40*8),NULL);
	p_pole=pole;
	vec_set(pole.scale_x,vector(0.5,.5,40));
	vec_set(pole.pan,vector(0,0,0));
	vec_set(pole.blue,COLOR_WHITE);
	set(pole,SHADOW|CAST);
	pXent_settype(pole,PH_STATIC,PH_BOX);
	
	// generate flag
	ENTITY *cloth = ent_create("clothflag.mdl",NULL,NULL);
	p_flag_ent=cloth;
	vec_set(cloth.pan,vector(0,0,0));
	cloth.material = mtl_twosided_alpha;
	cloth.ambient = 50;
	set(cloth,SHADOW|CAST);
	set(cloth.material,PASS_SOLID); // required for shadow
	//ent_clone(cloth); // Prevents, that all clothes move the same way
	
	// attach flag to pole
	c_setminmax(pole);
	c_setminmax(cloth);
	vec_set(cloth.x,vector(
	pole.x,
	pole.y+(cloth.max_y-cloth.min_y)/2,
	pole.z+pole.max_z-(cloth.max_z-cloth.min_z)/2));
	
	// setup flag cloth	
	var cloth_options[40];
	
	memcpy(cloth_options,CLOTH_DEFAULT,40*sizeof(var));
	vec_set(cloth_options[25],vector(-1,-1,0));  // external acceleration
	vec_set(cloth_options[28],vector(0,30,0));  // 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;
	
	pXent_cloth(cloth,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options);
	
}

function main(){	
	fps_max = 60;
	physX_open();
	level_load("");
	vec_set(sky_color,COLOR_BLUE);
	vec_set(sun_angle.pan,vector(300,60,5000));
	vec_set(camera.x,vector(-1200,100,500));
	vec_set(camera.pan,vector(0,-10,0));
	wait(1);
		//on_d = destroy_physic;
		on_o = p_open;
//		on_c = create_flag;
//		var num_bodies = pX_stats(1);
	//////////////////////////////
	// Cloth #1
	//////////////////////////////
	
	// generate flag pole	
	ENTITY *pole = ent_create(CUBE_MDL,vector(0,400,40*8),NULL);
	p_pole=pole;
	vec_set(pole.scale_x,vector(0.5,.5,40));
	vec_set(pole.pan,vector(0,0,0));
	vec_set(pole.blue,COLOR_WHITE);
	set(pole,SHADOW|CAST);
	pXent_settype(pole,PH_STATIC,PH_BOX);
	
	// generate flag
	ENTITY *cloth = ent_create("clothflag.mdl",NULL,NULL);
	p_flag_ent=cloth;
	vec_set(cloth.pan,vector(0,0,0));
	cloth.material = mtl_twosided_alpha;
	cloth.ambient = 50;
	set(cloth,SHADOW|CAST);
	set(cloth.material,PASS_SOLID); // required for shadow
	//ent_clone(cloth); // Prevents, that all clothes move the same way
	
	// attach flag to pole
	c_setminmax(pole);
	c_setminmax(cloth);
	vec_set(cloth.x,vector(
	pole.x,
	pole.y+(cloth.max_y-cloth.min_y)/2,
	pole.z+pole.max_z-(cloth.max_z-cloth.min_z)/2));
	
	// setup flag cloth	
	var cloth_options[40];
	
	memcpy(cloth_options,CLOTH_DEFAULT,40*sizeof(var));
	vec_set(cloth_options[25],vector(-1,-1,0));  // external acceleration
	vec_set(cloth_options[28],vector(0,30,0));  // 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;
	
	pXent_cloth(cloth,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options);
	
	
}


Last edited by Malice; 10/26/15 23:29.
Re: can't open physic engine after physX_destroy [Re: ] #456331
11/19/15 03:13
11/19/15 03:13
Joined: May 2015
Posts: 2
G
Gtox4566 Offline
Guest
Gtox4566  Offline
Guest
G

Joined: May 2015
Posts: 2
Malice,
You are wonderful !
Ginny Pig

Re: can't open physic engine after physX_destroy [Re: Gtox4566] #456344
11/19/15 13:56
11/19/15 13:56

M
Malice
Unregistered
Malice
Unregistered
M



So are you Gtox4566.
Of course I am , I was created in a awesome factory and had extra awesomeness installed at birth. Making me twice as awesome as the average Malice.

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