#pragma once
#include
#include
#include
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 cylinder_face{};
marked_subface_ptr_t bottom_plane{};
marked_subface_ptr_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> &) override;
marked_subface_ptr_t *get_subface() const override { return (marked_subface_ptr_t *)(&cylinder_face); }
size_t get_subface_count() const override { return 3; }
};
} // namespace internal