if(!camera)
return SimpleScene::render(renderer, tag);
- const Matrix &view_matrix = camera->get_matrix();
-
std::vector<DepthRenderable> sorted_renderables;
sorted_renderables.reserve(renderables.size());
- float radius_factor = 1.0f-reference;
- float sign = order*2.0f-1.0f;
+ const Vector3 &camera_pos = camera->get_position();
+ const Vector3 &look_dir = camera->get_look_direction();
+ float radius_factor = reference-1.0f;
+ float sign = 1.0f-order*2.0f;
bool use_frustum = setup_frustum(renderer);
for(RenderableSet::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
if(const Matrix *model_matrix = (*i)->get_matrix())
{
if(const Geometry::BoundingSphere<float, 3> *bsphere = (*i)->get_bounding_sphere())
- z = (view_matrix**model_matrix*compose(bsphere->get_center(), 1.0f)).z+bsphere->get_radius()*radius_factor;
+ z = dot(*model_matrix*bsphere->get_center()-camera_pos, look_dir)+bsphere->get_radius()*radius_factor;
else
- z = (view_matrix**model_matrix*Vector4(0.0f, 0.0f, 0.0f, 1.0f)).z;
+ z = dot(*model_matrix*Vector3()-camera_pos, look_dir);
}
sorted_renderables.push_back(DepthRenderable(z*sign, *i));
}