|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <base/primitive.hpp>
|
|
|
|
#include <subface/simple/plane.hpp>
|
|
|
|
#include <subface/simple/cylinder_face.hpp>
|
|
|
|
|
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
struct cylinder_t final : primitive {
|
|
|
|
void initialize(primitive_data_center_t &) override;
|
|
|
|
void destroy() override;
|
|
|
|
|
|
|
|
primitive_type get_type() const override { return PRIMITIVE_TYPE_CYLINDER; };
|
|
|
|
|
|
|
|
marked_subface_ptr_t<internal::cylinder_face_t> cylinder_face{};
|
|
|
|
marked_subface_ptr_t<internal::plane_t> bottom_plane{};
|
|
|
|
marked_subface_ptr_t<internal::plane_t> top_plane{};
|
|
|
|
|
|
|
|
// why virtual? For special primitives like cylinder, it may have multiple parts.
|
|
|
|
// The part with index 0 may not be the identity transform.
|
|
|
|
// For example, the cylinder face has no z translation.
|
|
|
|
// Note: The AABB of a cylinder is defined by the side surface, and z-axis scaling does not affect the side surface's radius.
|
|
|
|
// The degeneracy (simplification) check for a cylinder only considers the first two rows of the transform matrix (x/y directions),
|
|
|
|
// because scaling along z does not change the essential geometry of the cylinder side surface.
|
|
|
|
// TODO: the better way is to redefine cylinder, make identity transform as the first part.
|
|
|
|
const internal::transform_block &get_identity_local_to_world() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void initialize(primitive_data_center_t &, const std::vector<std::pair<internal::paired_model_matrix *, bool>> &) override;
|
|
|
|
|
|
|
|
marked_subface_ptr_t<subface> *get_subface() const override { return (marked_subface_ptr_t<subface> *)(&cylinder_face); }
|
|
|
|
|
|
|
|
size_t get_subface_count() const override { return 3; }
|
|
|
|
};
|
|
|
|
} // namespace internal
|