[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24295] trunk/blender/source/blender: Fix bug #19699: point density texture doesn't save particle system.
Brecht Van Lommel
brecht at blender.org
Wed Nov 4 09:44:42 CET 2009
Revision: 24295
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24295
Author: blendix
Date: 2009-11-04 09:44:42 +0100 (Wed, 04 Nov 2009)
Log Message:
-----------
Fix bug #19699: point density texture doesn't save particle system.
Non-ID pointers in DNA can only point to data from own ID block, so
now instead it uses an index into the particle system list, but still
exposed as a pointer through RNA.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/texture.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/makesdna/DNA_texture_types.h
trunk/blender/source/blender/makesrna/intern/rna_texture.c
trunk/blender/source/blender/render/intern/source/pointdensity.c
Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c 2009-11-04 05:45:57 UTC (rev 24294)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c 2009-11-04 08:44:42 UTC (rev 24295)
@@ -1125,7 +1125,7 @@
pd->totpoints = 0;
pd->coba = add_colorband(1);
pd->object = NULL;
- pd->psys = NULL;
+ pd->psys = 0;
return pd;
}
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2009-11-04 05:45:57 UTC (rev 24294)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2009-11-04 08:44:42 UTC (rev 24295)
@@ -2882,10 +2882,8 @@
tex->ima= newlibadr_us(fd, tex->id.lib, tex->ima);
tex->ipo= newlibadr_us(fd, tex->id.lib, tex->ipo);
if(tex->env) tex->env->object= newlibadr(fd, tex->id.lib, tex->env->object);
- if(tex->pd) {
+ if(tex->pd)
tex->pd->object= newlibadr(fd, tex->id.lib, tex->pd->object);
- tex->pd->psys= newlibadr(fd, tex->id.lib, tex->pd->psys);
- }
if(tex->vd) tex->vd->object= newlibadr(fd, tex->id.lib, tex->vd->object);
if(tex->nodetree)
Modified: trunk/blender/source/blender/makesdna/DNA_texture_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_texture_types.h 2009-11-04 05:45:57 UTC (rev 24294)
+++ trunk/blender/source/blender/makesdna/DNA_texture_types.h 2009-11-04 08:44:42 UTC (rev 24295)
@@ -159,12 +159,10 @@
int pdpad;
struct Object *object; /* for 'Object' or 'Particle system' type - source object */
- struct ParticleSystem *psys;
+ int psys; /* index+1 in ob.particlesystem, non-ID pointer not allowed */
short psys_cache_space; /* cache points in worldspace, object space, ... ? */
short ob_cache_space; /* cache points in worldspace, object space, ... ? */
- short pdpad2[2];
-
void *point_tree; /* the acceleration tree containing points */
float *point_data; /* dynamically allocated extra for extra information, like particle age */
Modified: trunk/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_texture.c 2009-11-04 05:45:57 UTC (rev 24294)
+++ trunk/blender/source/blender/makesrna/intern/rna_texture.c 2009-11-04 08:44:42 UTC (rev 24295)
@@ -34,9 +34,11 @@
#include "DNA_brush_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
+#include "DNA_object_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
#include "DNA_node_types.h"
+#include "DNA_particle_types.h"
#include "DNA_scene_types.h" /* MAXFRAME only */
#include "BKE_node.h"
@@ -321,6 +323,29 @@
return item;
}
+static PointerRNA rna_PointDensity_psys_get(PointerRNA *ptr)
+{
+ PointDensity *pd= ptr->data;
+ Object *ob= pd->object;
+ ParticleSystem *psys= NULL;
+ PointerRNA value;
+
+ if(ob && pd->psys)
+ psys= BLI_findlink(&ob->particlesystem, pd->psys-1);
+
+ RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &value);
+ return value;
+}
+
+static void rna_PointDensity_psys_set(PointerRNA *ptr, PointerRNA value)
+{
+ PointDensity *pd= ptr->data;
+ Object *ob= pd->object;
+
+ if(ob && value.id.data == ob)
+ pd->psys= BLI_findindex(&ob->particlesystem, value.data) + 1;
+}
+
static char *rna_ColorRamp_path(PointerRNA *ptr)
{
/* handle the cases where a single datablock may have 2 ramp types */
@@ -1552,9 +1577,9 @@
RNA_def_property_update(prop, 0, "rna_Texture_update");
prop= RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "psys");
RNA_def_property_ui_text(prop, "Particle System", "Particle System to render as points");
RNA_def_property_struct_type(prop, "ParticleSystem");
+ RNA_def_property_pointer_funcs(prop, "rna_PointDensity_psys_get", "rna_PointDensity_psys_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, 0, "rna_Texture_update");
Modified: trunk/blender/source/blender/render/intern/source/pointdensity.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pointdensity.c 2009-11-04 05:45:57 UTC (rev 24294)
+++ trunk/blender/source/blender/render/intern/source/pointdensity.c 2009-11-04 08:44:42 UTC (rev 24295)
@@ -236,11 +236,14 @@
if (pd->source == TEX_PD_PSYS) {
Object *ob = pd->object;
+ ParticleSystem *psys;
- if (!ob) return;
- if (!pd->psys) return;
+ if (!ob || !pd->psys) return;
+
+ psys= BLI_findlink(&ob->particlesystem, pd->psys-1);
+ if (!psys) return;
- pointdensity_cache_psys(re, pd, ob, pd->psys);
+ pointdensity_cache_psys(re, pd, ob, psys);
}
else if (pd->source == TEX_PD_OBJECT) {
Object *ob = pd->object;
More information about the Bf-blender-cvs
mailing list