File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 22// For conditions of distribution and use, see copyright notice in irrlicht.h
33
44#include " WeightBuffer.h"
5+ #include " vector3d.h"
56
67#include < algorithm>
78#include < numeric>
@@ -61,16 +62,23 @@ void WeightBuffer::skin(IVertexBuffer *dst,
6162 const std::vector<core::matrix4> &joint_transforms) const
6263{
6364 assert (animated_vertices.has_value ());
65+ bool dirty = false ;
6466 for (u32 i = 0 ; i < animated_vertices->size (); ++i) {
65-
6667 u32 vertex_id = (*animated_vertices)[i];
6768 auto pos = static_positions[i];
6869 auto normal = static_normals[i];
6970 skinVertex (vertex_id, pos, normal, joint_transforms);
70- dst->getPosition (vertex_id) = pos;
71- dst->getNormal (vertex_id) = normal;
71+ auto update = [&dirty](core::vector3df &dst, core::vector3df src) {
72+ if (dst != src) {
73+ dst = src;
74+ // Only mark as dirty if actually changed: Reupload may be expensive.
75+ dirty = true ;
76+ }
77+ };
78+ update (dst->getPosition (vertex_id), pos);
79+ update (dst->getNormal (vertex_id), normal);
7280 }
73- if (!animated_vertices-> empty () )
81+ if (dirty )
7482 dst->setDirty ();
7583}
7684
You can’t perform that action at this time.
0 commit comments