mesh vert/tri limit?
Blitz3D Forums/Blitz3D Programming/mesh vert/tri limit?
| ||
Hi I know there's a 65536 vert and tri limit for each surface in a mesh but is there an overall limit for the entire mesh? I'm trying to stuff a load of stuff into a single mesh - creating a new surface when the current gets full - but get a MAV on RenderWorld when I hit some limit. If there is an overall vert limit per mesh, nayone know what it is? Cheers! |
| ||
Hi, Try this: Graphics3D 640,480,0,2 SetBuffer BackBuffer() mesh = CreateMesh() surf = CreateSurface(mesh) count = 0 camera = CreateCamera() Repeat v0 = AddVertex(surf,Rnd(-10,10),Rnd(-10,10),Rnd(100,1000)) v1 = v0-1 v2 = v0-2 If v1<0 Then v1 = 0 If v2<0 Then v2 = 0 t = AddTriangle(surf,v0,v1,v2) If v0=>65535 Or t=>65535 surf = CreateSurface(mesh) count = count + v0 + 1 EndIf If (v0 Mod 1000) = 0 RenderWorld Text 0,0,count+v0+1 Flip False End If Until KeyHit(1) EndI get a memory access violation when I hit 61000 poly's...Strange! But with this, it keeps on going: Graphics3D 640,480,0,2 SetBuffer BackBuffer() mesh = CreateMesh() surf = CreateSurface(mesh) PositionEntity mesh,0,0,100 count = 0 camera = CreateCamera() Repeat v0 = AddVertex(surf,Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)) v1 = v0-1 v2 = v0-2 If v1<0 Then v1 = 0 If v2<0 Then v2 = 0 t = AddTriangle(surf,v0,v1,v2) If v0=>32767 Or t=>32767 surf = CreateSurface(mesh) count = count + v0 + 1 EndIf If (v0 Mod 1000) = 0 TurnEntity mesh,1,1,1 RenderWorld Text 0,0,count+v0+1 Flip False End If Until KeyHit(1) EndI think it uses signed shorts to store triangles, which means the limit is effectively 32768 tri's per surface. I don't know who signed the shorts though, and quite how you store triangles with signed shorts is still somewhat of a mystery to me. Correct me if I'm wrong! |
| ||
61001 is the last value displayed. But the debugger shows that v0 actually reached 62000. I always thought the limit was 2^16. Looks like it is a little less. |
| ||
The limit is: 61223 for some obscure reason. No signed shorts then :) Hmmm, no it isn't I think the limit is actually 32768. If you change the 'mod 1000' to 'mod 100' the MAV happens at a different triangle count... This works always: Graphics3D 640,480,0,2 SetBuffer BackBuffer() mesh = CreateMesh() surf = CreateSurface(mesh) PositionEntity mesh,0,0,100 count = 0 camera = CreateCamera() Repeat While t<32768 v0 = AddVertex(surf,Rnd(-10,10),Rnd(-10,10),Rnd(-10,10)) v1 = v0-1 v2 = v0-2 If v1<0 Then v1 = 0 If v2<0 Then v2 = 0 t = AddTriangle(surf,v0,v1,v2) Wend surf = CreateSurface(mesh) count = count + t + 1 t = 0 TurnEntity mesh,1,1,1 RenderWorld Text 0,0,count Flip False Until KeyHit(1) End |
| ||
Wow, that was a quick response, Fredborg! ;) I don't think signed shorts are being used to store triangles because the max I can get the surface triangle count up to is 61223 - 61224 gets a MAV. Then, I thought maybe the top couple of bits are being used as flags of somesort but 61223 in binary is 1110111100100111, so that idea's out. This makes no sense to me - I wonder what's going on? |
| ||
Yeah, it's weird. If you change:If (v0 Mod 1000) = 0to: If (v0 Mod 100) = 0In the top code example. I get a MAV when it reaches 47201. If you change it to 'Mod 10' I get a crash at 53931, So I think it's just some weird thing that let's it go beyond 32768. Maybe not, but 32768 seems to be crash proof :) |
| ||
Hmm, but if you change 32768 to 65534 in the new code (without the mod), everything seems OK. 65535 crashes! :/ |
| ||
But obviously that can't be right as it crashes some of the previous examples :) |
| ||
Oh yeah! I have the memory of a goldfish. :) |
| ||
If anyone is not confused enough:Const MagicNumber = 43700 ; try 43600 SeedRnd MilliSecs() Graphics3D 640,480,0,2 SetBuffer BackBuffer() mesh = CreateMesh() surf = CreateSurface(mesh) count = 0 camera = CreateCamera() Repeat v0 = AddVertex(surf,Rnd(-10,10),Rnd(-10,10),Rnd(100,1000)) v1 = AddVertex(surf,Rnd(-10,10),Rnd(-10,10),Rnd(100,1000)) v2 = AddVertex(surf,Rnd(-10,10),Rnd(-10,10),Rnd(100,1000)) t = AddTriangle(surf,v0,v1,v2) If v0 > MagicNumber RenderWorld Text 0,0,"v0 = " + v0 Text 0,20," t = " + t Flip False End If Until KeyHit(1) End When I start rendering at 43700 the program dies immediately. But starting from 43600 it goes all the way to 65406. |
| ||
...and even more confusion:Const MagicNumber = 43700 ; try 43600 SeedRnd MilliSecs() Graphics3D 640,480,0,2 SetBuffer BackBuffer() mesh = CreateMesh() surf = CreateSurface(mesh) count = 0 camera = CreateCamera() foo# = .1 ; .1 causes crash but 1.0 or 1.1 dont! Repeat v0 = AddVertex(surf,foo,1,1) v1 = AddVertex(surf,1,foo,1) v2 = AddVertex(surf,1,1,foo) t = AddTriangle(surf,v0,v1,v2) If v0 > MagicNumber RenderWorld Text 0,0,"v0 = " + v0 Text 0,20," t = " + t Flip False End If Until KeyHit(1) End The position the verts are placed at seems to make a difference. :/ |
| ||
Whee! Up is down! Left is right! Night is day! |
| ||
heh, never ceases to amaze me how the pure logic of computers often seems to be so illogical. :/ |