[Bf-blender-cvs] [02e687d] particles_refactor: Flags for particle attributes:
Lukas Tönne
noreply at git.blender.org
Tue Apr 22 12:06:02 CEST 2014
Commit: 02e687d02cecc579c103045cb03e00a39c20aacc
Author: Lukas Tönne
Date: Tue Dec 17 15:07:05 2013 +0100
https://developer.blender.org/rB02e687d02cecc579c103045cb03e00a39c20aacc
Flags for particle attributes:
- REQUIRED: These attributes are always existent in every particle
system. Currently this is only the "id" layer, position might also
be added
- PROTECTED: Attribute name, datatype, etc. can not be changed. Only
user-defined attributes can be modified this way.
===================================================================
M source/blender/blenkernel/BKE_nparticle.h
M source/blender/blenkernel/intern/nparticle.c
M source/blender/makesdna/DNA_nparticle_types.h
M source/blender/makesrna/intern/rna_nparticle.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_nparticle.h b/source/blender/blenkernel/BKE_nparticle.h
index 72fa414..74d21c8 100644
--- a/source/blender/blenkernel/BKE_nparticle.h
+++ b/source/blender/blenkernel/BKE_nparticle.h
@@ -44,7 +44,7 @@ void BKE_nparticle_system_free(struct NParticleSystem *psys);
struct NParticleSystem *BKE_nparticle_system_copy(struct NParticleSystem *psys);
struct NParticleAttribute *BKE_nparticle_attribute_find(struct NParticleSystem *psys, const char *name);
-struct NParticleAttribute *BKE_nparticle_attribute_new(struct NParticleSystem *psys, const char *name, int datatype);
+struct NParticleAttribute *BKE_nparticle_attribute_new(struct NParticleSystem *psys, const char *name, int datatype, int flag);
void BKE_nparticle_attribute_remove(struct NParticleSystem *psys, struct NParticleAttribute *attr);
void BKE_nparticle_attribute_remove_all(struct NParticleSystem *psys);
void BKE_nparticle_attribute_move(struct NParticleSystem *psys, int from_index, int to_index);
diff --git a/source/blender/blenkernel/intern/nparticle.c b/source/blender/blenkernel/intern/nparticle.c
index 0504e40..a5b1785 100644
--- a/source/blender/blenkernel/intern/nparticle.c
+++ b/source/blender/blenkernel/intern/nparticle.c
@@ -174,8 +174,8 @@ NParticleSystem *BKE_nparticle_system_new(void)
psys->state = nparticle_state_new(psys);
- /* fixed attributes */
- BKE_nparticle_attribute_new(psys, "id", PAR_ATTR_DATATYPE_INT);
+ /* required attributes */
+ BKE_nparticle_attribute_new(psys, "id", PAR_ATTR_DATATYPE_INT, PAR_ATTR_REQUIRED);
return psys;
}
@@ -215,7 +215,7 @@ NParticleAttribute *BKE_nparticle_attribute_find(NParticleSystem *psys, const ch
return NULL;
}
-NParticleAttribute *BKE_nparticle_attribute_new(NParticleSystem *psys, const char *name, int datatype)
+NParticleAttribute *BKE_nparticle_attribute_new(NParticleSystem *psys, const char *name, int datatype, int flag)
{
NParticleAttribute *attr;
@@ -228,6 +228,7 @@ NParticleAttribute *BKE_nparticle_attribute_new(NParticleSystem *psys, const cha
attr = MEM_callocN(sizeof(NParticleAttribute), "particle system attribute");
BLI_strncpy(attr->desc.name, name, sizeof(attr->desc.name));
attr->desc.datatype = datatype;
+ attr->desc.flag = flag;
BLI_addtail(&psys->attributes, attr);
diff --git a/source/blender/makesdna/DNA_nparticle_types.h b/source/blender/makesdna/DNA_nparticle_types.h
index 8e09e6c..f88fa97 100644
--- a/source/blender/makesdna/DNA_nparticle_types.h
+++ b/source/blender/makesdna/DNA_nparticle_types.h
@@ -35,9 +35,14 @@
typedef struct NParticleAttributeDescription {
char name[64];
int datatype;
- int pad;
+ int flag;
} NParticleAttributeDescription;
+typedef enum eParticleAttributeFlag {
+ PAR_ATTR_REQUIRED = 1, /* always exists */
+ PAR_ATTR_PROTECTED = 2 /* descriptor is immutable */
+} eParticleAttributeFlag;
+
/* particle attribute types */
typedef enum eParticleAttributeDataType {
PAR_ATTR_DATATYPE_INTERNAL = 0, /* for static attributes with special types */
diff --git a/source/blender/makesrna/intern/rna_nparticle.c b/source/blender/makesrna/intern/rna_nparticle.c
index 3ad2318..5bccb58 100644
--- a/source/blender/makesrna/intern/rna_nparticle.c
+++ b/source/blender/makesrna/intern/rna_nparticle.c
@@ -339,7 +339,7 @@ static NParticleAttribute *rna_NParticleSystem_attributes_new(NParticleSystem *p
BKE_reportf(reports, RPT_ERROR_INVALID_INPUT, "Particle attribute with name %s already exists", name);
return NULL;
}
- return BKE_nparticle_attribute_new(psys, name, datatype);
+ return BKE_nparticle_attribute_new(psys, name, datatype, 0);
}
static void rna_NParticleSystem_attributes_remove(NParticleSystem *psys, NParticleAttribute *attr)
More information about the Bf-blender-cvs
mailing list