Returning modified data from a forked ISECT test

New Message Reply Date view Thread view Subject view Author view

Peter Smithies (modellers++at++intersim.co.uk)
Fri, 31 Oct 1997 09:39:19 +0000


Hi All,

I am having problems returning data from a forked ISECT process.
After using pfPassIsectData to copy data used by an intersection
function I am assuming a call to pfGetIsectData will transfer data
modified
by the intersection function back to the APP data structure .
However upon inspection of the data returned, nothing has changed even
although I most definitely changed the data (see example source test.c).

Is pfGetIsectData the right funtion to transfer the data back or am I
missing something here.

Whilst on the performer subject ,this one must surely have been asked.
Why does the system lock when I try to pfuLockDown - (APP,CULL,DRAW
p=1,2,3)-
on our InfiniteReality ? I also try to pfuRunProcOn the ISECT stage on
p0.
I asked SG's Clive Harding who's investigating and he could repeat the
problem
with perfly so it's not just me. This problem does not occur on a RE2
machine.

-- 

Peter Smithies, Software Engineer, Intersim Limited, Units 7-8, Thorgate Road, Littlehampton. Sussex. UK Tel: +44 (0)1903 733428 Fax: +44 (0)1903 730246 email: modellers++at++intersim.co.uk Internet: http://www.intersim.co.uk

/*--------------------- This file tests doing isect code as a forked process ---------------------*/

/*----------------------------------------------------------------------*/

/*----------------*/ /* Include Files */ /*----------------*/

/* Performer includes*/ #include <Performer/pf.h> #include <Performer/pr.h> #include <Performer/pfui.h> #include <Performer/pfutil.h> #include <Performer/pfdu.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <bstring.h> #include <math.h> #include <unistd.h>

#ifdef IRISGL #include <gl.h> #endif

/*----------------*/ /* Defines */ /*----------------*/

#define COL_IDLE 0 #define COL_BUSY 1 #define COL_DONE 2

/*----------------*/ /* Typedefs */ /*----------------*/

typedef struct {

unsigned char ready; unsigned char enable; unsigned char spare[6];

} collision_info;

/*--------------------*/ /* External Routines */ /*--------------------*/

extern void COL_isectfunc(void *data);

/*----------------*/ /* Externals */ /*----------------*/

/*----------------*/ /* Globals */ /*----------------*/

collision_info *MA_Coll_model = NULL;

/*-----------------*/ /* Local Variables */ /*-----------------*/

static int Collide = TRUE;

/*--------------------*/ /* Forward References */ /*--------------------*/

static void Setup_coll_model( collision_info *coll_model); static void Respond_to_collisions( collision_info *coll_model ); static void Post_frame(void); static void Pre_frame(void); static void Init_coll_position( collision_info *coll_model); static void Update_collision_model(collision_info *coll_model); static void Isectfunc(void *data);

/*--------------------------------------------------------------------------*/

static void InitConfig(void) { /* Set multiprocessing mode. */ /* Default will automatically fork isect, if possible, if pfIsectFunc is called before pfConfig */ //pfMultiprocess(PFMP_DEFAULT); pfMultiprocess(PFMP_APP_CULL_DRAW | PFMP_FORK_ISECT); // which should be as PFMP_DEFAULT if certain conditions are met /* Set intersection callback. */

pfIsectFunc(Isectfunc); MA_Coll_model = (collision_info*) pfAllocIsectData( sizeof(collision_info) ); printf("Pointer to coll data = %p\n",MA_Coll_model); }

