Path: chuka.playstation.co.uk!news From: sosman@terratron.com (Steven Osman) Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Elevation data Date: Wed, 08 Dec 1999 22:50:06 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 89 Message-ID: <384eda83.10073394@news.playstation.co.uk> References: <82luhc$6qr1@chuka.playstation.co.uk> NNTP-Posting-Host: 209.27.57.69 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 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); > } > > > > >