some improvements in raycast model

This commit is contained in:
PavelMikus 2022-05-24 12:49:32 +02:00
parent e34d915a1d
commit c4285a6ab3

View File

@ -18,9 +18,14 @@ Vec3f sample_sphere_uniform(const Vec2f &samples) {
1.0f - 2.0f * samples.y()}; 1.0f - 2.0f * samples.y()};
} }
float sigmoid(float x) {
float e = std::exp(x);
return (2.0f * e) / (1.0f + e) - 1.0f;
}
indexed_triangle_set fix_model_volume_mesh(const TriangleMesh &mesh) { indexed_triangle_set fix_model_volume_mesh(const TriangleMesh &mesh) {
float thickness = 2.0f; float thickness = 2.0f;
float resolution = 0.2f; float resolution = 0.3f;
//prepare uniform samples of a sphere //prepare uniform samples of a sphere
size_t sqrt_sample_count = 8; size_t sqrt_sample_count = 8;
@ -94,14 +99,13 @@ indexed_triangle_set fix_model_volume_mesh(const TriangleMesh &mesh) {
} }
} }
if (float(inside_hits) > float(precomputed_sample_directions.size()) * 2.0f / 3.0f) { float ratio = float(inside_hits) / float(precomputed_sample_directions.size());
value = -distance; float x = sigmoid(6 * (-ratio + 0.666f));
if (apply_bonus) {
value = -2.0f * distance; if (x < 0 && apply_bonus) {
} x = x * 2.0f;
} else {
value = distance;
} }
value = distance * x;
} }
} }
); );