1 registered members (AndrewAMD),
1,203
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
CodeMaster
OP
Junior Member
|
OP
Junior Member
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
#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
|
Malice
Unregistered
|
Malice
Unregistered
|
Good New I found your error 1513 in physX_open. It has nothing to do with physX_open()
#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
|
Malice
Unregistered
|
Malice
Unregistered
|
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
|
Malice
Unregistered
|
Malice
Unregistered
|
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
// 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- 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: CodeMaster]
#455651
10/26/15 18:54
10/26/15 18:54
|
Malice
Unregistered
|
Malice
Unregistered
|
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
|
Malice
Unregistered
|
Malice
Unregistered
|
#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
CodeMaster
OP
Junior Member
|
OP
Junior Member
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
|
Malice
Unregistered
|
Malice
Unregistered
|
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_cloneNope - 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
|
Malice
Unregistered
|
Malice
Unregistered
|
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
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.
|
|
|
|