forked from m0w1337/cyube3dit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AsyncRenderer.pbi
72 lines (70 loc) · 2.8 KB
/
AsyncRenderer.pbi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Procedure AsyncBuildChunk(chunknum, x, y, chunkx, chunky)
startz.f = 0
If(Not IsStaticGeometry(Chunknum))
CreateStaticGeometry(Chunknum, 32, 800, 32, #True)
EndIf
prevblock = -1
For z = 0 To 799
If(CurrChunkData(x,y,z) <> prevblock Or prevblock > 5)
If(prevblock > -1)
If(IsEntity(prevblock))
AddStaticGeometryEntity(Chunknum, EntityID(prevblock), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
ElseIf(prevblock = 15)
light = CreateLight(#PB_Any, RGB(255, 255, 150), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky)
LightAttenuation(light,25,1.5)
ElseIf(prevblock <> 3)
AddStaticGeometryEntity(Chunknum, EntityID(999), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
EndIf
EndIf
startz = z*0.5
scale = 1
Else
scale = scale + 1
EndIf
prevblock = CurrChunkData(x,y,z)
Next
If(prevblock > -1)
If(IsEntity(prevblock))
AddStaticGeometryEntity(Chunknum, EntityID(prevblock), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
ElseIf(prevblock <> 3)
AddStaticGeometryEntity(Chunknum, EntityID(999), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
EndIf
EndIf
EndProcedure
Procedure AsyncBuildChunkVertices(chunknum, x, y, chunkx, chunky)
startz.f = 0
If(Not IsStaticGeometry(Chunknum))
CreateStaticGeometry(Chunknum, 32, 800, 32, #True)
EndIf
prevblock = -1
For z = 0 To 799
If(CurrChunkData(x,y,z) <> prevblock Or prevblock > 5)
If(prevblock > -1)
If(IsEntity(prevblock))
AddStaticGeometryEntity(Chunknum, EntityID(prevblock), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
ElseIf(prevblock = 15)
;light = CreateLight(#PB_Any, RGB(255, 255, 150), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky)
;LightAttenuation(light,25,1.5)
ElseIf(prevblock <> 3)
AddStaticGeometryEntity(Chunknum, EntityID(999), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
EndIf
EndIf
startz = z*0.5
scale = 1
Else
scale = scale + 1
EndIf
prevblock = CurrChunkData(x,y,z)
Next
If(prevblock > -1)
If(IsEntity(prevblock))
AddStaticGeometryEntity(Chunknum, EntityID(prevblock), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
ElseIf(prevblock <> 3)
AddStaticGeometryEntity(Chunknum, EntityID(999), (x*0.5-15) + chunkx,startz+(scale-1)*0.25,(y*0.5-16) + chunky,1,scale,1)
EndIf
EndIf
EndProcedure
; IDE Options = PureBasic 5.60 (Windows - x64)
; CursorPosition = 33
; Folding = -
; EnableXP