[Bf-blender-cvs] [466ead9] temp_hair_modifiers: Simple infrastructure for registering particle modifier types, similar to type registration of mesh modifiers.

Lukas Tönne noreply at git.blender.org
Mon Feb 2 19:40:25 CET 2015


Commit: 466ead9314d4b1aa18480c711c8d4dc98bcf3a4b
Author: Lukas Tönne
Date:   Mon Feb 2 18:30:56 2015 +0100
Branches: temp_hair_modifiers
https://developer.blender.org/rB466ead9314d4b1aa18480c711c8d4dc98bcf3a4b

Simple infrastructure for registering particle modifier types, similar
to type registration of mesh modifiers.

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

M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/particle_modifier.c
M	source/blender/makesdna/DNA_particle_types.h
M	source/creator/creator.c
M	source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

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

diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 5923fc4..c9e5330 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -273,6 +273,17 @@ typedef struct ParticleInterpolationData {
 	int bspline;
 } ParticleInterpolationData;
 
+typedef struct ParticleModifierTypeInfo {
+	/* The user visible name for this modifier */
+	char name[32];
+
+	/* The DNA struct name for the modifier data type, used to write the DNA data out */
+	char structName[32];
+
+	/* The size of the modifier data type, used by allocation. */
+	int structSize;
+} ParticleModifierTypeInfo;
+
 #define PARTICLE_DRAW_DATA_UPDATED  1
 
 #define PSYS_FRAND_COUNT    1024
@@ -305,6 +316,9 @@ BLI_INLINE void psys_frand_vec(ParticleSystem *psys, unsigned int seed, float ve
 
 /* ----------- functions needed outside particlesystem ---------------- */
 /* particle.c */
+void particle_modifier_types_init(void);
+struct ParticleModifierTypeInfo *particle_modifier_type_info_get(ParticleModifierType type);
+
 int count_particles(struct ParticleSystem *psys);
 int count_particles_mod(struct ParticleSystem *psys, int totgr, int cur);
 
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index d61d6ee..397d8e8 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -141,6 +141,7 @@ set(SRC
 	intern/particle_child.c
 	intern/particle_distribute.c
 	intern/particle_interpolate.c
+	intern/particle_modifier.c
 	intern/particle_system.c
 	intern/pbvh.c
 	intern/pbvh_bmesh.c
diff --git a/source/blender/blenkernel/intern/particle_modifier.c b/source/blender/blenkernel/intern/particle_modifier.c
new file mode 100644
index 0000000..e528e8c
--- /dev/null
+++ b/source/blender/blenkernel/intern/particle_modifier.c
@@ -0,0 +1,70 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/particle_modifier.c
+ *  \ingroup bke
+ */
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
+#include "DNA_particle_types.h"
+
+#include "BKE_particle.h"
+
+static ParticleModifierTypeInfo *particle_modifier_types[NUM_PARTICLE_MODIFIER_TYPES];
+
+static ParticleModifierTypeInfo modifierType_None = {
+	"None",
+	"ParticleModifierData",
+	sizeof(ParticleModifierData)
+};
+
+static ParticleModifierTypeInfo modifierType_MeshDeform = {
+	"MeshDeform",
+	"MeshDeformParticleModifierData",
+	sizeof(MeshDeformParticleModifierData)
+};
+
+void particle_modifier_types_init(void)
+{
+#define INIT_TYPE(name) (particle_modifier_types[eParticleModifierType_##name] = &modifierType_##name)
+	INIT_TYPE(None);
+	INIT_TYPE(MeshDeform);
+#undef INIT_TYPE
+}
+
+ParticleModifierTypeInfo *particle_modifier_type_info_get(ParticleModifierType type)
+{
+	/* type unsigned, no need to check < 0 */
+	if (type < NUM_PARTICLE_MODIFIER_TYPES && particle_modifier_types[type]->name[0] != '\0') {
+		return particle_modifier_types[type];
+	}
+	else {
+		return NULL;
+	}
+}
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 89f7903..a890b49 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -158,6 +158,21 @@ typedef struct SPHFluidSettings {
 #define SPH_SOLVER_DDR					0
 #define SPH_SOLVER_CLASSICAL			1
 
+typedef enum ParticleModifierType {
+	eParticleModifierType_None              = 0,
+	eParticleModifierType_MeshDeform        = 1,
+	NUM_PARTICLE_MODIFIER_TYPES
+} ParticleModifierType;
+
+typedef struct ParticleModifierData {
+	int type;
+	int flag;
+} ParticleModifierData;
+
+typedef struct MeshDeformParticleModifierData {
+	ParticleModifierData md;
+} MeshDeformParticleModifierData;
+
 typedef struct ParticleSettings {
 	ID id;
 	struct AnimData *adt;
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 1540648..dbfb51d 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -1582,6 +1582,7 @@ int main(
 	IMB_init();
 	BKE_images_init();
 	BKE_modifier_init();
+	particle_modifier_types_init();
 	DAG_init();
 
 	BKE_brush_system_init();
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 915fe61..0113054 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -463,6 +463,7 @@ int main(int argc, char** argv)
 	IMB_init();
 	BKE_images_init();
 	BKE_modifier_init();
+	particle_modifier_types_init();
 	DAG_init();
 
 #ifdef WITH_FFMPEG




More information about the Bf-blender-cvs mailing list