|
@ -24,7 +24,7 @@ void cylinder_t::destroy() |
|
|
void cylinder_t::initialize(primitive_data_center_t &data_center, |
|
|
void cylinder_t::initialize(primitive_data_center_t &data_center, |
|
|
const std::vector<std::pair<internal::paired_model_matrix *, bool>> &new_model_matrices) |
|
|
const std::vector<std::pair<internal::paired_model_matrix *, bool>> &new_model_matrices) |
|
|
{ |
|
|
{ |
|
|
std::array<subface *, 3> old_ptrs{bottom_plane.get_ptr(), cylinder_face.get_ptr(), top_plane.get_ptr()}; |
|
|
std::array<subface *, 3> old_ptrs{cylinder_face.get_ptr(), bottom_plane.get_ptr(), top_plane.get_ptr()}; |
|
|
std::array<paired_model_matrix *, 3> old_model_matrices{nullptr, nullptr, nullptr}; |
|
|
std::array<paired_model_matrix *, 3> old_model_matrices{nullptr, nullptr, nullptr}; |
|
|
for (size_t i = 0; i < 3; ++i) { |
|
|
for (size_t i = 0; i < 3; ++i) { |
|
|
if (old_ptrs[i] != nullptr) old_model_matrices[i] = old_ptrs[i]->model_matrices; |
|
|
if (old_ptrs[i] != nullptr) old_model_matrices[i] = old_ptrs[i]->model_matrices; |
|
@ -52,8 +52,13 @@ void cylinder_t::initialize(primitive_data_center_t |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// deferred release to avoid acquiring the same just-released subface
|
|
|
// deferred release to avoid acquiring the same just-released subface
|
|
|
for (size_t i = 0; i < 3; ++i) { |
|
|
{ |
|
|
if (old_ptrs[i] != nullptr) data_center.spheres.release(old_model_matrices[i]); |
|
|
if (old_ptrs[0] != nullptr) |
|
|
|
|
|
data_center.cylinders.release(cylinder_paired_model_matrix{old_model_matrices[0]}); |
|
|
|
|
|
if (old_ptrs[1] != nullptr) |
|
|
|
|
|
data_center.planes.release(plane_paired_model_matrix{old_model_matrices[1]}); |
|
|
|
|
|
if (old_ptrs[2] != nullptr) |
|
|
|
|
|
data_center.planes.release(plane_paired_model_matrix{old_model_matrices[2]}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} // namespace internal
|
|
|
} // namespace internal
|