You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.0 KiB
58 lines
2.0 KiB
#pragma once
|
|
|
|
#include <base/primitive.hpp>
|
|
#include <subface/simple/plane.hpp>
|
|
#include <subface/simple/cylinder_face.hpp>
|
|
|
|
namespace internal
|
|
{
|
|
struct cylinder_t final : public primitive {
|
|
cylinder_t(primitive_data_center_t *data_center_ptr) : primitive(data_center_ptr)
|
|
{
|
|
initialize({identity_model_matrix_ptr, plane_to_z_model_matrix_ptr, plane_to_z_pos_1_model_matrix_ptr},
|
|
{false, true, false},
|
|
{static_cast<const void *>(&descriptor_defaults::unit_cylinder), nullptr, nullptr},
|
|
k_aabb_up_unit);
|
|
}
|
|
|
|
primitive_type get_type() const override { return PRIMITIVE_TYPE_CYLINDER; };
|
|
|
|
/**
|
|
* @brief 获取子面的 descriptor 指针
|
|
* @return 指针数组,可能是以下两种类型:
|
|
* - 规范化指针:已被 data_center 管理,共享生命周期
|
|
* - 常量池指针:指向全局常量,仅用于初始化时查找
|
|
*/
|
|
stl_vector_mp<const void*> get_subface_geometries() const override
|
|
{
|
|
std::cerr << "[CYLINDER_GEOM] Getting subface geometries:\n";
|
|
|
|
// 检查是否已初始化
|
|
if (subfaces[0].get_ptr() != nullptr) {
|
|
auto* cylinder_face = static_cast<cylinder_face_t*>(subfaces[0].get_ptr());
|
|
return {
|
|
static_cast<const void *>(cylinder_face->get_geometry_ptr()),
|
|
nullptr,
|
|
nullptr
|
|
};
|
|
} else {
|
|
return {
|
|
static_cast<const void*>(&descriptor_defaults::unit_cylinder), // 在 cylinder 中,geometry 即 descriptor
|
|
nullptr,
|
|
nullptr
|
|
};
|
|
}
|
|
}
|
|
span<marked_subface_ptr_t<subface>> get_subfaces() const override
|
|
{
|
|
return {const_cast<marked_subface_ptr_t<subface> *>(subfaces.data()), subfaces.size()};
|
|
}
|
|
|
|
stl_vector_mp<surface_type> get_subface_types() const override
|
|
{
|
|
return {surface_type::cylinder, surface_type::plane, surface_type::plane};
|
|
}
|
|
|
|
std::array<marked_subface_ptr_t<subface>, 3> subfaces{};
|
|
};
|
|
} // namespace internal
|