-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpaged_lod.go
188 lines (167 loc) · 4.86 KB
/
paged_lod.go
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package osg
import (
"github.com/flywave/go-osg/model"
)
func checkDatabasePath(obj interface{}) bool {
return true
}
func readDatabasePath(is *OsgIstream, obj interface{}) {
lod := obj.(*model.PagedLod)
hasp := false
is.Read(&hasp)
if !hasp {
if len(is.Options.DbPath) > 0 {
lod.DataBasePath = is.Options.DbPath
}
} else {
is.ReadWrappedString(&lod.DataBasePath)
}
}
func writeDatabasePath(os *OsgOstream, obj interface{}) {
lod := obj.(*model.PagedLod)
b := len(lod.DataBasePath) > 0
os.Write(b)
if b {
os.Write(&lod.DataBasePath)
}
os.Write(os.CRLF)
}
func setFrameNumberOfLastTraversal(obj interface{}, pro interface{}) {
obj.(*model.PagedLod).FrameNumberOfLastTraversal = pro.(uint32)
}
func getFrameNumberOfLastTraversal(obj interface{}) interface{} {
return &obj.(*model.PagedLod).FrameNumberOfLastTraversal
}
func setNumChildrenThatCannotBeExpired(obj interface{}, pro interface{}) {
obj.(*model.PagedLod).NumChildrenThatCannotBeExpired = pro.(uint32)
}
func getNumChildrenThatCannotBeExpired(obj interface{}) interface{} {
return &obj.(*model.PagedLod).NumChildrenThatCannotBeExpired
}
func setDisableExternalChildrenPaging(obj interface{}, pro interface{}) {
obj.(*model.PagedLod).DisableExternalChildrenPaging = pro.(bool)
}
func getDisableExternalChildrenPaging(obj interface{}) interface{} {
return &obj.(*model.PagedLod).DisableExternalChildrenPaging
}
func checkRangeDataList(obj interface{}) bool {
lod := obj.(*model.PagedLod)
return len(lod.PerRangeDataList) > 0
}
func readRangeDataList(is *OsgIstream, obj interface{}) {
lod := obj.(*model.PagedLod)
size := is.ReadSize()
is.Read(is.BEGINBRACKET)
lod.PerRangeDataList = make([]model.PerRangeData, size, size)
for i := 0; i < size; i++ {
var str string
is.ReadWrappedString(&str)
lod.SetFileName(i, str)
}
is.Read(is.ENDBRACKET)
is.PROPERTY.Name = "PriorityList"
is.Read(is.PROPERTY)
size = is.ReadSize()
is.Read(is.BEGINBRACKET)
for i := 0; i < size; i++ {
var off, scale float32
is.Read(&off)
is.Read(&scale)
lod.SetPriorityOffset(i, off)
lod.SetPriorityOffset(i, scale)
}
is.Read(is.ENDBRACKET)
}
func writeRangeDataList(os *OsgOstream, obj interface{}) {
lod := obj.(*model.PagedLod)
l := len(lod.PerRangeDataList)
os.Write(l)
os.Write(os.BEGINBRACKET)
os.Write(os.CRLF)
for _, per := range lod.PerRangeDataList {
os.Write(per.FileName)
}
os.Write(os.CRLF)
os.Write(os.ENDBRACKET)
os.Write(os.CRLF)
os.PROPERTY.Name = "PriorityList"
os.Write(os.PROPERTY)
os.Write(l)
os.Write(os.BEGINBRACKET)
os.Write(os.CRLF)
for _, per := range lod.PerRangeDataList {
os.Write(per.PriorityOffset)
os.Write(per.PriorityScale)
os.Write(os.CRLF)
}
os.Write(os.ENDBRACKET)
os.Write(os.CRLF)
}
func checkChildren(obj interface{}) bool {
lod := obj.(*model.PagedLod)
return len(lod.Children) > 0
}
func readChildren(is *OsgIstream, obj interface{}) {
lod := obj.(*model.PagedLod)
size := is.ReadSize()
if size > 0 {
is.Read(is.BEGINBRACKET)
for i := 0; i < size; i++ {
ob := is.ReadObject(nil)
nd, ok := ob.(model.NodeInterface)
if ok {
lod.AddChild(nd)
}
}
}
is.Read(is.ENDBRACKET)
}
func writeChildren(os *OsgOstream, obj interface{}) {
lod := obj.(*model.PagedLod)
size := len(lod.PerRangeDataList)
dynamicLoadedSize := 0
for _, per := range lod.PerRangeDataList {
if len(per.FileName) > 0 {
dynamicLoadedSize++
}
}
realSize := size - dynamicLoadedSize
if realSize > 0 {
os.Write(os.BEGINBRACKET)
os.Write(os.CRLF)
for i, per := range lod.PerRangeDataList {
if len(per.FileName) > 0 {
continue
}
if i < len(lod.Children) {
os.Write(lod.Children[i])
}
}
os.Write(os.ENDBRACKET)
}
}
func init() {
fn := func() interface{} {
pl := model.NewPagedLod()
return pl
}
wrap := NewObjectWrapper("PagedLOD", fn, "osg::Object osg::Node osg::LOD osg::PagedLOD")
ser1 := NewUserSerializer("DatabasePath", checkDatabasePath, readDatabasePath, writeDatabasePath)
ser2 := NewPropByValSerializer("FrameNumberOfLastTraversal", false, getFrameNumberOfLastTraversal, setFrameNumberOfLastTraversal)
ser3 := NewPropByValSerializer("NumChildrenThatCannotBeExpired", false, getNumChildrenThatCannotBeExpired, setNumChildrenThatCannotBeExpired)
ser4 := NewPropByValSerializer("DisableExternalChildrenPaging", false, getDisableExternalChildrenPaging, setDisableExternalChildrenPaging)
ser5 := NewUserSerializer("RangeDataList", checkRangeDataList, readRangeDataList, writeRangeDataList)
ser6 := NewUserSerializer("Children", checkChildren, readChildren, writeChildren)
wrap.AddSerializer(ser1, RWUSER)
wrap.AddSerializer(ser2, RWUINT)
wrap.AddSerializer(ser3, RWUINT)
wrap.AddSerializer(ser4, RWBOOL)
wrap.AddSerializer(ser5, RWUSER)
wrap.AddSerializer(ser6, RWUSER)
{
uv := AddUpdateWrapperVersionProxy(wrap, 70)
wrap.MarkSerializerAsRemoved("FrameNumberOfLastTraversal")
uv.SetLastVersion()
}
GetObjectWrapperManager().AddWrap(wrap)
}