[Bf-blender-cvs] [f2bdf4b] particles_refactor: New function for adding a particle based on particle id.

Lukas Tönne noreply at git.blender.org
Tue Apr 22 12:05:53 CEST 2014


Commit: f2bdf4bd4cc5910e18e636288b6d2c6160d421ef
Author: Lukas Tönne
Date:   Mon Dec 16 18:41:47 2013 +0100
https://developer.blender.org/rBf2bdf4bd4cc5910e18e636288b6d2c6160d421ef

New function for adding a particle based on particle id.

===================================================================

M	source/blender/blenkernel/BKE_nparticle.h
M	source/blender/blenkernel/intern/nparticle.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_nparticle.h b/source/blender/blenkernel/BKE_nparticle.h
index f4cdfc6..45ee503 100644
--- a/source/blender/blenkernel/BKE_nparticle.h
+++ b/source/blender/blenkernel/BKE_nparticle.h
@@ -56,6 +56,7 @@ struct NParticleAttributeState *BKE_nparticle_state_find_attribute(struct NParti
 
 int BKE_nparticle_find_index(struct NParticleState *state, NParticleID id);
 bool BKE_nparticle_exists(struct NParticleState *state, NParticleID id);
+int BKE_nparticle_add(struct NParticleState *state, NParticleID id);
 
 typedef struct NParticleIterator {
 	struct NParticleState *state;
diff --git a/source/blender/blenkernel/intern/nparticle.c b/source/blender/blenkernel/intern/nparticle.c
index db63989..fd40cdd 100644
--- a/source/blender/blenkernel/intern/nparticle.c
+++ b/source/blender/blenkernel/intern/nparticle.c
@@ -308,7 +308,21 @@ int BKE_nparticle_find_index(NParticleState *state, NParticleID id)
 
 bool BKE_nparticle_exists(NParticleState *state, NParticleID id)
 {
-	return BKE_nparticle_find_index(state, id) != -1;
+	return BKE_nparticle_find_index(state, id) >= 0;
+}
+
+int BKE_nparticle_add(NParticleState *state, NParticleID id)
+{
+	int index = BKE_nparticle_find_index(state, id);
+	if (index < 0) {
+		NParticleAttributeState *attrstate;
+		for (attrstate = state->attributes; attrstate->hashkey; ++attrstate) {
+			BLI_pbuf_add_elements(&attrstate->data, 1);
+			index = attrstate->data.totelem - 1;
+		}
+	}
+	
+	return index;
 }




More information about the Bf-blender-cvs mailing list