Revision: 32740
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32740
Author:   lukastoenne
Date:     2010-10-27 16:32:01 +0200 (Wed, 27 Oct 2010)

Log Message:
-----------
Particle properties can now be accessed from data nodes. Particle properties 
currently still have to be added in the particle details panel before being 
used in the node tree, this could be changed so that properties are added 
automatically.
Brought back the AddParticle node.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenkernel/BKE_particleset.h
    branches/particles-2010/source/blender/blenkernel/intern/particleset.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c
    branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.h
    
branches/particles-2010/source/blender/nodes/intern/simulation/node_tree_simulation.c
    
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_add_particle.c
    
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_get_data.c
    
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_set_data.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2010-10-27 13:52:12 UTC (rev 32739)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h        
2010-10-27 14:32:01 UTC (rev 32740)
@@ -595,7 +595,7 @@
 
 /* node-specific functions for UI */
 /* XXX having these here is ugly, should be in nodes directory */
-void sim_getdata_add_property_socket(struct bNode *node, const char *prop);
+void sim_getdata_add_property_socket(struct bNode *node, const char *name);
 void sim_getdata_foreach_property(struct bNode *node, void *items, const char 
*str, int (*cb)(void *items, const char *str, const char *name, const char 
*identifier, int icon));
 const char *sim_getdata_path_get(struct bNode *node);
 void sim_getdata_path_set(struct bNodeTree *ntree, struct bNode *node, const 
char *path);
@@ -603,7 +603,7 @@
 void sim_getdata_type_set(struct bNodeTree *ntree, struct bNode *node, struct 
StructRNA *type);
 void sim_getdata_property_types(struct bNodeSocket *sock, int **types, int 
*num_types);
 
-void sim_setdata_add_property_socket(struct bNode *node, const char *prop);
+void sim_setdata_add_property_socket(struct bNode *node, const char *name);
 void sim_setdata_foreach_property(struct bNode *node, void *items, const char 
*str, int (*cb)(void *items, const char *str, const char *name, const char 
*identifier, int icon));
 const char *sim_setdata_path_get(struct bNode *node);
 void sim_setdata_path_set(struct bNodeTree *ntree, struct bNode *node, const 
char *path);

Modified: branches/particles-2010/source/blender/blenkernel/BKE_particleset.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_particleset.h 
2010-10-27 13:52:12 UTC (rev 32739)
+++ branches/particles-2010/source/blender/blenkernel/BKE_particleset.h 
2010-10-27 14:32:01 UTC (rev 32740)
@@ -76,6 +76,22 @@
 
 void *pset_parprop(struct NParticle *pa, struct ParticlePropertyInfo *prop);
 
+float pset_read_float(struct NParticle *pa, struct ParticlePropertyInfo *prop);
+int pset_read_int(struct NParticle *pa, struct ParticlePropertyInfo *prop);
+char pset_read_bool(struct NParticle *pa, struct ParticlePropertyInfo *prop);
+void pset_read_vector(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[3]);
+void pset_read_rgba(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4]);
+void pset_read_quat(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4]);
+void pset_read_matrix(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4][4]);
+
+void pset_write_float(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value);
+void pset_write_int(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
int value);
+void pset_write_bool(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
char value);
+void pset_write_vector(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, float value[3]);
+void pset_write_rgba(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value[4]);
+void pset_write_quat(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value[4]);
+void pset_write_matrix(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, float value[4][4]);
+
 /* object functions */
 void make_local_particleset(struct ParticleSet *pset);
 struct ParticleSet *add_particleset(char *name);

Modified: branches/particles-2010/source/blender/blenkernel/intern/particleset.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/particleset.c      
2010-10-27 13:52:12 UTC (rev 32739)
+++ branches/particles-2010/source/blender/blenkernel/intern/particleset.c      
2010-10-27 14:32:01 UTC (rev 32740)
@@ -673,6 +673,104 @@
        return ((char*)pa + prop->offset);
 }
 
