[Bf-blender-cvs] [b6ced99] particles_refactor: Use a fixed "id" attribute, this will be required for all sorts of particle functions and identify particles unambiguously.

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


Commit: b6ced99abb38ba1d5d2be3e67cef345a51ad17b1
Author: Lukas Tönne
Date:   Sun Dec 15 11:48:17 2013 +0100
https://developer.blender.org/rBb6ced99abb38ba1d5d2be3e67cef345a51ad17b1

Use a fixed "id" attribute, this will be required for all sorts of
particle functions and identify particles unambiguously.

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

M	source/blender/blenkernel/intern/nparticle.c
M	source/blender/makesdna/DNA_nparticle_types.h

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

diff --git a/source/blender/blenkernel/intern/nparticle.c b/source/blender/blenkernel/intern/nparticle.c
index 3050993..9f2798c 100644
--- a/source/blender/blenkernel/intern/nparticle.c
+++ b/source/blender/blenkernel/intern/nparticle.c
@@ -79,6 +79,10 @@ static void nparticle_attribute_state_copy(NParticleAttributeState *to, NParticl
 NParticleSystem *BKE_nparticle_system_new(void)
 {
 	NParticleSystem *psys = MEM_callocN(sizeof(NParticleSystem), "nparticle system");
+	
+	/* fixed attributes */
+	psys->attribute_id = BKE_nparticle_attribute_new(psys, "id", PAR_ATTR_DATATYPE_INT);
+	
 	return psys;
 }
 
@@ -91,11 +95,14 @@ void BKE_nparticle_system_free(NParticleSystem *psys)
 NParticleSystem *BKE_nparticle_system_copy(NParticleSystem *psys)
 {
 	NParticleSystem *npsys = MEM_dupallocN(psys);
-	NParticleAttribute *attr;
+	NParticleAttribute *attr, *nattr;
 	
 	npsys->attributes.first = npsys->attributes.last = NULL;
 	for (attr = psys->attributes.first; attr; attr = attr->next) {
-		BKE_nparticle_attribute_copy(npsys, psys, attr);
+		nattr = BKE_nparticle_attribute_copy(npsys, psys, attr);
+		
+		if (attr == psys->attribute_id)
+			npsys->attribute_id = nattr;
 	}
 	
 	return npsys;
diff --git a/source/blender/makesdna/DNA_nparticle_types.h b/source/blender/makesdna/DNA_nparticle_types.h
index 7f6ebe9..e137be5 100644
--- a/source/blender/makesdna/DNA_nparticle_types.h
+++ b/source/blender/makesdna/DNA_nparticle_types.h
@@ -64,6 +64,7 @@ typedef struct NParticleAttribute {
 
 typedef struct NParticleSystem {
 	ListBase attributes;				/* definition of available attributes */
+	struct NParticleAttribute *attribute_id;
 } NParticleSystem;
 
 #endif




More information about the Bf-blender-cvs mailing list