Updated ozz-animation to version 0.14.1 @35b2efd4
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Adds fbx2mesh utility target.
|
||||
if(ozz_build_fbx)
|
||||
|
||||
# share meshes with thte sample framework
|
||||
# share meshes with the sample framework
|
||||
add_executable(sample_fbx2mesh
|
||||
fbx2mesh.cc
|
||||
${PROJECT_SOURCE_DIR}/samples/framework/mesh.cc
|
||||
@@ -9,6 +9,7 @@ if(ozz_build_fbx)
|
||||
target_link_libraries(sample_fbx2mesh
|
||||
ozz_animation_fbx
|
||||
ozz_options)
|
||||
target_copy_shared_libraries(sample_fbx2mesh)
|
||||
set_target_properties(sample_fbx2mesh
|
||||
PROPERTIES FOLDER "samples/tools")
|
||||
|
||||
|
||||
+19
-20
@@ -25,12 +25,12 @@
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "framework/mesh.h"
|
||||
|
||||
#include "ozz/animation/offline/fbx/fbx.h"
|
||||
|
||||
#include "ozz/animation/runtime/skeleton.h"
|
||||
|
||||
#include "ozz/base/containers/map.h"
|
||||
#include "ozz/base/containers/vector.h"
|
||||
#include "ozz/base/io/archive.h"
|
||||
@@ -39,14 +39,8 @@
|
||||
#include "ozz/base/maths/math_ex.h"
|
||||
#include "ozz/base/maths/simd_math.h"
|
||||
#include "ozz/base/memory/allocator.h"
|
||||
|
||||
#include "ozz/options/options.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "fbxsdk/utils/fbxgeometryconverter.h"
|
||||
|
||||
// Declares command line options.
|
||||
OZZ_OPTIONS_DECLARE_STRING(file, "Specifies input file.", "", true)
|
||||
OZZ_OPTIONS_DECLARE_STRING(skeleton,
|
||||
@@ -504,19 +498,18 @@ bool BuildSkin(FbxMesh* _fbx_mesh,
|
||||
const int* ctrl_point_indices = cluster->GetControlPointIndices();
|
||||
const double* ctrl_point_weights = cluster->GetControlPointWeights();
|
||||
for (int cpi = 0; cpi < ctrl_point_index_count; ++cpi) {
|
||||
const SkinMapping mapping = {joint,
|
||||
static_cast<float>(ctrl_point_weights[cpi])};
|
||||
if (mapping.weight <= 0.f) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const int ctrl_point = ctrl_point_indices[cpi];
|
||||
assert(ctrl_point < static_cast<int>(_remap.size()));
|
||||
// It happens that weight is 0. In this case give the vertex a very small
|
||||
// weight so normalization succeeds.
|
||||
const float ctrl_point_weight =
|
||||
static_cast<float>(ctrl_point_weights[cpi]);
|
||||
const SkinMapping mapping = {
|
||||
joint, ctrl_point_weight == 0.f ? 1e-9f : ctrl_point_weight};
|
||||
|
||||
// remap.size() can be 0, skinned control point might not be used by any
|
||||
// polygon of the mesh. Sometimes, the mesh can have less points than at
|
||||
// the time of the skinning because a smooth operator was active when
|
||||
// skinning but has been deactivated during export.
|
||||
const int ctrl_point = ctrl_point_indices[cpi];
|
||||
const ControlPointRemap& remap = _remap[ctrl_point];
|
||||
for (size_t v = 0; v < remap.size(); ++v) {
|
||||
vertex_skin_mappings[remap[v]].push_back(mapping);
|
||||
@@ -560,6 +553,11 @@ bool BuildSkin(FbxMesh* _fbx_mesh,
|
||||
|
||||
// Stores joint's indices and weights.
|
||||
size_t influence_count = inv.size();
|
||||
if (influence_count == 0) {
|
||||
vertex_skin_mappings[i].push_back({0,1.f});
|
||||
influence_count = 1;
|
||||
}
|
||||
|
||||
if (influence_count > 0) {
|
||||
size_t j = 0;
|
||||
for (; j < influence_count; ++j) {
|
||||
@@ -579,11 +577,12 @@ bool BuildSkin(FbxMesh* _fbx_mesh,
|
||||
}
|
||||
|
||||
if (vertex_isnt_influenced) {
|
||||
ozz::log::Err() << "At least one vertex isn't influenced by any joints."
|
||||
<< std::endl;
|
||||
ozz::log::LogV() << "At least one vertex isn't influenced by any joints. "
|
||||
"It's been reassigned to root joint."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
return !vertex_isnt_influenced;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Limits the number of joints influencing a vertex.
|
||||
|
||||
Reference in New Issue
Block a user