Path: chuka.playstation.co.uk!news From: "Matthew Hardingham" Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Elevation data Date: Thu, 9 Dec 1999 21:31:37 -0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 99 Message-ID: <82p7ct$7rp2@chuka.playstation.co.uk> References: <82luhc$6qr1@chuka.playstation.co.uk> <384eda83.10073394@news.playstation.co.uk> NNTP-Posting-Host: modem-14.verapamil.dialup.pol.co.uk X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Cheers for that but for some reason it's now working ! odd that I still don't know what caused it. Matt Steven Osman wrote in message news:384eda83.10073394@news.playstation.co.uk... > You're performing 16384 memory allocations, I wonder if that has > anything to do with it. Maybe the compiler's memory manager isn't the > most efficient. > > I also wouldn't be surprised if your printf is the problem (did you > put that in afterwards?) You are printing out 16384 lines also! > > An extremely trivial point (incidentally)... This line: > > NewVert->Next = NULL; > > is redundant > > > Steven > > > On Wed, 8 Dec 1999 15:40:58 -0000, "Matthew Hardingham" > wrote: > > >Right here we go then, > > > >At the moment I have a set of elevation points stored in an array (128x128) > >from this I'm creating a link list of vertices. > >For some reason it is running very slow or the program is crashing out. > >Why ? > >It's bugging me me now. > > > >Here's the vertex structure -- > > > > /* Vertex list */ > > typedef struct Vertex { > > unsigned short IdxX, IdxZ; > > VECTOR Vert; /* Vector */ > > struct Vertex *Next; > > } VERTEX; > > > > > >Heres a snippet of code where the elevation data is extracted from the > >array -- > > > > /* Loop through the mesh */ > > for(MeshZ=0; MeshZ > { > > for(MeshX=0; MeshX > { > > NewVert = AllocateVertex(); > > > > NewVert->IdxX = BlockX; > > NewVert->IdxZ = BlockZ; > > > > printf("\n Z - %ld X - %ld", MeshZ, MeshX); > > > > /* Set vertices values */ > > NewVert->Vert.vx = (MeshX*MESH_INTERVAL); > > NewVert->Vert.vy = HeightArray[MeshZ][MeshX]; > > NewVert->Vert.vz = (MeshZ*MESH_INTERVAL); > > > > /* Change the pointers and link list positions */ > > CurrentVert->Next = NewVert; > > NewVert->Next = NULL; > > CurrentVert = NewVert; > > } > > } > > > >Here's the allocation part --- > > > > /* Vertex memory allocation */ > > VERTEX *AllocateVertex(void) > > { > > VERTEX *V = NULL; > > > > V = (VERTEX *)malloc(sizeof(VERTEX)); > > > > V->IdxX = 0; V->IdxZ = 0; > > > > /* Vertice values */ > > V->Vert.vx = 0; V->Vert.vy = 0; V->Vert.vz = 0; > > > > V->Next = NULL; > > > > return(V); > > } > > > > > > > > > > >