/*--------------------------------------------------------------------------*/ typedef struct { int coll_set; // we wont change isect data if this is set } SharedState; SharedState *pState;

int main(int argc, char *argv[]) { pfVec3 view_xyz; pfVec3 view_hpr; pfScene *scene; pfChannel *chan; pfPipe *p; pfPipeWindow *pw; float t; printf("\n=========================================="); printf("\n"); printf("\nTest of isect as forked bkground task" ); printf("\n"); printf("\n==========================================\n\n"); fflush ( stdout ); pfInit();

InitConfig(); pState = (SharedState*)pfCalloc(1, sizeof(SharedState), pfGetSharedArena()); pState->coll_set = 0;

pfConfig();

/* Basic initialization */ Collide = TRUE;

/*InitScene*/ scene = pfNewScene(); /*InitPipe*/ p = pfGetPipe(0);

pw = pfNewPWin (p); pfPWinType (pw, PFPWIN_TYPE_X); pfPWinName (pw, "Test of isect as forked bkground task"); pfPWinOriginSize (pw, 0, 0, 500,500); pfOpenPWin (pw); /*InitChannel*/ chan = pfNewChan(p); pfChanScene(chan, scene); pfChanFOV(chan, 45.0f, 0.0f); pfChanNearFar(chan, 1.0f, 2000.0f); if (scene) { if (!MA_Coll_model) { printf("\nERROR: Null Collision model to setup"); fflush(stdout); } else Setup_coll_model( MA_Coll_model ); }

pfInitClock(0.0f);

Init_coll_position( MA_Coll_model );

pfSetVec3 (view_xyz, 0.0f, 0.0f, 50.0f); pfSetVec3 (view_hpr, 0.0f, -90.0f, 0.0f);

while ( t < 20.0f) { pfSync(); Pre_frame(); pfFrame(); Post_frame();

pfChanView (chan, view_xyz, view_hpr);

t = pfGetTime(); }

pfuExitUtil(); pfExit();

return 0; }

/*------------------------------------------------------------------------------------------*/

static void Post_frame() {

if (pState->coll_set == 1) // if this is set then MA_Coll_model->ready should be set as COL_DONE in isect func {

// ok isect stuff should be set reread it into buffer via pfGetIsectData(); ? MA_Coll_model = (collision_info *) pfGetIsectData(); // does not work if ISECT is forked if("\nPost Frame pstate is %d coll_model->ready is %d (should be %d after pfGetIsectData()? )\n",pState->coll_set,MA_Coll_model->ready,COL_DONE); Respond_to_collisions(MA_Coll_model); pState->coll_set = 0; } }

/*------------------------------------------------------------------------------------------*/

static void Pre_frame(void) { if(pState->coll_set == 0) { Update_collision_model(MA_Coll_model); pfPassIsectData(); } }

/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

static void Setup_coll_model( collision_info *coll_model) {

coll_model->ready = COL_IDLE; coll_model->enable = Collide;

return; }

/*--------------------------------------------------------------------------*/

/* Called by sync task */

static void Respond_to_collisions( collision_info *coll_model ) { printf("\nRespond: coll_model->ready = %d", coll_model->ready); fflush(stdout);

if (coll_model->ready == COL_DONE) /* A collision detection completed by async task */ { ; } /* End of ready (ie async finished) */

if (coll_model->ready == COL_DONE) { coll_model->ready = COL_IDLE; /* TODO: Put this inside previous condition! */ }

}

/*--------------------------------------------------------------------------*/

static void Init_coll_position( collision_info *coll_model ) { ; }

/*--------------------------------------------------------------------------*/

static void Update_collision_model(collision_info *coll_model) { printf("\nUpdate: ready = %d", coll_model->ready); fflush(stdout);

if (coll_model->ready == COL_IDLE) { if (Collide) coll_model->enable = TRUE; else coll_model->enable = FALSE; }

}

/*--------------------------------------------------------------------------*/

/* Called from pfIsectFunc. This is done in background. */

static void Isectfunc(void *data) { collision_info *coll_model;

coll_model = (collision_info *) data;

printf("\nIsectfunc, ready = %d", coll_model->ready); fflush(stdout); if (coll_model->ready == COL_DONE) { return; }

if (!coll_model->enable) { return; } coll_model->ready = COL_DONE; /* Reset in synchronous loop */ pState->coll_set = 1; printf("\nSetting ready to COL_DONE (%d)",coll_model->ready); fflush(stdout); return; }

/*--------------------------------------------------------------------------*/

======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:09 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.