if(!camera)
return false;
- const Matrix &matrix = camera->get_object_matrix();
+ culling_matrix = renderer.get_matrix();
float y = tan(camera->get_field_of_view()/2.0f);
float s = sqrt(y*y+1);
- frustum_edges[0] = matrix*Vector4(0, 1/s, y/s, 0);
- frustum_edges[1] = matrix*Vector4(0, -1/s, y/s, 0);
+ frustum_edges[0] = Vector4(0, 1/s, y/s, 0);
+ frustum_edges[1] = Vector4(0, -1/s, y/s, 0);
float x = y*camera->get_aspect();
s = sqrt(x*x+1);
- frustum_edges[2] = matrix*Vector4(1/s, 0, x/s, 0);
- frustum_edges[3] = matrix*Vector4(-1/s, 0, x/s, 0);
+ frustum_edges[2] = Vector4(1/s, 0, x/s, 0);
+ frustum_edges[3] = Vector4(-1/s, 0, x/s, 0);
- const Vector3 &camera_pos = camera->get_position();
- Vector4 pos4 = compose(camera_pos, 0.0f);
- for(unsigned i=0; i<4; ++i)
- frustum_edges[i].w = -inner_product(frustum_edges[i], pos4);
-
- const Vector3 &look_dir = camera->get_look_direction();
- frustum_edges[4] = compose(look_dir, -dot(camera_pos, look_dir)-camera->get_far_clip());
- frustum_edges[5] = compose(-look_dir, dot(camera_pos, look_dir)+camera->get_near_clip());
+ frustum_edges[4] = Vector4(0, 0, -1, -camera->get_far_clip());
+ frustum_edges[5] = Vector4(0, 0, 1, camera->get_near_clip());
return true;
}
if(!matrix || !bsphere)
return false;
- Vector4 center = *matrix*compose(bsphere->get_center(), 1.0f);
+ Vector4 center = culling_matrix*(*matrix*compose(bsphere->get_center(), 1.0f));
float radius = bsphere->get_radius();
for(unsigned i=0; i<6; ++i)