Revision: 32755
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32755
Author:   lukastoenne
Date:     2010-10-28 14:43:27 +0200 (Thu, 28 Oct 2010)

Log Message:
-----------
Added a SurfacePoint struct type for particle properties and node sockets. This 
will be used to describe locations on a geometry surface, which move with it 
when deformed. Internally this consists of a face number and a uvw coordinate 
vector (might change later for geometry types other than meshes). It be used 
for emission locations of particles, mesh material interpolation, sticky 
particles and all other things requiring interpolated geometry properties.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_particleset.h
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/blenkernel/intern/particleset.c
    branches/particles-2010/source/blender/editors/space_node/node_draw.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/makesdna/DNA_particleset_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

Modified: branches/particles-2010/source/blender/blenkernel/BKE_particleset.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_particleset.h 
2010-10-28 12:40:25 UTC (rev 32754)
+++ branches/particles-2010/source/blender/blenkernel/BKE_particleset.h 
2010-10-28 12:43:27 UTC (rev 32755)
@@ -83,6 +83,7 @@
 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_read_surfacepoint(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, SurfacePoint *result);
 
 void pset_write_float(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value);
 void pset_write_int(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
int value);
@@ -91,6 +92,7 @@
 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]);
+void pset_write_surfacepoint(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, const SurfacePoint *value);
 
 /* object functions */
 void make_local_particleset(struct ParticleSet *pset);

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c     
2010-10-28 12:40:25 UTC (rev 32754)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c     
2010-10-28 12:43:27 UTC (rev 32755)
@@ -88,17 +88,18 @@
 void ntreeSocketTypeInfo(int type, const char **identifier, int *icon, const 
char **name)
 {
        switch (type) {
-       case SOCK_VALUE:        if (identifier) *identifier = "SOCK_VALUE";     
        if (icon) *icon = 0;    if (name) *name = "Value";              break;
-       case SOCK_VECTOR:       if (identifier) *identifier = "SOCK_VECTOR";    
if (icon) *icon = 0;    if (name) *name = "Vector";             break;
-       case SOCK_RGBA:         if (identifier) *identifier = "SOCK_RGBA";      
        if (icon) *icon = 0;    if (name) *name = "Color";              break;
-       case SOCK_ANY:          if (identifier) *identifier = "SOCK_ANY";       
        if (icon) *icon = 0;    if (name) *name = "Any";                break;
-       case SOCK_OP:           if (identifier) *identifier = "SOCK_OP";        
        if (icon) *icon = 0;    if (name) *name = "Execute";    break;
-       case SOCK_FLOAT:        if (identifier) *identifier = "SOCK_FLOAT";     
        if (icon) *icon = 0;    if (name) *name = "Float";              break;
-       case SOCK_INT:          if (identifier) *identifier = "SOCK_INT";       
        if (icon) *icon = 0;    if (name) *name = "Integer";    break;
-       case SOCK_BOOL:         if (identifier) *identifier = "SOCK_BOOL";      
        if (icon) *icon = 0;    if (name) *name = "Boolean";    break;
-       case SOCK_QUAT:         if (identifier) *identifier = "SOCK_QUAT";      
        if (icon) *icon = 0;    if (name) *name = "Quaternion"; break;
-       case SOCK_MATRIX:       if (identifier) *identifier = "SOCK_MATRIX";    
if (icon) *icon = 0;    if (name) *name = "Matrix";             break;
-       case SOCK_STRING:       if (identifier) *identifier = "SOCK_STRING";    
if (icon) *icon = 0;    if (name) *name = "String";             break;
+       case SOCK_VALUE:        if (identifier) *identifier = "SOCK_VALUE";     
        if (icon) *icon = 0;    if (name) *name = "Value";                      
break;
+       case SOCK_VECTOR:       if (identifier) *identifier = "SOCK_VECTOR";    
if (icon) *icon = 0;    if (name) *name = "Vector";                     break;
+       case SOCK_RGBA:         if (identifier) *identifier = "SOCK_RGBA";      
        if (icon) *icon = 0;    if (name) *name = "Color";                      
break;
+       case SOCK_ANY:          if (identifier) *identifier = "SOCK_ANY";       
        if (icon) *icon = 0;    if (name) *name = "Any";                        
break;
+       case SOCK_OP:           if (identifier) *identifier = "SOCK_OP";        
        if (icon) *icon = 0;    if (name) *name = "Execute";            break;
+       case SOCK_FLOAT:        if (identifier) *identifier = "SOCK_FLOAT";     
        if (icon) *icon = 0;    if (name) *name = "Float";                      
break;
+       case SOCK_INT:          if (identifier) *identifier = "SOCK_INT";       
        if (icon) *icon = 0;    if (name) *name = "Integer";            break;
+       case SOCK_BOOL:         if (identifier) *identifier = "SOCK_BOOL";      
        if (icon) *icon = 0;    if (name) *name = "Boolean";            break;
+       case SOCK_QUAT:         if (identifier) *identifier = "SOCK_QUAT";      
        if (icon) *icon = 0;    if (name) *name = "Quaternion";         break;
+       case SOCK_MATRIX:       if (identifier) *identifier = "SOCK_MATRIX";    
if (icon) *icon = 0;    if (name) *name = "Matrix";                     break;
+       case SOCK_STRING:       if (identifier) *identifier = "SOCK_STRING";    
if (icon) *icon = 0;    if (name) *name = "String";                     break;
+       case SOCK_SURFPT:       if (identifier) *identifier = "SOCK_SURFPT";    
if (icon) *icon = 0;    if (name) *name = "SurfacePoint";       break;
        default:                        if (identifier) *identifier = "";       
                        if (icon) *icon = 0;    if (name) *name = "";
        }
 }

