Browse Source

fix: Make get_identity_local_to_world virtual to support primitives with multiple subfaces (e.g., cylinder).

Note: Cylinder's side surface defines its AABB, and z-axis scaling does not affect its radius.
Degeneracy checks only consider x/y directions (first two rows of the transform matrix), since z scaling does not change the essential geometry.
TODO: Consider redefining cylinder so the identity transform is always the first subface.
V2-origin
mckay 3 weeks ago
parent
commit
fdce50916f
  1. 4
      primitive_process/interface/base/primitive.hpp
  2. 9
      primitive_process/interface/primitive/simple/cylinder.hpp
  3. 5
      primitive_process/src/primitive/simple/cylinder.cpp

4
primitive_process/interface/base/primitive.hpp

@ -62,7 +62,9 @@ EXTERN_C struct PE_API primitive {
// so we don't need to fetch aabb anymore // so we don't need to fetch aabb anymore
// aabb fetch_aabb() const; // aabb fetch_aabb() const;
// CAUTION: keep characteristics local_to_world as the first subface's part // CAUTION: keep characteristics local_to_world as the first subface's part
const internal::transform_block &get_identity_local_to_world() const; // why virtual? for special primitive like cylinder, it may have multiple parts, the part
// with index 0 may not be the identity transform. e.g., cylinder face has no z translation.
virtual const internal::transform_block &get_identity_local_to_world() const;
void apply_transform(internal::transform_type, Eigen::Vector4d); void apply_transform(internal::transform_type, Eigen::Vector4d);

9
primitive_process/interface/primitive/simple/cylinder.hpp

@ -16,6 +16,15 @@ struct cylinder_t final : primitive {
marked_subface_ptr_t<internal::plane_t> bottom_plane{}; marked_subface_ptr_t<internal::plane_t> bottom_plane{};
marked_subface_ptr_t<internal::plane_t> top_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: protected:
void initialize(primitive_data_center_t &, const std::vector<std::pair<internal::paired_model_matrix *, bool>> &) override; void initialize(primitive_data_center_t &, const std::vector<std::pair<internal::paired_model_matrix *, bool>> &) override;

5
primitive_process/src/primitive/simple/cylinder.cpp

@ -61,4 +61,9 @@ void cylinder_t::initialize(primitive_data_center_t
data_center.planes.release(plane_paired_model_matrix{old_model_matrices[2]}); data_center.planes.release(plane_paired_model_matrix{old_model_matrices[2]});
} }
} }
const internal::transform_block &cylinder_t::get_identity_local_to_world() const
{
return get_subface()[1].get_ptr()->raw_local_to_world();
}
} // namespace internal } // namespace internal
Loading…
Cancel
Save