diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2020-12-18 16:19:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 16:19:12 +0100 |
commit | 7ad29ed64e850fd43ba7ceb1cfaab4e015ef7b97 (patch) | |
tree | f1d46d8194f01e56cd3a4d042b9b33ba728c6f62 /scene/resources | |
parent | 36b4e035dc7c410c29cda4446f8daa2e00a31da0 (diff) | |
parent | d2302f53d6ad80943e7f4245ac572003f1681d00 (diff) |
Merge pull request #44468 from reduz/implement-lod
Implement automatic LOD (Level of Detail)
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/surface_tool.cpp | 3 | ||||
-rw-r--r-- | scene/resources/surface_tool.h | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 772b54bc53..50308d641a 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -1128,7 +1128,8 @@ Vector<int> SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun vertices[i * 3 + 2] = vertex_array[i].vertex.z; } - uint32_t index_count = simplify_func((unsigned int *)lod.ptrw(), (unsigned int *)index_array.ptr(), index_array.size(), vertices.ptr(), vertex_array.size(), sizeof(float) * 3, p_target_index_count, p_threshold); + float error; + uint32_t index_count = simplify_func((unsigned int *)lod.ptrw(), (unsigned int *)index_array.ptr(), index_array.size(), vertices.ptr(), vertex_array.size(), sizeof(float) * 3, p_target_index_count, p_threshold, &error); ERR_FAIL_COND_V(index_count == 0, lod); lod.resize(index_count); diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h index e80a5339a9..0e60bfe389 100644 --- a/scene/resources/surface_tool.h +++ b/scene/resources/surface_tool.h @@ -76,7 +76,7 @@ public: typedef void (*OptimizeVertexCacheFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, size_t vertex_count); static OptimizeVertexCacheFunc optimize_vertex_cache_func; - typedef size_t (*SimplifyFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error); + typedef size_t (*SimplifyFunc)(unsigned int *destination, const unsigned int *indices, size_t index_count, const float *vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float *r_error); static SimplifyFunc simplify_func; private: |