+float pset_read_float(struct NParticle *pa, struct ParticlePropertyInfo *prop)
+{
+       if (prop->type == PARPROP_FLOAT)
+               return *(float*)((char*)pa + prop->offset);
+       else
+               return 0.0f;
+}
+
+int pset_read_int(struct NParticle *pa, struct ParticlePropertyInfo *prop)
+{
+       if (prop->type == PARPROP_INT)
+               return *(int*)((char*)pa + prop->offset);
+       else
+               return 0;
+}
+
+char pset_read_bool(struct NParticle *pa, struct ParticlePropertyInfo *prop)
+{
+       if (prop->type == PARPROP_BOOL)
+               return *(char*)((char*)pa + prop->offset);
+       else
+               return 0;
+}
+
+void pset_read_vector(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[3])
+{
+       if (prop->type == PARPROP_VECTOR)
+               copy_v3_v3(result, (float*)((char*)pa + prop->offset));
+       else
+               zero_v3(result);
+}
+
+void pset_read_rgba(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4])
+{
+       if (prop->type == PARPROP_RGBA)
+               copy_v4_v4(result, (float*)((char*)pa + prop->offset));
+       else
+               zero_v4(result);
+}
+
+void pset_read_quat(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4])
+{
+       if (prop->type == PARPROP_RGBA)
+               copy_qt_qt(result, (float*)((char*)pa + prop->offset));
+       else
+               unit_qt(result);
+}
+
+void pset_read_matrix(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4][4])
+{
+       if (prop->type == PARPROP_RGBA)
+               copy_m4_m4(result, (float(*)[4])((char*)pa + prop->offset));
+       else
+               unit_m4(result);
+}
+
+void pset_write_float(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value)
+{
+       if (prop->type == PARPROP_FLOAT)
+               *(float*)((char*)pa + prop->offset) = value;
+}
+
+void pset_write_int(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
int value)
+{
+       if (prop->type == PARPROP_INT)
+               *(int*)((char*)pa + prop->offset) = value;
+}
+
+void pset_write_bool(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
char value)
+{
+       if (prop->type == PARPROP_BOOL)
+               *(char*)((char*)pa + prop->offset) = value;
+}
+
+void pset_write_vector(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, float value[3])
+{
+       if (prop->type == PARPROP_VECTOR)
+               copy_v3_v3((float*)((char*)pa + prop->offset), value);
+}
+
+void pset_write_rgba(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value[4])
+{
+       if (prop->type == PARPROP_RGBA)
+               copy_v4_v4((float*)((char*)pa + prop->offset), value);
+}
+
+void pset_write_quat(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value[4])
+{
+       if (prop->type == PARPROP_QUAT)
+               copy_qt_qt((float*)((char*)pa + prop->offset), value);
+}
+
+void pset_write_matrix(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, float value[4][4])
+{
+       if (prop->type == PARPROP_MATRIX)
+               copy_m4_m4((float(*)[4])((char*)pa + prop->offset), 
(float(*)[4])value);
+}
+
 void make_local_particleset(ParticleSet *pset)
 {
        Object *ob = 0;

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2010-10-27 13:52:12 UTC (rev 32739)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2010-10-27 14:32:01 UTC (rev 32740)
@@ -391,7 +391,7 @@
 typedef struct SimDataNodeSocket {
        int type;                                               /* type of 
property */
        int pad;
-       char identifier[64];                    /* identifier string */
+//     char identifier[64];                    /* identifier string */
 } SimDataNodeSocket;
 
 #define SIM_DATA_RNA           1

Modified: 
branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c   
2010-10-27 13:52:12 UTC (rev 32739)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c   
2010-10-27 14:32:01 UTC (rev 32740)
@@ -99,6 +99,16 @@
        context_update_size(r_ctx);
 }
 
+void *sim_context_data(SimDataContext *ctx)
+{
+       return ctx->ptr.data;
+}
+
+ID *sim_context_id(SimDataContext *ctx)
+{
+       return (ID*)ctx->ptr.id.data;
+}
+
 StructRNA *sim_context_type(SimDataContext *ctx)
 {
        if (ctx->prop && RNA_property_type(ctx->prop) == PROP_COLLECTION)
@@ -147,6 +157,7 @@
        r_ctx->key = 0;
        RNA_pointer_create(NULL, NULL, NULL, &r_ctx->ptr);
        r_ctx->prop = NULL;
+       r_ctx->size = 1;
        
        resolved = RNA_path_resolve_full(&base, path, &r_ctx->ptr, 
&r_ctx->prop, &r_ctx->key);
        if (resolved)
@@ -586,7 +597,7 @@
        }
 }
 
-void sim_input_read_vector(SimExecData *execdata, SimSocketIterator *iter, 
float *result)
+void sim_input_read_vector(SimExecData *execdata, SimSocketIterator *iter, 
float result[3])
 {
 #ifdef WITH_OPENCL
        if (BKE_opencl_is_active()) {
@@ -615,7 +626,7 @@
        }
 }
 
-void sim_input_read_rgba(SimExecData *execdata, SimSocketIterator *iter, float 
*result)
+void sim_input_read_rgba(SimExecData *execdata, SimSocketIterator *iter, float 
result[4])
 {
 #ifdef WITH_OPENCL
        if (BKE_opencl_is_active()) {
@@ -646,7 +657,7 @@
        }
 }
 
-void sim_input_read_quat(SimExecData *execdata, SimSocketIterator *iter, float 
*result)
+void sim_input_read_quat(SimExecData *execdata, SimSocketIterator *iter, float 
result[4])
 {
 #ifdef WITH_OPENCL
        if (BKE_opencl_is_active()) {
@@ -677,31 +688,31 @@
        }
 }
 
-void sim_input_read_matrix(SimExecData *execdata, SimSocketIterator *iter, 
float *result)
+void sim_input_read_matrix(SimExecData *execdata, SimSocketIterator *iter, 
float result[4][4])
 {
 #ifdef WITH_OPENCL
        if (BKE_opencl_is_active()) {
                switch (iter->sock->type) {
                case SOCK_MATRIX:
-                       result[0] = ((cl_float4*)iter->current)[0].x;
-                       result[1] = ((cl_float4*)iter->current)[0].y;
-                       result[2] = ((cl_float4*)iter->current)[0].z;
-                       result[3] = ((cl_float4*)iter->current)[0].w;
-                       result[4] = ((cl_float4*)iter->current)[1].x;
-                       result[5] = ((cl_float4*)iter->current)[1].y;
-                       result[6] = ((cl_float4*)iter->current)[1].z;
-                       result[7] = ((cl_float4*)iter->current)[1].w;
-                       result[8] = ((cl_float4*)iter->current)[2].x;
-                       result[9] = ((cl_float4*)iter->current)[2].y;
-                       result[10] = ((cl_float4*)iter->current)[2].z;
-                       result[11] = ((cl_float4*)iter->current)[2].w;
-                       result[12] = ((cl_float4*)iter->current)[3].x;
-                       result[13] = ((cl_float4*)iter->current)[3].y;
-                       result[14] = ((cl_float4*)iter->current)[3].z;
-                       result[15] = ((cl_float4*)iter->current)[3].w;
+                       result[0][0] = ((cl_float4*)iter->current)[0].x;
+                       result[0][1] = ((cl_float4*)iter->current)[0].y;
+                       result[0][2] = ((cl_float4*)iter->current)[0].z;

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to