[Bf-blender-cvs] [a54ce3d] alembic: Added optional motion state data to Strands.
Lukas Tönne
noreply at git.blender.org
Sun Mar 29 20:27:53 CEST 2015
Commit: a54ce3d26a5387052e8b14d20f868ed34f564c2c
Author: Lukas Tönne
Date: Sun Mar 29 20:23:54 2015 +0200
Branches: alembic
https://developer.blender.org/rBa54ce3d26a5387052e8b14d20f868ed34f564c2c
Added optional motion state data to Strands.
This implements the distinction between the strand goal position
(grooming data, shape keys) and the result of dynamics simulation.
===================================================================
M source/blender/blenkernel/BKE_strands.h
M source/blender/blenkernel/intern/strands.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_strands.h b/source/blender/blenkernel/BKE_strands.h
index f19c137..513407a 100644
--- a/source/blender/blenkernel/BKE_strands.h
+++ b/source/blender/blenkernel/BKE_strands.h
@@ -27,6 +27,11 @@ typedef struct StrandsVertex {
float weight;
} StrandsVertex;
+typedef struct StrandsMotionState {
+ float co[3];
+ float vel[3];
+} StrandsMotionState;
+
typedef struct StrandsCurve {
int numverts;
} StrandsCurve;
@@ -35,17 +40,23 @@ typedef struct Strands {
StrandsCurve *curves;
StrandsVertex *verts;
int totcurves, totverts;
+
+ /* optional */
+ StrandsMotionState *state;
} Strands;
struct Strands *BKE_strands_new(int strands, int verts);
void BKE_strands_free(struct Strands *strands);
+void BKE_strands_add_motion_state(struct Strands *strands);
+
/* ------------------------------------------------------------------------- */
typedef struct StrandIterator {
int index, tot;
StrandsCurve *curve;
StrandsVertex *verts;
+ StrandsMotionState *state;
} StrandIterator;
BLI_INLINE void BKE_strand_iter_init(StrandIterator *iter, Strands *strands)
@@ -54,6 +65,7 @@ BLI_INLINE void BKE_strand_iter_init(StrandIterator *iter, Strands *strands)
iter->index = 0;
iter->curve = strands->curves;
iter->verts = strands->verts;
+ iter->state = strands->state;
}
BLI_INLINE bool BKE_strand_iter_valid(StrandIterator *iter)
@@ -68,12 +80,15 @@ BLI_INLINE void BKE_strand_iter_next(StrandIterator *iter)
++iter->index;
++iter->curve;
iter->verts += numverts;
+ if (iter->state)
+ iter->state += numverts;
}
typedef struct StrandVertexIterator {
int index, tot;
StrandsVertex *vertex;
+ StrandsMotionState *state;
} StrandVertexIterator;
BLI_INLINE void BKE_strand_vertex_iter_init(StrandVertexIterator *iter, StrandIterator *strand_iter)
@@ -81,6 +96,7 @@ BLI_INLINE void BKE_strand_vertex_iter_init(StrandVertexIterator *iter, StrandIt
iter->tot = strand_iter->curve->numverts;
iter->index = 0;
iter->vertex = strand_iter->verts;
+ iter->state = strand_iter->state;
}
BLI_INLINE bool BKE_strand_vertex_iter_valid(StrandVertexIterator *iter)
@@ -91,6 +107,8 @@ BLI_INLINE bool BKE_strand_vertex_iter_valid(StrandVertexIterator *iter)
BLI_INLINE void BKE_strand_vertex_iter_next(StrandVertexIterator *iter)
{
++iter->vertex;
+ if (iter->state)
+ ++iter->state;
++iter->index;
}
diff --git a/source/blender/blenkernel/intern/strands.c b/source/blender/blenkernel/intern/strands.c
index 8130382..51e9ee2 100644
--- a/source/blender/blenkernel/intern/strands.c
+++ b/source/blender/blenkernel/intern/strands.c
@@ -43,3 +43,10 @@ void BKE_strands_free(Strands *strands)
MEM_freeN(strands);
}
}
+
+void BKE_strands_add_motion_state(Strands *strands)
+{
+ if (!strands->state) {
+ strands->state = MEM_mallocN(sizeof(StrandsMotionState) * strands->totverts, "strand motion states");
+ }
+}
More information about the Bf-blender-cvs
mailing list