15class ChangeMeshAction :
public HistoryAction
18 using Obj = ObjectMesh;
21 ChangeMeshAction( std::string name,
const std::shared_ptr<ObjectMesh>& obj ) :
23 name_{ std::move(
name ) }
27 if (
auto m = obj->mesh() )
28 cloneMesh_ = std::make_shared<Mesh>( *m );
33 ChangeMeshAction( std::string name,
const std::shared_ptr<ObjectMesh>& obj, std::shared_ptr<Mesh> newMesh ) :
35 name_{ std::move(
name ) }
38 cloneMesh_ = objMesh_->updateMesh( std::move( newMesh ) );
41 virtual std::string
name()
const override
46 virtual void action( HistoryAction::Type )
override
51 cloneMesh_ = objMesh_->updateMesh( cloneMesh_ );
54 static void setObjectDirty(
const std::shared_ptr<ObjectMesh>& obj )
57 obj->setDirtyFlags( DIRTY_ALL );
60 [[nodiscard]]
virtual size_t heapBytes()
const override
66 std::shared_ptr<ObjectMesh> objMesh_;
67 std::shared_ptr<Mesh> cloneMesh_;
73class ChangeMeshUVCoordsAction :
public HistoryAction
76 using Obj = ObjectMeshHolder;
81 name_{ std::move(
name ) }
85 uvCoords_ = obj->getUVCoords();
90 ChangeMeshUVCoordsAction( std::string name,
const std::shared_ptr<ObjectMeshHolder>& obj, VertUVCoords&& newUvCoords ) :
92 name_{ std::move(
name ) }
96 uvCoords_ = std::move( newUvCoords );
97 obj->updateUVCoords( uvCoords_ );
101 virtual std::string
name()
const override
106 virtual void action( HistoryAction::Type )
override
111 objMesh_->updateUVCoords( uvCoords_ );
114 static void setObjectDirty(
const std::shared_ptr<ObjectMeshHolder>& obj )
117 obj->setDirtyFlags( DIRTY_UV );
120 [[nodiscard]]
virtual size_t heapBytes()
const override
122 return name_.capacity() + uvCoords_.heapBytes();
127 std::shared_ptr<ObjectMeshHolder> objMesh_;
133class ChangeTextureAction :
public HistoryAction
136 using Obj = ObjectMeshHolder;
141 name_{ std::move(
name ) }
144 textures_ = obj->getTextures();
148 ChangeTextureAction( std::string name,
const std::shared_ptr<ObjectMeshHolder>& obj, Vector<MeshTexture, TextureId>&& newTextures ) :
150 name_{ std::move(
name ) }
154 textures_ = std::move( newTextures );
155 obj->updateTextures( textures_ );
159 virtual std::string
name()
const override
164 virtual void action( HistoryAction::Type )
override
168 obj_->updateTextures( textures_ );
171 static void setObjectDirty(
const std::shared_ptr<ObjectMeshHolder>& obj )
174 obj->setDirtyFlags( DIRTY_TEXTURE );
177 [[nodiscard]]
virtual size_t heapBytes()
const override
183 std::shared_ptr<ObjectMeshHolder> obj_;
184 Vector<MeshTexture, TextureId> textures_;
189class ChangeMeshPointsAction :
public HistoryAction
192 using Obj = ObjectMesh;
197 name_{ std::move(
name ) }
201 if (
auto m = objMesh_->mesh() )
202 clonePoints_ = m->points;
206 ChangeMeshPointsAction( std::string name,
const std::shared_ptr<ObjectMesh>& obj, VertCoords && newCoords ) :
208 name_{ std::move(
name ) }
210 clonePoints_ = std::move( newCoords );
211 action( HistoryAction::Type::Redo );
214 virtual std::string
name()
const override
219 virtual void action( HistoryAction::Type )
override
224 if (
auto m = objMesh_->varMesh() )
226 std::swap( m->points, clonePoints_ );
227 objMesh_->setDirtyFlags( DIRTY_POSITION );
231 static void setObjectDirty(
const std::shared_ptr<ObjectMesh>& obj )
234 obj->setDirtyFlags( DIRTY_POSITION );
237 [[nodiscard]]
virtual size_t heapBytes()
const override
239 return name_.capacity() + clonePoints_.heapBytes();
242 const std::shared_ptr<ObjectMesh> & obj()
const {
return objMesh_; }
243 const VertCoords & clonePoints()
const {
return clonePoints_; }
246 std::shared_ptr<ObjectMesh> objMesh_;
247 VertCoords clonePoints_;
253class ChangeMeshTopologyAction :
public HistoryAction
256 using Obj = ObjectMesh;
261 name_{ std::move(
name ) }
265 if (
auto m = objMesh_->mesh() )
266 cloneTopology_ = m->topology;
272 name_{ std::move(
name ) }
274 cloneTopology_ = std::move( newTopology );
275 action( HistoryAction::Type::Redo );
278 virtual std::string
name()
const override
283 virtual void action( HistoryAction::Type )
override
288 if (
auto m = objMesh_->varMesh() )
290 std::swap( m->topology, cloneTopology_ );
291 objMesh_->setDirtyFlags( DIRTY_FACE );
295 static void setObjectDirty(
const std::shared_ptr<ObjectMesh>& obj )
298 obj->setDirtyFlags( DIRTY_FACE );
301 [[nodiscard]]
virtual size_t heapBytes()
const override
303 return name_.capacity() + cloneTopology_.heapBytes();
307 std::shared_ptr<ObjectMesh> objMesh_;
308 MeshTopology cloneTopology_;
314class ChangeMeshTexturePerFaceAction :
public HistoryAction
317 using Obj = ObjectMeshHolder;
322 name_{ std::move(
name ) }
326 texturePerFace_ = obj->getTexturePerFace();
333 name_{ std::move(
name ) }
337 texturePerFace_ = std::move( newTexturePerFace );
338 obj->updateTexturePerFace( texturePerFace_ );
342 virtual std::string
name()
const override
347 virtual void action( HistoryAction::Type )
override
352 objMesh_->updateTexturePerFace( texturePerFace_ );
355 static void setObjectDirty(
const std::shared_ptr<ObjectMeshHolder>& obj )
358 obj->setDirtyFlags( DIRTY_TEXTURE_PER_FACE );
361 [[nodiscard]]
virtual size_t heapBytes()
const override
363 return name_.capacity() + texturePerFace_.heapBytes();
367 Vector<TextureId, FaceId> texturePerFace_;
368 std::shared_ptr<ObjectMeshHolder> objMesh_;
unsafe ChangeMeshAction(MR._ByValue_ChangeMeshAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeMeshPointsAction(MR._ByValue_ChangeMeshPointsAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeMeshTexturePerFaceAction(MR._ByValue_ChangeMeshTexturePerFaceAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeMeshTopologyAction(MR._ByValue_ChangeMeshTopologyAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeMeshUVCoordsAction(MR._ByValue_ChangeMeshUVCoordsAction _other)
unsafe ChangeTextureAction(MR._ByValue_ChangeTextureAction _other)
unsafe void action(MR.HistoryAction.Type _1)
size_t heapBytes(const BitSet &bs)
returns the amount of memory given BitSet occupies on heap
Definition MRMesh/MRBitSet.h:298
std::string name(const T &primitive)
Definition MRFeatures.h:309
Definition MRCameraOrientationPlugin.h:8