Skip to content

Commit

Permalink
Merge pull request #55 from CloudScorpion/master
Browse files Browse the repository at this point in the history
Octree tests are working again
  • Loading branch information
cjcliffe committed Dec 12, 2011
2 parents 51ebc56 + a314059 commit b286638
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
16 changes: 8 additions & 8 deletions source/CubicVR.Scene.js
Expand Up @@ -889,11 +889,11 @@ CubicVR.RegisterModule("Scene", function (base) {
lights = lights.concat(scene_object.static_lights);
lights = lights.concat(this.global_lights);
if (this.collect_stats) {
lights_rendered = Math.max(lights.length, lights_rendered);
if (lights_rendered === lights.length) {
this.lights_rendered = Math.max(lights.length, this.lights_rendered);
if (this.lights_rendered === lights.length) {
lights_list = lights;
} //if
++objects_rendered;
++this.objects_rendered;
} //if
if (lights.length === 0) {
lights = [GLCore.emptyLight];
Expand Down Expand Up @@ -1004,7 +1004,7 @@ CubicVR.RegisterModule("Scene", function (base) {
var frustum_hits;

var use_octree = this.octree !== undef;
var lights_rendered = 0;
this.lights_rendered = 0;
if (use_octree) {
// for (var i = 0, l = this.dynamic_lights.length; i < l; ++i) {
// var light = this.dynamic_lights[i];
Expand All @@ -1013,7 +1013,7 @@ CubicVR.RegisterModule("Scene", function (base) {
this.octree.reset_node_visibility();
this.octree.cleanup();
frustum_hits = this.octree.get_frustum_hits(this.camera);
lights_rendered = frustum_hits.lights.length;
this.lights_rendered = frustum_hits.lights.length;
} //if

this.doTransform();
Expand All @@ -1030,7 +1030,7 @@ CubicVR.RegisterModule("Scene", function (base) {
light.prepare(this.camera);
}

var objects_rendered = 0;
this.objects_rendered = 0;
var lights_list = [];
var transparencies = [];
var lights = this.lights;
Expand All @@ -1051,8 +1051,8 @@ CubicVR.RegisterModule("Scene", function (base) {
}

if (this.collect_stats) {
this.stats['objects.num_rendered'] = objects_rendered;
this.stats['lights.num_rendered'] = lights_rendered;
this.stats['objects.num_rendered'] = this.objects_rendered;
this.stats['lights.num_rendered'] = this.lights_rendered;
this.stats['lights.rendered'] = lights_list;
this.stats['lights.num_global'] = this.global_lights.length;
this.stats['lights.num_dynamic'] = this.dynamic_lights.length;
Expand Down
6 changes: 4 additions & 2 deletions tests/octree/octree.html
Expand Up @@ -144,8 +144,10 @@
{
map_context.fillStyle = "#000000";
map_context.fillRect(0, 0, 400, 400);
scene.octree.draw_on_map(map_context);
scene.camera.frustum.draw_on_map(map_context);
scene.octree.draw_on_map(map_canvas, map_context, "map");
scene.octree.draw_on_map(map_canvas, map_context, "objects");
scene.octree.draw_on_map(map_canvas, map_context, "lights");
scene.camera.frustum.draw_on_map(map_canvas, map_context);
} //if

scene.camera.target = [Math.sin(xp), 0, Math.cos(xp)];
Expand Down
6 changes: 4 additions & 2 deletions tests/octree/octree_destroy.html
Expand Up @@ -155,8 +155,10 @@
{
map_context.fillStyle = "#000000";
map_context.fillRect(0, 0, 400, 400);
scene.octree.draw_on_map(map_context);
scene.camera.frustum.draw_on_map(map_context);
scene.octree.draw_on_map(map_canvas, map_context, "map");
scene.octree.draw_on_map(map_canvas, map_context, "objects");
scene.octree.draw_on_map(map_canvas, map_context, "lights");
scene.camera.frustum.draw_on_map(map_canvas, map_context);
} //if

scene.camera.target = [Math.sin(xp), 0, Math.cos(xp)];
Expand Down
6 changes: 4 additions & 2 deletions tests/octree/octree_move.html
Expand Up @@ -160,8 +160,10 @@
{
map_context.fillStyle = "#000000";
map_context.fillRect(0, 0, 400, 400);
scene.octree.draw_on_map(map_context);
scene.camera.frustum.draw_on_map(map_context);
scene.octree.draw_on_map(map_canvas, map_context, "map");
scene.octree.draw_on_map(map_canvas, map_context, "objects");
scene.octree.draw_on_map(map_canvas, map_context, "lights");
scene.camera.frustum.draw_on_map(map_canvas, map_context);
} //if

scene.camera.target = [Math.sin(xp), 0, Math.cos(xp)];
Expand Down

0 comments on commit b286638

Please sign in to comment.