animation bounding box only shows with boxes enabled

This commit is contained in:
T1ti
2024-10-20 03:55:42 +02:00
parent 5bb1ff6cbe
commit a49909c945
6 changed files with 29 additions and 11 deletions

View File

@@ -3525,6 +3525,12 @@ void MapView::draw_map()
cursorColor = draw_parameters.cursor_color; cursorColor = draw_parameters.cursor_color;
minimapRenderSettings = draw_parameters.minimapRenderSettings; minimapRenderSettings = draw_parameters.minimapRenderSettings;
bool debug_cam = _debug_cam_mode.get();
// math::frustum frustum(model_view(debug_cam) * projection());
_model_view = model_view(debug_cam);
_projection = projection();
//! \note Select terrain below mouse, if no item selected or the item is map. //! \note Select terrain below mouse, if no item selected or the item is map.
if (!(_world->has_selection() if (!(_world->has_selection()
|| _locked_cursor_mode.get())) || _locked_cursor_mode.get()))
@@ -3539,8 +3545,7 @@ void MapView::draw_map()
bool show_unpaintable = _classic_ui ? show_unpaintable_chunks : _left_sec_toolbar->showUnpaintableChunk(); bool show_unpaintable = _classic_ui ? show_unpaintable_chunks : _left_sec_toolbar->showUnpaintableChunk();
bool debug_cam = _debug_cam_mode.get();
// math::frustum frustum(model_view(debug_cam) * projection());
WorldRenderParams renderParams; WorldRenderParams renderParams;
@@ -3582,9 +3587,6 @@ void MapView::draw_map()
renderParams.render_select_wmo_aabb = _render_wmo_aabb; renderParams.render_select_wmo_aabb = _render_wmo_aabb;
renderParams.render_select_wmo_groups_bounds = _render_wmo_groups_bounds; renderParams.render_select_wmo_groups_bounds = _render_wmo_groups_bounds;
_model_view = model_view(debug_cam);
_projection = projection();
_world->renderer()->draw ( _world->renderer()->draw (
_model_view _model_view
, _projection , _projection

View File

@@ -87,13 +87,13 @@ void ModelInstance::draw_box (glm::mat4x4 const& model_view
// animated bounding box // animated bounding box
// worldRnder already draws it for any model with mesh_bounds_ratio < 0.3 // worldRnder already draws it for any model with mesh_bounds_ratio < 0.3
if (draw_anim_bb && model->mesh_bounds_ratio > 0.3f && model->mesh_bounds_ratio < 0.5f) if (draw_anim_bb && model->mesh_bounds_ratio < 0.5f)
{ {
auto animated_bb = model->getAnimatedBoundingBox(); auto animated_bb = model->getAnimatedBoundingBox();
Noggit::Rendering::Primitives::WireBox::getInstance(_context).draw(model_view Noggit::Rendering::Primitives::WireBox::getInstance(_context).draw(model_view
, projection , projection
, transformMatrix() , transformMatrix()
, { 0.6f, 0.6f, 0.6f, 0.6f } // gray , { 0.6f, 0.6f, 0.6f, 1.0f } // gray
, animated_bb[0] , animated_bb[0]
, animated_bb[1] , animated_bb[1]
); );

View File

@@ -162,6 +162,7 @@ void ModelRender::draw(glm::mat4x4 const& model_view
, bool no_cull , bool no_cull
, bool animate , bool animate
, bool draw_fake_geometry_box , bool draw_fake_geometry_box
, bool draw_animation_box
) )
{ {
ZoneScopedN(NOGGIT_CURRENT_FUNCTION); ZoneScopedN(NOGGIT_CURRENT_FUNCTION);
@@ -203,6 +204,11 @@ void ModelRender::draw(glm::mat4x4 const& model_view
if (all_boxes || _model->_hidden ) if (all_boxes || _model->_hidden )
{ {
model_boxes_to_draw.emplace(_model, instances.size()); model_boxes_to_draw.emplace(_model, instances.size());
if (draw_animation_box)
{
}
} }
else if (draw_fake_geometry_box && _model->use_fake_geometry() /*|| _model->particles_only()*/) else if (draw_fake_geometry_box && _model->use_fake_geometry() /*|| _model->particles_only()*/)
{ // hackfix for rendering particle only objects bounds as they currently don't render { // hackfix for rendering particle only objects bounds as they currently don't render

View File

@@ -135,6 +135,7 @@ namespace Noggit::Rendering
, bool no_cull , bool no_cull
, bool animate , bool animate
, bool draw_fake_geometry_box , bool draw_fake_geometry_box
, bool draw_animation_box
); );
void drawParticles(glm::mat4x4 const& model_view void drawParticles(glm::mat4x4 const& model_view

View File

@@ -811,6 +811,8 @@ void WorldRender::draw (glm::mat4x4 const& model_view
continue; continue;
} }
bool draw_animated_boxes = true;
/*if (draw_hidden_models || !pair.first->is_hidden())*/ // now done when building models_to_draw /*if (draw_hidden_models || !pair.first->is_hidden())*/ // now done when building models_to_draw
{ {
pair.first->renderer()->draw( model_view pair.first->renderer()->draw( model_view
@@ -827,13 +829,16 @@ void WorldRender::draw (glm::mat4x4 const& model_view
, false , false
, render_settings.draw_model_animations , render_settings.draw_model_animations
, render_settings.editing_mode == editing_mode::object , render_settings.editing_mode == editing_mode::object
, draw_animated_boxes
); );
_world->_n_rendered_objects += pair.second.size(); _world->_n_rendered_objects += pair.second.size();
} }
// Draw animated bounding boxes for small animated models that move // Draw animated bounding boxes for small animated models that move
if (render_settings.editing_mode == editing_mode::object if (/*render_settings.editing_mode == editing_mode::object*/
&& pair.first->animated_mesh() /*&& render_settings.draw_model_animations*/ && pair.first->mesh_bounds_ratio < 0.3f) (render_settings.draw_models_with_box || pair.first->is_hidden()) // same condition to draw bounding box in draw()
/*&& render_settings.draw_model_animations*/
&& pair.first->animated_mesh() && pair.first->mesh_bounds_ratio < 0.5f)
{ {
auto animated_bb = pair.first->getAnimatedBoundingBox(); auto animated_bb = pair.first->getAnimatedBoundingBox();
for (auto const& instance_matrix : pair.second) for (auto const& instance_matrix : pair.second)
@@ -841,7 +846,7 @@ void WorldRender::draw (glm::mat4x4 const& model_view
Noggit::Rendering::Primitives::WireBox::getInstance(_world->_context).draw(model_view Noggit::Rendering::Primitives::WireBox::getInstance(_world->_context).draw(model_view
, projection , projection
, instance_matrix , instance_matrix
, { 0.6f, 0.6f, 0.6f, 0.6f } // grey , { 0.6f, 0.6f, 0.6f, 1.0f } // grey
, animated_bb[0] , animated_bb[0]
, animated_bb[1] , animated_bb[1]
); );
@@ -945,9 +950,11 @@ void WorldRender::draw (glm::mat4x4 const& model_view
{ {
// bool is_selected = false; // bool is_selected = false;
bool is_selected = _world->is_selected(model->uid); bool is_selected = _world->is_selected(model->uid);
bool draw_anim_bb = !(render_settings.draw_models_with_box || model->model->is_hidden());
model->draw_box(model_view, projection, is_selected, render_settings.render_select_m2_collission_bbox model->draw_box(model_view, projection, is_selected, render_settings.render_select_m2_collission_bbox
, render_settings.render_select_m2_aabb, true); , render_settings.render_select_m2_aabb, draw_anim_bb);
} }
} }
} }

View File

@@ -261,6 +261,7 @@ void PreviewRenderer::draw()
, false , false
, _draw_animated.get() , _draw_animated.get()
, true , true
, false
); );
} }
@@ -288,6 +289,7 @@ void PreviewRenderer::draw()
, false , false
, _draw_animated.get() , _draw_animated.get()
, false , false
, false
); );
} }