[Bf-blender-cvs] [bc3e02f] particles_refactor: Copied over some old code, to be adapted.

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


Commit: bc3e02f8fe9f3317804098375405a48623a7d7a2
Author: Lukas Tönne
Date:   Tue Jun 4 10:22:32 2013 +0200
https://developer.blender.org/rBbc3e02f8fe9f3317804098375405a48623a7d7a2

Copied over some old code, to be adapted.

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

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/makesdna/DNA_pagedbuffer_types.h
M	source/blender/modifiers/CMakeLists.txt
A	source/blender/modifiers/intern/MOD_nparticle.c

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

diff --git a/source/blender/blenkernel/BKE_nparticle.h b/source/blender/blenkernel/BKE_nparticle.h
index d1bbbe7..c796f48 100644
--- a/source/blender/blenkernel/BKE_nparticle.h
+++ b/source/blender/blenkernel/BKE_nparticle.h
@@ -15,22 +15,107 @@
  * 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
+ * Copyright 2011, Blender Foundation.
  *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
+ * Contributor(s): Lukas Toenne
  *
  * ***** END GPL LICENSE BLOCK *****
  */
-#ifndef __BKE_NPARTICLE_H__
-#define __BKE_NPARTICLE_H__
+
+#ifndef BKE_NPARTICLE_H
+#define BKE_NPARTICLE_H
 
 /** \file BKE_nparticle.h
  *  \ingroup bke
  */
 
-struct bParticleBuffer;
+#include "BLI_math.h"
+#include "BLI_pagedbuffer.h"
+
+#include "DNA_nparticle_types.h"
+
+#include "BKE_node.h"
+
+struct Object;
+struct Scene;
+struct DupliObject;
+struct NParticleSystem;
+struct NParticlesModifierData;
+struct NParticleDupliObject;
+
+
+#if 0 /* old code */
+BLI_INLINE int pit_get_particle_flag(struct NParticleSystem *psys, struct bPagedBufferIterator *it, NParticleFlagLayerType flag)
+{
+	return (((*PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_FLAG]->layer, NParticleFlagLayerType)) & flag) != 0);
+}
+BLI_INLINE void pit_set_particle_flag(struct NParticleSystem *psys, struct bPagedBufferIterator *it, NParticleFlagLayerType flag)
+{
+	(*PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_FLAG]->layer_write, NParticleFlagLayerType)) |= flag;
+}
+BLI_INLINE void pit_clear_particle_flag(struct NParticleSystem *psys, struct bPagedBufferIterator *it, NParticleFlagLayerType flag)
+{
+	(*PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_FLAG]->layer_write, NParticleFlagLayerType)) &= ~flag;
+}
+
+BLI_INLINE NParticleRNG *pit_get_particle_rng(struct NParticleSystem *psys, struct bPagedBufferIterator *it)
+{
+	return PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_RANDOM_SEED]->layer, NParticleRNG);
+}
+
+BLI_INLINE const NParticleVector *pit_get_particle_position(struct NParticleSystem *psys, struct bPagedBufferIterator *it)
+{
+	return PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_POSITION]->layer, NParticleVector);
+}
+
+BLI_INLINE void pit_set_particle_position(struct NParticleSystem *psys, struct bPagedBufferIterator *it, const NParticleVector *value)
+{
+	copy_v3_v3((float *)PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_POSITION]->layer_write, NParticleVector), (const float *)value);
+}
+
+BLI_INLINE const NParticleQuaternion *pit_get_particle_rotation(struct NParticleSystem *psys, struct bPagedBufferIterator *it)
+{
+	return PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_ROTATION]->layer, NParticleQuaternion);
+}
+
+BLI_INLINE void pit_set_particle_rotation(struct NParticleSystem *psys, struct bPagedBufferIterator *it, const NParticleQuaternion *value)
+{
+	copy_qt_qt((float *)PBUF_GET_DATA_POINTER(it, psys->standard_attribute[PAR_ATTR_TYPE_ROTATION]->layer_write, NParticleQuaternion), (const float *)value);
+}
+
+struct bPagedBufferIterator pit_init_particles(struct NParticleSystem *psys);
+struct bPagedBufferIterator pit_init_particles_at(struct NParticleSystem *psys, int index);
+void pit_next_particle(struct NParticleSystem *psys, struct bPagedBufferIterator *it);
+
+void npar_init(struct NParticleSystem *psys);
+void npar_free(struct NParticleSystem *psys);
+void npar_copy(struct NParticleSystem *to, struct NParticleSystem *from);
+
+struct bPagedBufferIterator npar_create_particles(struct NParticleSystem *psys, struct NParticleSource *source, float time, float num);
+void npar_free_dead_particles(struct NParticleSystem *psys);
+
+void npar_reset(struct NParticleSystem *psys);
+
+struct NParticleAttribute *npar_find_custom_attribute(struct NParticleSystem *psys, const char *name);
+void npar_custom_attribute_unique_name(struct ListBase *attributes, struct NParticleAttribute *attr);
+void npar_init_attribute(struct NParticleAttribute *attr, int type, struct NParticleSystem *psys);
+void npar_init_custom_attribute(struct NParticleAttribute *attr, int datatype, const char *name, struct NParticleSystem *psys);
+struct NParticleAttribute *npar_add_attribute(struct NParticleSystem *psys, int type);
+struct NParticleAttribute *npar_add_custom_attribute(struct NParticleSystem *psys, int datatype, const char *name);
+void npar_remove_attribute(struct NParticleSystem *psys, struct NParticleAttribute *attr);
+int npar_socket_type_from_attribute(struct NParticleAttribute *attr);
+
+void npar_update_state(struct NParticleAttribute *attr, struct bPagedBufferIterator *pit);
+void npar_update_state_all(struct NParticleSystem *psys, struct bPagedBufferIterator *pit);
+
+struct NParticleSource *npar_source_new(struct NParticleSystem *psys);
+
+struct NParticleDupliObject *npar_dupli_object_new(void);
+void npar_dupli_object_free(struct NParticleDupliObject *dupli);
+struct NParticleDupliObject *npar_dupli_object_copy(struct NParticleDupliObject *dupli);
+void npar_create_dupli_object(struct NParticlesModifierData *pmd, struct bPagedBufferIterator *pit, struct Object **ob, float mat[][4]);
+
+void npar_filter_objects(struct Scene *scene, int type, void *userdata, void (*walk)(void *userdata, Scene *scene, struct Object *ob, struct bNodeTree *ntree));
+#endif
 
 #endif
