@@ -93,9 +93,9 @@ bool client_input_arrays_to_hmesh(std::shared_ptr<context_t>& context_ptr,
93
93
{
94
94
95
95
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
96
- const float & x = (vptr[(i * 3 ) + 0 ] - srcmesh_cutmesh_com[0 ]) + pre_quantization_translation[0 ];
97
- const float & y = (vptr[(i * 3 ) + 1 ] - srcmesh_cutmesh_com[1 ]) + pre_quantization_translation[1 ];
98
- const float & z = (vptr[(i * 3 ) + 2 ] - srcmesh_cutmesh_com[2 ]) + pre_quantization_translation[2 ];
96
+ const float x = (vptr[(i * 3 ) + 0 ] - srcmesh_cutmesh_com[0 ]) + pre_quantization_translation[0 ];
97
+ const float y = (vptr[(i * 3 ) + 1 ] - srcmesh_cutmesh_com[1 ]) + pre_quantization_translation[1 ];
98
+ const float z = (vptr[(i * 3 ) + 2 ] - srcmesh_cutmesh_com[2 ]) + pre_quantization_translation[2 ];
99
99
vec3 quantized_vertex (scalar_t::quantize (x, multiplier),
100
100
scalar_t::quantize (y, multiplier),
101
101
scalar_t::quantize (z, multiplier));
@@ -117,11 +117,11 @@ bool client_input_arrays_to_hmesh(std::shared_ptr<context_t>& context_ptr,
117
117
118
118
vd_t vd = halfedgeMesh.add_vertex (quantized_vertex);
119
119
#else
120
- const float & x =
120
+ const float x =
121
121
(vptr[(i * 3 ) + 0 ] - srcmesh_cutmesh_com[0 ]) + pre_quantization_translation[0 ];
122
- const float & y =
122
+ const float y =
123
123
(vptr[(i * 3 ) + 1 ] - srcmesh_cutmesh_com[1 ]) + pre_quantization_translation[1 ];
124
- const float & z =
124
+ const float z =
125
125
(vptr[(i * 3 ) + 2 ] - srcmesh_cutmesh_com[2 ]) + pre_quantization_translation[2 ];
126
126
// insert our vertex into halfedge mesh
127
127
vd_t vd = halfedgeMesh.add_vertex (
@@ -140,9 +140,15 @@ bool client_input_arrays_to_hmesh(std::shared_ptr<context_t>& context_ptr,
140
140
// for each input mesh-vertex
141
141
for (McUint32 i = 0 ; i < numVertices; ++i)
142
142
{
143
- const double & x = (vptr[(i * 3 ) + 0 ] - srcmesh_cutmesh_com[0 ]) + pre_quantization_translation[0 ];
144
- const double & y = (vptr[(i * 3 ) + 1 ] - srcmesh_cutmesh_com[1 ]) + pre_quantization_translation[1 ];
145
- const double & z = (vptr[(i * 3 ) + 2 ] - srcmesh_cutmesh_com[2 ]) + pre_quantization_translation[2 ];
143
+ const double x_ =
144
+ vptr[(i * 3 ) + 0 ];
145
+ const double y_ =
146
+ vptr[(i * 3 ) + 1 ];
147
+ const double z_ = vptr[(i * 3 ) + 2 ];
148
+
149
+ const double x = (x_ - srcmesh_cutmesh_com[0 ]) + pre_quantization_translation[0 ];
150
+ const double y = (y_ - srcmesh_cutmesh_com[1 ]) + pre_quantization_translation[1 ];
151
+ const double z = (z_ - srcmesh_cutmesh_com[2 ]) + pre_quantization_translation[2 ];
146
152
147
153
#if MCUT_WITH_ARBITRARY_PRECISION_NUMBERS
148
154
vec3 quantized_vertex (scalar_t::quantize (x, multiplier),
@@ -2205,11 +2211,10 @@ bool calculate_vertex_parameters(
2205
2211
vec3_<double > srcmesh_cutmesh_bboxmin = compwise_min (srcmesh_bboxmin, cutmesh_bboxmin);
2206
2212
vec3_<double > srcmesh_cutmesh_bboxmax = compwise_max (srcmesh_bboxmax, cutmesh_bboxmax);
2207
2213
2208
- vec3_<double > offset_from_origin = vec3_<double >(
2209
- 1.0 ,
2210
- 1.0 ,
2211
- 1.0 ); // ensure that when meshes are place into positive quadrant, no vertex coincides with the origin.
2214
+
2212
2215
vec3_<double > to_positive_quadrant = (srcmesh_cutmesh_com - srcmesh_cutmesh_bboxmin);
2216
+ vec3_<double > offset_from_origin =
2217
+ normalize (to_positive_quadrant); // ensures that when meshes are place into positive quadrant, no vertex coincides with the origin.
2213
2218
2214
2219
pre_quantization_translation = to_positive_quadrant + offset_from_origin;
2215
2220
@@ -2218,16 +2223,19 @@ bool calculate_vertex_parameters(
2218
2223
//
2219
2224
srcmesh_com = srcmesh_com + pre_quantization_translation;
2220
2225
cutmesh_com = cutmesh_com + pre_quantization_translation;
2221
- srcmesh_cutmesh_com = srcmesh_cutmesh_com + pre_quantization_translation;
2226
+ // srcmesh_cutmesh_com = srcmesh_cutmesh_com + pre_quantization_translation;
2222
2227
srcmesh_bboxmin = srcmesh_bboxmin + pre_quantization_translation;
2223
2228
srcmesh_bboxmax = srcmesh_bboxmax + pre_quantization_translation;
2224
2229
cutmesh_bboxmin = cutmesh_bboxmin + pre_quantization_translation;
2225
2230
cutmesh_bboxmax = cutmesh_bboxmax + pre_quantization_translation;
2226
2231
srcmesh_cutmesh_bboxmin = srcmesh_cutmesh_bboxmin + pre_quantization_translation;
2227
2232
srcmesh_cutmesh_bboxmax = srcmesh_cutmesh_bboxmax + pre_quantization_translation;
2228
2233
2229
-
2230
- double max_coord = std::numeric_limits<double >::lowest ();
2234
+ vec3_<double > diag = srcmesh_cutmesh_bboxmax - srcmesh_cutmesh_bboxmin;
2235
+ MCUT_ASSERT (diag[0 ] > 0 );
2236
+ MCUT_ASSERT (diag[1 ] > 0 );
2237
+ MCUT_ASSERT (diag[2 ] > 0 );
2238
+ /* double max_coord = std::numeric_limits<double>::lowest();
2231
2239
double min_coord = std::numeric_limits<double>::max();
2232
2240
2233
2241
for(int i = 0; i < 3; ++i)
@@ -2236,9 +2244,10 @@ bool calculate_vertex_parameters(
2236
2244
std::min(srcmesh_cutmesh_bboxmin[1], srcmesh_cutmesh_bboxmin[2]));
2237
2245
max_coord = std::max(srcmesh_cutmesh_bboxmax[0],
2238
2246
std::max(srcmesh_cutmesh_bboxmax[1], srcmesh_cutmesh_bboxmax[2]));
2239
- }
2247
+ }*/
2240
2248
2241
- const double M = std::max (std::abs (min_coord), std::abs (max_coord));
2249
+ const double M = std::max (diag[0 ],std::max (diag[1 ], diag[2 ]));
2250
+ /* Std::max(std::abs(min_coord), std::abs(max_coord));*/
2242
2251
2243
2252
auto is_pow2 = [](uint64_t x) { return (x != 0 ) && !(x & (x - 1 )); };
2244
2253
@@ -2259,7 +2268,7 @@ bool calculate_vertex_parameters(
2259
2268
// The "+ 1" to cater to instances where "(uint64_t)(M + 0.5)" is a power-of-two: Here numerical perturbation will lead to
2260
2269
// some vertex coordinates being larger than "(uint64_t)(M + 0.5)". Therefore we add 1 to cover even instances that involve perturbation.
2261
2270
const auto M_ = (uint64_t )(M + 0.5 ) + 1 ;
2262
- const auto M_np2 = is_pow2 (M_+1 ) ? M_ : next_pow2 (M_);
2271
+ const auto M_np2 = is_pow2 (M_+1 ) ? M_ : next_pow2 (M_+ 1 );
2263
2272
2264
2273
quantization_multiplier = (double )M_np2;
2265
2274
0 commit comments