… | |
… | |
137 | return false; |
137 | return false; |
138 | #endif |
138 | #endif |
139 | } |
139 | } |
140 | |
140 | |
141 | if (vs.state == OCCLUDED) |
141 | if (vs.state == OCCLUDED) |
|
|
142 | { |
|
|
143 | if (size ()) |
|
|
144 | ctx.vislist.push_back (this); |
142 | return false; |
145 | return false; |
|
|
146 | } |
143 | |
147 | |
144 | GLfloat z = ctx.z_near + distance (ctx.frustum.n, centerf) + rad; |
148 | GLfloat z = ctx.z_near + distance (ctx.frustum.n, centerf) + rad; |
145 | if (ctx.perspfact * extent / z < 1.) // very crude "too small to see" check |
149 | if (ctx.perspfact * extent / z < 1.) // very crude "too small to see" check |
146 | return false; |
150 | return false; |
147 | //printf ("z %f, perspfact %f, z*p %f\n", z, ctx.perspfact, ctx.perspfact / z); |
151 | //printf ("z %f, perspfact %f, z*p %f\n", z, ctx.perspfact, ctx.perspfact / z); |
… | |
… | |
207 | #endif |
211 | #endif |
208 | oct_visibility &vs = *(oct_visibility *)get_visibility (ctx); |
212 | oct_visibility &vs = *(oct_visibility *)get_visibility (ctx); |
209 | |
213 | |
210 | if (vs.state == OCCLUDED) |
214 | if (vs.state == OCCLUDED) |
211 | { |
215 | { |
212 | abort (); |
|
|
213 | if (ctx.pass == view::POSTDEPTH) |
216 | if (ctx.pass == view::POSTDEPTH) |
214 | { |
217 | { |
215 | ctx.begin_occ_query (*this, 0); |
218 | ctx.begin_occ_query (*this, 0); |
216 | sector s = orig - ctx.orig; |
219 | sector s = orig - ctx.orig; |
217 | gl::draw_bbox (s, s + extent); |
220 | gl::draw_bbox (s, s + extent); |
|
|
221 | printf ("bbox %Ld,%ld,%Ld\n", s.x, s.y, s.z); |
218 | ctx.end_occ_query (); |
222 | ctx.end_occ_query (); |
219 | } |
223 | } |
220 | } |
224 | } |
221 | else |
225 | else |
222 | { |
226 | { |
|
|
227 | int nvis = 0; |
|
|
228 | |
223 | for (iterator i = begin (); i != end (); ) |
229 | for (iterator i = begin (); i != end (); ) |
224 | { |
230 | { |
225 | entity *e = *i++; |
231 | entity *e = *i++; |
226 | |
232 | |
227 | if (!ctx.may_draw (e)) |
233 | if (!ctx.may_draw (e)) |
… | |
… | |
235 | { |
241 | { |
236 | ctx.begin_occ_query (*this, e); |
242 | ctx.begin_occ_query (*this, e); |
237 | gl::draw_bbox (e->a - ctx.orig, e->b - ctx.orig); |
243 | gl::draw_bbox (e->a - ctx.orig, e->b - ctx.orig); |
238 | ctx.end_occ_query (); |
244 | ctx.end_occ_query (); |
239 | } |
245 | } |
|
|
246 | else |
|
|
247 | nvis++; |
240 | } |
248 | } |
241 | else |
249 | else |
242 | { |
250 | { |
243 | if (evs.state != OCCLUDED) |
251 | if (evs.state != OCCLUDED) |
244 | { |
252 | { |
… | |
… | |
259 | ctx.end_occ_query (); |
267 | ctx.end_occ_query (); |
260 | } |
268 | } |
261 | } |
269 | } |
262 | } |
270 | } |
263 | } |
271 | } |
|
|
272 | |
|
|
273 | #if 0 |
|
|
274 | if (ctx.pass == view::POSTDEPTH && nvis == 0 && size ()) |
|
|
275 | vs.state = OCCLUDED; |
|
|
276 | #endif |
264 | } |
277 | } |
265 | } |
278 | } |
266 | |
279 | |
267 | void octant::event (occ_query &ev) |
280 | void octant::event (occ_query &ev) |
268 | { |
281 | { |
… | |
… | |
273 | { |
286 | { |
274 | evis &evs = vs.vismap[e]; |
287 | evis &evs = vs.vismap[e]; |
275 | evs.state = ev.count ? FULL : OCCLUDED; |
288 | evs.state = ev.count ? FULL : OCCLUDED; |
276 | } |
289 | } |
277 | else |
290 | else |
278 | { |
|
|
279 | //vs.state = ev.count ? FULL : OCCLUDED; |
291 | vs.state = ev.count ? FULL : OCCLUDED; |
280 | } |
|
|
281 | |
|
|
282 | #if 0 |
|
|
283 | visibility_state &vs = ev.v.vismap[this]; |
|
|
284 | |
|
|
285 | vs.last = timer.now; |
|
|
286 | vs.state = ev.r <= 0 |
|
|
287 | ? visibility_state::OCCLUDED |
|
|
288 | : visibility_state::FULL; |
|
|
289 | #endif |
|
|
290 | } |
292 | } |
291 | |
293 | |
292 | |
294 | |