//================================================================
// E3D library
//
// - Generic "Shape" header
//
// AUTHOR:  Gabor Nagy
// DATE:    2024-Apr-11 03:39:03
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//================================================================
#ifndef _E3D_Shape_h
#define _E3D_Shape_h

#ifndef _E3D_Face_h
#include <E3D/Face.h>
#endif

#ifndef _E3D_Model_h
#include <E3D/Model.h>
#endif

#ifndef _E3D_Mesh_h
#include <E3D/Mesh.h>
#endif

#ifndef _E3D_Polygon_h
#include <E3D/Polygon.h>
#endif


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif

typedef struct E3dShapeSnapshot_S  E3dShapeSnapshot;


#define E3dShapeSnapshotCore\
	EObject*      Object;\
	void          (*FreeContents)(E3dShapeSnapshot* PThis);\
	EChangeFlags  (*UndoRedo)(E3dScene* PScene, const E3dShapeSnapshot* PThis, EOpNodeListA* POpNodes, const int POperation);\
\
	E3dMatrix     LocalToWorldMatrix;  /* Matrix used for translate operations on the Points  */\
	EBool         LocalToWorldMatrixIsNotIdentity

struct E3dShapeSnapshot_S
{
	E3dShapeSnapshotCore;
};


// These structures are used for taking "snapshots" of Vertices/Points/Spline keys etc. for interactive
// transforming and for Undo/Redo of transforming and deleting Points
//
typedef struct
{
	E3dShapeSnapshotCore;

	E3dPointSnapshot*  VertexSnapshots;
	E3dPointSnapshot*  VertexSnapshotsRedo;
	EIndex             VertexSnapshots_Count;
	E3dVertexSize      VertexSnapshotSize;

	const EResource*   Attribute;                 // E.g. a pointer to the EResource representing vertex normals
	int                AttributeComponentOffset;  // E.g. the Y component of an E3dCoord3
	E3dVertexSize      BytesPerAttribute;
	EUpdateFlags       UpdateFlags;               // E.g. E3dUpdateMeshSHAPE if Attribute points to Vertex positions
} E3dVerticesSnapshot;


typedef struct
{
	E3dShapeSnapshotCore;

	E3dSnapshotSplineCV*  SnapshotCVs;EIndex  CVs_Count;
	unsigned int          CVSize;
	char                  SubCV;     // For Bezier curves
} E3dSplineCVsSnapshot;


extern void  E3dShapeSnapshots_Free(E3dShapeSnapshot*** PShapeSnapshotsP, EIndex* PNumOfShapeSnapshotsP);

extern void          E3dShapeSnapshotVertices_FreeContents(E3dShapeSnapshot* PShapeSnapshot);
extern EChangeFlags  E3dShapeSnapshotVertices_UndoRedo(E3dScene* PScene, const E3dShapeSnapshot* PShapeSnapshot, EOpNodeListA* POpNodes, const int POperation);
extern EChangeFlags  E3dShapeSnapshots_UndoRedo(E3dShapeSnapshot* const* PShapeSnapshots, const EIndex PShapeSnapshots_Count, const int POperation);

extern void          E3dShapeSnapshotSplineCVs_FreeContents(E3dShapeSnapshot* PShapeSnapshot);
extern EChangeFlags  E3dShapeSnapshotSplineCVs_Undo(E3dScene* PScene, const E3dShapeSnapshot* PShapeSnapshot, EOpNodeListA* POpNodes, const int POperation);


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
}	// Close scope of 'extern "C"' declaration
#endif

#endif  // _E3D_Shape_h
