[Bf-blender-cvs] [39ce10c] particles_refactor: Added a new attribute type 'POINTER', for storing rigid body pointers. This may not be the best way to map rigid bodies to particles, eventually a nicer way could be to make use of the userpointer in Bullet btRigidBody and store a weak reference to Blender types there instead. Storing rigid body pointers in the particles just mimicks the way the Object RBs work atm.

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


Commit: 39ce10c2f5d172f1bd477648bce50e936b734d79
Author: Lukas Tönne
Date:   Mon Dec 23 09:36:41 2013 +0100
https://developer.blender.org/rB39ce10c2f5d172f1bd477648bce50e936b734d79

Added a new attribute type 'POINTER', for storing rigid body pointers.
This may not be the best way to map rigid bodies to particles,
eventually a nicer way could be to make use of the userpointer in Bullet
btRigidBody and store a weak reference to Blender types there instead.
Storing rigid body pointers in the particles just mimicks the way the
Object RBs work atm.

The pointer attribute gets a flag 'TEMPORARY' to prevent it from being
stored in the cache and .blend files, since it's only valid during the
Bullet stepping anyway.

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

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 74e8678..8293f66 100644
--- a/source/blender/blenkernel/intern/nparticle.c
+++ b/source/blender/blenkernel/intern/nparticle.c
@@ -58,6 +58,7 @@ const char *BKE_nparticle_datatype_name(int datatype)
 		case PAR_ATTR_DATATYPE_NORMAL: return "normal";
 		case PAR_ATTR_DATATYPE_COLOR: return "color";
 		case PAR_ATTR_DATATYPE_MATRIX: return "matrix";
+		case PAR_ATTR_DATATYPE_POINTER: return "pointer";
 		default: return "";
 	}
 }
@@ -74,6 +75,7 @@ static size_t nparticle_elem_bytes(int datatype)
 			return sizeof(float)*3;
 		case PAR_ATTR_DATATYPE_COLOR: return sizeof(float)*4;
 		case PAR_ATTR_DATATYPE_MATRIX: return sizeof(float)*16;
+		case PAR_ATTR_DATATYPE_POINTER: return sizeof(void*);
 
 		default:
 			BLI_assert(false);	/* unknown datatype, should never happen */
@@ -165,6 +167,9 @@ static void nparticle_system_default_attributes(NParticleSystem *psys)
 	
 	/* common attributes */
 	BKE_nparticle_attribute_new(psys, "position", PAR_ATTR_DATATYPE_POINT, PAR_ATTR_PROTECTED);
+	
+	/* XXX bullet RB pointers, this should be based on actual simulation settings and requirements */
+	BKE_nparticle_attribute_new(psys, "rigidbody", PAR_ATTR_DATATYPE_POINTER, PAR_ATTR_PROTECTED | PAR_ATTR_READONLY | PAR_ATTR_TEMPORARY);
 }
 
 NParticleSystem *BKE_nparticle_system_new(void)
diff --git a/source/blender/makesdna/DNA_nparticle_types.h b/source/blender/makesdna/DNA_nparticle_types.h
index cd93002..c935d79 100644
--- a/source/blender/makesdna/DNA_nparticle_types.h
+++ b/source/blender/makesdna/DNA_nparticle_types.h
@@ -41,7 +41,8 @@ typedef struct NParticleAttributeDescription {
 typedef enum eParticleAttributeFlag {
 	PAR_ATTR_REQUIRED				= 1,	/* always exists */
 	PAR_ATTR_PROTECTED				= 2,	/* descriptor is immutable */
-	PAR_ATTR_READONLY				= 4		/* attribute data is read-only */
+	PAR_ATTR_READONLY				= 4,	/* attribute data is read-only */
+	PAR_ATTR_TEMPORARY				= 8		/* temporary runtime attribute (not stored in cache or blend files) */
 } eParticleAttributeFlag;
 
 /* particle attribute types */
@@ -54,7 +55,8 @@ typedef enum eParticleAttributeDataType {
 	PAR_ATTR_DATATYPE_POINT			= 5,
 	PAR_ATTR_DATATYPE_NORMAL		= 6,
 	PAR_ATTR_DATATYPE_COLOR			= 7,
-	PAR_ATTR_DATATYPE_MATRIX		= 8
+	PAR_ATTR_DATATYPE_MATRIX		= 8,
+	PAR_ATTR_DATATYPE_POINTER		= 9
 } eParticleAttributeDataType;
 
 typedef struct NParticleAttributeState {




More information about the Bf-blender-cvs mailing list