diff --git a/source/blender/blenkernel/intern/nparticle.c b/source/blender/blenkernel/intern/nparticle.c
index 90a52d7..bd486e8 100644
--- a/source/blender/blenkernel/intern/nparticle.c
+++ b/source/blender/blenkernel/intern/nparticle.c
@@ -15,12 +15,9 @@
  * 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) 2001-2002 by NaN Holding BV.
- * All rights reserved.
+ * Copyright 2011, Blender Foundation.
  *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
+ * Contributor(s): Lukas Toenne
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -29,11 +26,609 @@
  *  \ingroup bke
  */
 
+
+#include <assert.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
 #include "MEM_guardedalloc.h"
 
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_node_types.h"
+#include "DNA_nparticle_types.h"
+#include "DNA_object_types.h"
+#include "DNA_pagedbuffer_types.h"
+#include "DNA_scene_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_ghash.h"
+#include "BLI_math.h"
 #include "BLI_pagedbuffer.h"
+#include "BLI_path_util.h"
+#include "BLI_utildefines.h"
 
-#include "DNA_nparticle_types.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_global.h"
+#include "BKE_group.h"
+#include "BKE_main.h"
+#include "BKE_modifier.h"
+#include "BKE_node.h"
 
 #include "BKE_nparticle.h"
+#include "BKE_object.h"
+#include "BKE_library.h"
+#include "BKE_depsgraph.h"
+
+#include "RNA_access.h"
+
+
+#if 0 /* old code */
+struct bPagedBufferIterator pit_init_particles(struct NParticleSystem *psys)
+{
+	return pit_init(&psys->particles);
+}
+
+struct bPagedBufferIterator pit_init_particles_at(struct NParticleSystem *psys, int index)
+{
+	return pit_init_at(&psys->particles, index);
+}
+
+/* skips dead particles */
+void pit_next_particle(struct NParticleSystem *psys, bPagedBufferIterator *it)
+{
+	do {
+		pit_next(it);
+	} while (it->valid && pit_get_particle_flag(psys, it, NPAR_DEAD));
+}
+
+static void pbuf_print(bPagedBuffer *pbuf)
+{
+	bPagedBufferLayerInfo *layer = pbuf->layers.first;
+//	char indent[64] = {'\0'};
+	
+	while (layer) {
+		printf("Layer %s: ", layer->name);
+		printf(" index=%d, stride=%d\n", layer->layer, layer->stride);
+		
+		layer = layer->next;
+	}
+}
+
+void npar_init(NParticleSystem *psys)
+{
+	/* XXX NPARTICLES page size default? */
+	pbufInit(&psys->particles, 1024);
+	
+	npar_add_attribute(psys, PAR_ATTR_TYPE_FLAG);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_ID);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_SOURCE_ID);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_RANDOM_SEED);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_REM_INDEX);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_BIRTH_TIME);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_POSITION);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_VELOCITY);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_FORCE);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_MASS);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_ROTATION);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_ANGULAR_VELOCITY);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_TORQUE);
+	npar_add_attribute(psys, PAR_ATTR_TYPE_ANGULAR_MASS);
+	
+	nodePathMapInit(&psys->node_path_map);
+	
+	psys->next_source_id = 0;
+	
+	/* pbuf_print(&psys->particles); */
+}
+
+void npar_free(NParticleSystem *psys)
+{
+	NParticleAttribute *attr, *attr_next;
+	
+	/* free attributes */
+	for (attr=psys->attributes.first; attr; attr=attr_next) {
+		attr_next = attr->next;
+		npar_remove_attribute(psys, attr);
+	}
+	
+	nodePathMapFree(&psys->node_path_map);
+	
+	pbufFree(&psys->particles);
+}
+
+static NParticleAttribute *npar_copy_attribute(NParticleAttribute *attr)
+{
+	NParticleAttribute *nattr = MEM_dupallocN(attr);
+	nattr->prev = nattr->next = NULL;
+	
+	nattr->layer = attr->layer->new_layer;
+	nattr->layer_write = attr->layer_write->new_layer;
+	
+	/* temporary copy pointer for easy mapping */
+	attr->new_attribute = nattr;
+	
+	return nattr;
+}
+
+void npar_copy(NParticleSystem *to, NParticleSystem *from)
+{
+	NParticleAttribute *attr;
+	int i;
+	
+	pbufCopy(&to->particles, &from->particles);
+	
+	/* copy attributes */
+	to->attributes.first = to->attributes.last = NULL;
+	for (attr=from->attributes.first; attr; attr=attr->next) {
+		BLI_addtail(&to->attributes, npar_copy_attribute(attr));
+	}
+	for (i=0; i < PAR_ATTR_TYPE_MAX; ++i) {
+		if (from->standard_attribute[i])
+			to->standard_attribute[i] = from->standard_attribute[i]->new_attribute;
+	}
+	if (from->active_attribute)
+		to->active_attribute = from->active_attribute->new_attribute;
+	
+	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list