Modified: branches/particles-2010/source/blender/blenkernel/intern/particleset.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/particleset.c      
2010-10-28 12:40:25 UTC (rev 32754)
+++ branches/particles-2010/source/blender/blenkernel/intern/particleset.c      
2010-10-28 12:43:27 UTC (rev 32755)
@@ -715,7 +715,7 @@
 
 void pset_read_quat(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4])
 {
-       if (prop->type == PARPROP_RGBA)
+       if (prop->type == PARPROP_QUAT)
                copy_qt_qt(result, (float*)((char*)pa + prop->offset));
        else
                unit_qt(result);
@@ -723,12 +723,25 @@
 
 void pset_read_matrix(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float result[4][4])
 {
-       if (prop->type == PARPROP_RGBA)
+       if (prop->type == PARPROP_MATRIX)
                copy_m4_m4(result, (float(*)[4])((char*)pa + prop->offset));
        else
                unit_m4(result);
 }
 
+void pset_read_surfacepoint(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, struct SurfacePoint *result)
+{
+       if (prop->type == PARPROP_SURFPT) {
+               SurfacePoint *pt= (SurfacePoint*)((char*)pa + prop->offset);
+               copy_v3_v3(result->co, pt->co);
+               result->face = pt->face;
+       }
+       else {
+               zero_v3(result->co);
+               result->face = 0;
+       }
+}
+
 void pset_write_float(struct NParticle *pa, struct ParticlePropertyInfo *prop, 
float value)
 {
        if (prop->type == PARPROP_FLOAT)
@@ -771,6 +784,15 @@
                copy_m4_m4((float(*)[4])((char*)pa + prop->offset), 
(float(*)[4])value);
 }
 
+void pset_write_surfacepoint(struct NParticle *pa, struct ParticlePropertyInfo 
*prop, const struct SurfacePoint *value)
+{
+       if (prop->type == PARPROP_SURFPT) {
+               SurfacePoint *pt= (SurfacePoint*)((char*)pa + prop->offset);
+               copy_v3_v3(pt->co, value->co);
+               pt->face = value->face;
+       }
+}
+
 void make_local_particleset(ParticleSet *pset)
 {
        Object *ob = 0;

Modified: branches/particles-2010/source/blender/editors/space_node/node_draw.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_draw.c       
2010-10-28 12:40:25 UTC (rev 32754)
+++ branches/particles-2010/source/blender/editors/space_node/node_draw.c       
2010-10-28 12:43:27 UTC (rev 32755)
@@ -571,6 +571,9 @@
        case SOCK_STRING:
                r_col[0]= 180;  r_col[1]= 180;  r_col[2]= 180;  r_col[3]= 255;
                break;
+       case SOCK_SURFPT:
+               r_col[0]= 130;  r_col[1]= 150;  r_col[2]= 240;  r_col[3]= 255;
+               break;
        default:
                r_col[0]= 100;  r_col[1]= 200;  r_col[2]= 100;  r_col[3]= 255;
        }

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2010-10-28 12:40:25 UTC (rev 32754)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h    
2010-10-28 12:43:27 UTC (rev 32755)
@@ -127,7 +127,8 @@
 #define SOCK_QUAT                      8
 #define SOCK_MATRIX                    9
 #define SOCK_STRING                    10
-#define NUM_SOCKET_TYPES       11      /* must be last! */
+#define SOCK_SURFPT                    11
+#define NUM_SOCKET_TYPES       12      /* must be last! */
 
 /* sock->flag, first bit is select */
        /* hidden is user defined, to hide unused */

Modified: 
branches/particles-2010/source/blender/makesdna/DNA_particleset_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_particleset_types.h     
2010-10-28 12:40:25 UTC (rev 32754)
+++ branches/particles-2010/source/blender/makesdna/DNA_particleset_types.h     
2010-10-28 12:43:27 UTC (rev 32755)
@@ -33,6 +33,12 @@
 
 struct AnimData;
 
+/* XXX could be a library data type */
+typedef struct SurfacePoint {
+       int face;
+       float co[3];
+} SurfacePoint;
+
 typedef enum ParticleLife {
        PLIFE_UNBORN = -1,
        PLIFE_DEAD = 0,
@@ -52,6 +58,7 @@
        PARPROP_RGBA,
        PARPROP_QUAT,
        PARPROP_MATRIX,
+       PARPROP_SURFPT,
        /* must be last */
        NUM_PARPROP_TYPES
 } ParticlePropertyType;

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-28 12:40:25 UTC (rev 32754)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c   
2010-10-28 12:43:27 UTC (rev 32755)
@@ -49,6 +49,15 @@
 
 #ifdef WITH_OPENCL
 
+/* Note: these structs must match their C counterparts! */
+const char *cl_structs = STRINGIFY(
+typedef struct SurfacePoint {
+       float4 co;
+       int face;
+       char pad[12];
+} SurfacePoint;
+);
+
 const char *cl_string_funcs = STRINGIFY(
 //size_t strlen(const char *str)
 //{
@@ -379,6 +388,8 @@
                        return 4*sizeof(cl_float4);
                case SOCK_STRING:
                        return SIM_STRINGLENGTH * sizeof(cl_char);
+               case SOCK_SURFPT:
+                       return sizeof(clSurfacePoint);
                case SOCK_OP:
                        return 0;
                case SOCK_ANY:
@@ -408,6 +419,8 @@
                        return 16*sizeof(float);
                case SOCK_STRING:
                        return SIM_STRINGLENGTH * sizeof(char);
+               case SOCK_SURFPT:
+                       return sizeof(SurfacePoint);
                case SOCK_OP:
                        return 0;
                default:
@@ -753,6 +766,37 @@
        }
 }
 
+void sim_input_read_surfacepoint(SimExecData *execdata, SimSocketIterator 
*iter, SurfacePoint *result)
+{
+#ifdef WITH_OPENCL
+       if (BKE_opencl_is_active()) {
+               switch (iter->sock->type) {
+               case SOCK_SURFPT:
+                       result->co[0] = ((clSurfacePoint*)iter->current)->co.x;
+                       result->co[1] = ((clSurfacePoint*)iter->current)->co.y;
+                       result->co[2] = ((clSurfacePoint*)iter->current)->co.z;
+                       result->face = ((clSurfacePoint*)iter->current)->face;
+                       break;
+               default:
+                       zero_v3(result->co);

@@ 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