Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_view.cc
| Show All 15 Lines | |||||
| namespace blender::draw { | namespace blender::draw { | ||||
| void View::sync(const float4x4 &view_mat, const float4x4 &win_mat) | void View::sync(const float4x4 &view_mat, const float4x4 &win_mat) | ||||
| { | { | ||||
| data_.viewmat = view_mat; | data_.viewmat = view_mat; | ||||
| data_.viewinv = view_mat.inverted(); | data_.viewinv = view_mat.inverted(); | ||||
| data_.winmat = win_mat; | data_.winmat = win_mat; | ||||
| data_.wininv = win_mat.inverted(); | data_.wininv = win_mat.inverted(); | ||||
| data_.persmat = data_.winmat * data_.viewmat; | |||||
| data_.persinv = data_.persmat.inverted(); | |||||
| /* Should not be used anymore. */ | /* Should not be used anymore. */ | ||||
| data_.viewcamtexcofac = float4(1.0f, 1.0f, 0.0f, 0.0f); | data_.viewcamtexcofac = float4(1.0f, 1.0f, 0.0f, 0.0f); | ||||
| data_.is_inverted = (is_negative_m4(view_mat.ptr()) == is_negative_m4(win_mat.ptr())); | data_.is_inverted = (is_negative_m4(view_mat.ptr()) == is_negative_m4(win_mat.ptr())); | ||||
| update_view_vectors(); | update_view_vectors(); | ||||
| BoundBox &bound_box = *reinterpret_cast<BoundBox *>(&data_.frustum_corners); | BoundBox &bound_box = *reinterpret_cast<BoundBox *>(&data_.frustum_corners); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | #endif | ||||
| /* Transform into world space. */ | /* Transform into world space. */ | ||||
| for (int i = 0; i < 8; i++) { | for (int i = 0; i < 8; i++) { | ||||
| mul_m4_v3(data_.viewinv.ptr(), bbox.vec[i]); | mul_m4_v3(data_.viewinv.ptr(), bbox.vec[i]); | ||||
| } | } | ||||
| } | } | ||||
| void View::frustum_culling_planes_calc() | void View::frustum_culling_planes_calc() | ||||
| { | { | ||||
| planes_from_projmat(data_.persmat.ptr(), | float4x4 persmat = data_.winmat * data_.viewmat; | ||||
| planes_from_projmat(persmat.ptr(), | |||||
| data_.frustum_planes[0], | data_.frustum_planes[0], | ||||
| data_.frustum_planes[5], | data_.frustum_planes[5], | ||||
| data_.frustum_planes[1], | data_.frustum_planes[1], | ||||
| data_.frustum_planes[3], | data_.frustum_planes[3], | ||||
| data_.frustum_planes[4], | data_.frustum_planes[4], | ||||
| data_.frustum_planes[2]); | data_.frustum_planes[2]); | ||||
| /* Normalize. */ | /* Normalize. */ | ||||
| ▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | |||||
| void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze) | void View::compute_visibility(ObjectBoundsBuf &bounds, uint resource_len, bool debug_freeze) | ||||
| { | { | ||||
| if (debug_freeze && frozen_ == false) { | if (debug_freeze && frozen_ == false) { | ||||
| data_freeze_ = static_cast<ViewInfos>(data_); | data_freeze_ = static_cast<ViewInfos>(data_); | ||||
| data_freeze_.push_update(); | data_freeze_.push_update(); | ||||
| } | } | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| if (debug_freeze) { | if (debug_freeze) { | ||||
| drw_debug_matrix_as_bbox(data_freeze_.persinv, float4(0, 1, 0, 1)); | float4x4 persmat = data_freeze_.winmat * data_freeze_.viewmat; | ||||
| drw_debug_matrix_as_bbox(persmat.inverted(), float4(0, 1, 0, 1)); | |||||
| } | } | ||||
| #endif | #endif | ||||
| frozen_ = debug_freeze; | frozen_ = debug_freeze; | ||||
| GPU_debug_group_begin("View.compute_visibility"); | GPU_debug_group_begin("View.compute_visibility"); | ||||
| /* TODO(fclem): Early out if visibility hasn't changed. */ | /* TODO(fclem): Early out if visibility hasn't changed. */ | ||||
| /* TODO(fclem): Resize to nearest pow2 to reduce fragmentation. */ | /* TODO(fclem): Resize to nearest pow2 to reduce fragmentation. */ | ||||
| Show All 25 Lines | |||||