|
|
@ -31,8 +31,8 @@ void extrude_polyline_t::initialize_from_descriptor(primitive_data_center_t* dc, |
|
|
axis_matrix.local_to_world = geom->axis_to_world; |
|
|
axis_matrix.local_to_world = geom->axis_to_world; |
|
|
axis_matrix.world_to_local = geom->axis_to_world.inverse(); |
|
|
axis_matrix.world_to_local = geom->axis_to_world.inverse(); |
|
|
|
|
|
|
|
|
paired_model_matrix bottom_matrix = compute_polyline_bottom_cap_matrix(desc.axis); |
|
|
paired_model_matrix bottom_matrix = compute_polyline_bottom_cap_matrix(*geom); |
|
|
paired_model_matrix top_matrix = compute_polyline_top_cap_matrix(desc.axis); |
|
|
paired_model_matrix top_matrix = compute_polyline_top_cap_matrix(*geom); |
|
|
|
|
|
|
|
|
std::array<paired_model_matrix, 3> matrix_storage = {axis_matrix, bottom_matrix, top_matrix}; |
|
|
std::array<paired_model_matrix, 3> matrix_storage = {axis_matrix, bottom_matrix, top_matrix}; |
|
|
paired_model_matrix_ptr_t axis_matrix_ptr = make_pointer_wrapper(matrix_storage[0]); |
|
|
paired_model_matrix_ptr_t axis_matrix_ptr = make_pointer_wrapper(matrix_storage[0]); |
|
|
@ -53,14 +53,10 @@ void extrude_polyline_t::initialize_from_descriptor(primitive_data_center_t* dc, |
|
|
bottom_cap_desc = descriptor_defaults::unit_plane; |
|
|
bottom_cap_desc = descriptor_defaults::unit_plane; |
|
|
top_cap_desc = descriptor_defaults::unit_plane; |
|
|
top_cap_desc = descriptor_defaults::unit_plane; |
|
|
} |
|
|
} |
|
|
std::cout << "[EXTRUDE_POLYLINE_INIT] Bottom cap AABB min: (" << bottom_cap_desc.local_aabb_min.x << ", " |
|
|
|
|
|
<< bottom_cap_desc.local_aabb_min.y << ")\n"; |
|
|
|
|
|
std::cout << "[EXTRUDE_POLYLINE_INIT] Bottom cap AABB max: (" << bottom_cap_desc.local_aabb_max.x << ", " |
|
|
|
|
|
<< bottom_cap_desc.local_aabb_max.y << ")\n"; |
|
|
|
|
|
|
|
|
|
|
|
// 修改initialize调用,传递plane descriptor
|
|
|
// 修改initialize调用,传递plane descriptor
|
|
|
initialize({axis_matrix_ptr, bottom_matrix_ptr, top_matrix_ptr}, |
|
|
initialize({axis_matrix_ptr, bottom_matrix_ptr, top_matrix_ptr}, |
|
|
{false, true, false}, // polyline侧面的法向指向内部,因此需要翻转
|
|
|
{false, true, false}, |
|
|
{static_cast<const void*>(geom), |
|
|
{static_cast<const void*>(geom), |
|
|
nullptr, |
|
|
nullptr, |
|
|
nullptr}, |
|
|
nullptr}, |
|
|
@ -69,6 +65,19 @@ void extrude_polyline_t::initialize_from_descriptor(primitive_data_center_t* dc, |
|
|
recompute_aabb(); |
|
|
recompute_aabb(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void extrude_polyline_t::update_geometry(const void* new_geometry_ptr, size_t subface_index) |
|
|
|
|
|
{ |
|
|
|
|
|
if (subface_index != 0) { |
|
|
|
|
|
throw std::invalid_argument("extrude_polyline_t::update_geometry: cap planes (index 1 and 2) cannot be " |
|
|
|
|
|
"updated independently. Their matrices are derived from the axis path. " |
|
|
|
|
|
"Use replace_profile(), replace_axis(), or initialize_from_descriptor() " |
|
|
|
|
|
"to rebuild the primitive as a whole."); |
|
|
|
|
|
} |
|
|
|
|
|
if (!data_center) { throw std::runtime_error("Primitive not initialized"); } |
|
|
|
|
|
auto* desc = static_cast<const extrude_polyline_descriptor_t*>(new_geometry_ptr); |
|
|
|
|
|
initialize_from_descriptor(data_center.raw(), *desc); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void extrude_polyline_t::replace_profile(const profile_descriptor_t& new_profile) |
|
|
void extrude_polyline_t::replace_profile(const profile_descriptor_t& new_profile) |
|
|
{ |
|
|
{ |
|
|
if (!data_center) { throw std::runtime_error("Primitive not initialized"); } |
|
|
if (!data_center) { throw std::runtime_error("Primitive not initialized"); } |
|
|
@ -125,9 +134,6 @@ void extrude_helixline_t::initialize_from_descriptor(primitive_data_center_t* dc |
|
|
paired_model_matrix bottom_matrix = compute_helixline_bottom_cap_matrix(geom->axis_geom); |
|
|
paired_model_matrix bottom_matrix = compute_helixline_bottom_cap_matrix(geom->axis_geom); |
|
|
paired_model_matrix top_matrix = compute_helixline_top_cap_matrix(geom->axis_geom); |
|
|
paired_model_matrix top_matrix = compute_helixline_top_cap_matrix(geom->axis_geom); |
|
|
|
|
|
|
|
|
std::cout << "[EXTRUDE_HELIXLINE_INIT] Bottom cap matrix(BNTP):\n" << bottom_matrix.local_to_world.matrix() << "\n"; |
|
|
|
|
|
std::cout << "[EXTRUDE_HELIXLINE_INIT] Top cap matrix(BNTP):\n" << top_matrix.local_to_world.matrix() << "\n"; |
|
|
|
|
|
|
|
|
|
|
|
std::array<paired_model_matrix, 3> matrix_storage = {axis_matrix, bottom_matrix, top_matrix}; |
|
|
std::array<paired_model_matrix, 3> matrix_storage = {axis_matrix, bottom_matrix, top_matrix}; |
|
|
paired_model_matrix_ptr_t axis_matrix_ptr = make_pointer_wrapper(matrix_storage[0]); |
|
|
paired_model_matrix_ptr_t axis_matrix_ptr = make_pointer_wrapper(matrix_storage[0]); |
|
|
paired_model_matrix_ptr_t bottom_matrix_ptr = make_pointer_wrapper(matrix_storage[1]); |
|
|
paired_model_matrix_ptr_t bottom_matrix_ptr = make_pointer_wrapper(matrix_storage[1]); |
|
|
@ -148,13 +154,26 @@ void extrude_helixline_t::initialize_from_descriptor(primitive_data_center_t* dc |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
initialize({axis_matrix_ptr, bottom_matrix_ptr, top_matrix_ptr}, |
|
|
initialize({axis_matrix_ptr, bottom_matrix_ptr, top_matrix_ptr}, |
|
|
{false, true, false}, // helixline侧面的法向指向内部,因此需要翻转
|
|
|
{false, true, false}, |
|
|
{static_cast<const void*>(geom), nullptr, nullptr}, |
|
|
{static_cast<const void*>(geom), nullptr, nullptr}, |
|
|
aabb_t{}); |
|
|
aabb_t{}); |
|
|
|
|
|
|
|
|
recompute_aabb(); |
|
|
recompute_aabb(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void extrude_helixline_t::update_geometry(const void* new_geometry_ptr, size_t subface_index) |
|
|
|
|
|
{ |
|
|
|
|
|
if (subface_index != 0) { |
|
|
|
|
|
throw std::invalid_argument("extrude_helixline_t::update_geometry: cap planes (index 1 and 2) cannot be " |
|
|
|
|
|
"updated independently. Their matrices are derived from the helix path. " |
|
|
|
|
|
"Use replace_profile(), replace_axis(), or initialize_from_descriptor() " |
|
|
|
|
|
"to rebuild the primitive as a whole."); |
|
|
|
|
|
} |
|
|
|
|
|
if (!data_center) { throw std::runtime_error("Primitive not initialized"); } |
|
|
|
|
|
auto* desc = static_cast<const extrude_helixline_descriptor_t*>(new_geometry_ptr); |
|
|
|
|
|
initialize_from_descriptor(data_center.raw(), *desc); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void extrude_helixline_t::replace_profile(const profile_descriptor_t& new_profile) |
|
|
void extrude_helixline_t::replace_profile(const profile_descriptor_t& new_profile) |
|
|
{ |
|
|
{ |
|
|
if (!data_center) { throw std::runtime_error("Primitive not initialized"); } |
|
|
if (!data_center) { throw std::runtime_error("Primitive not initialized"); } |
|
|
|