Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-02-16 20:32:37 +0300
committerHans Goudey <h.goudey@me.com>2022-02-16 20:32:37 +0300
commitc324cf153924ae2ec5b7c59eabff71652847aeae (patch)
treef12f07ed61b018481e4bc45a7687567c48c952aa /source/blender/makesdna/DNA_curves_types.h
parent5b73017ddb679bb050fe13e4d9e3e5b04ea559b9 (diff)
Curves: Further implementation of new curves data structure
The general idea here is to wrap the `CurvesGeometry` DNA struct with a C++ class that can do most of the heavy lifting for the curve geometry. Using a C++ class allows easier ways to group methods, easier const correctness, and code that's more readable and faster to write. This way, it works much more like a version of `CurveEval` that uses more efficient attribute storage. This commit adds the structure of some yet-to-be-implemented code, the largest thing being mutexes and vectors meant to hold lazily calculated evaluated positions, tangents, and normals. That part might change slightly, but it's helpful to be able to see the direction this commit is aiming in. In particular, the inherently single-threaded accumulated lengths and Bezier evaluated point offsets might be cached. Ref T95355 Differential Revision: https://developer.blender.org/D14054
Diffstat (limited to 'source/blender/makesdna/DNA_curves_types.h')
-rw-r--r--source/blender/makesdna/DNA_curves_types.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h
index 03a587c896b..c45de832e3c 100644
--- a/source/blender/makesdna/DNA_curves_types.h
+++ b/source/blender/makesdna/DNA_curves_types.h
@@ -13,6 +13,33 @@
extern "C" {
#endif
+#ifdef __cplusplus
+namespace blender::bke {
+class CurvesGeometryRuntime;
+} // namespace blender::bke
+using CurvesGeometryRuntimeHandle = blender::bke::CurvesGeometryRuntime;
+#else
+typedef struct CurvesGeometryRuntimeHandle CurvesGeometryRuntimeHandle;
+#endif
+
+typedef enum CurveType {
+ CURVE_TYPE_CATMULL_ROM = 0,
+ CURVE_TYPE_POLY = 1,
+ CURVE_TYPE_BEZIER = 2,
+ CURVE_TYPE_NURBS = 3,
+} CurveType;
+
+typedef enum HandleType {
+ /** The handle can be moved anywhere, and doesn't influence the point's other handle. */
+ BEZIER_HANDLE_FREE = 0,
+ /** The location is automatically calculated to be smooth. */
+ BEZIER_HANDLE_AUTO = 1,
+ /** The location is calculated to point to the next/previous control point. */
+ BEZIER_HANDLE_VECTOR = 2,
+ /** The location is constrained to point in the opposite direction as the other handle. */
+ BEZIER_HANDLE_ALIGN = 3,
+} HandleType;
+
/**
* A reusable data structure for geometry consisting of many curves. All control point data is
* stored contiguously for better efficiency. Data for each curve is stored as a slice of the
@@ -34,13 +61,19 @@ typedef struct CurvesGeometry {
float *radius;
/**
+ * The type of each curve. #CurveType.
+ * \note This data is owned by #curve_data.
+ */
+ int8_t *curve_type;
+
+ /**
* The start index of each curve in the point data. The size of each curve can be calculated by
* subtracting the offset from the next offset. That is valid even for the last curve because
* this array is allocated with a length one larger than the number of splines.
*
* \note This is *not* stored in #CustomData because its size is one larger than #curve_data.
*/
- int *offsets;
+ int *curve_offsets;
/**
* All attributes stored on control points (#ATTR_DOMAIN_POINT).
@@ -60,6 +93,11 @@ typedef struct CurvesGeometry {
* The number of curves in the data-block.
*/
int curve_size;
+
+ /**
+ * Runtime data for curves, stored as a pointer to allow defining this as a C++ class.
+ */
+ CurvesGeometryRuntimeHandle *runtime;
} CurvesGeometry;
typedef struct Curves {