svn merge ^/trunk/blender -r43676:43685
authorCampbell Barton <ideasman42@gmail.com>
Tue, 24 Jan 2012 22:44:48 +0000 (22:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 24 Jan 2012 22:44:48 +0000 (22:44 +0000)
1  2 
source/blender/blenkernel/intern/particle_system.c
source/blender/makesrna/intern/rna_object_api.c

index 7e69e67fca72824096b37e9aad53ab4fe685747a,5bb0ffbb76ab4a8152a091edeac5966500a555b3..69ddcd21cb9500c56fda6d6f45d01bb61f334f1a
@@@ -61,6 -61,7 +61,6 @@@
  #include "DNA_ipo_types.h" // XXX old animation system stuff... to be removed!
  #include "DNA_listBase.h"
  
 -#include "BLI_edgehash.h"
  #include "BLI_rand.h"
  #include "BLI_jitter.h"
  #include "BLI_math.h"
@@@ -70,8 -71,6 +70,8 @@@
  #include "BLI_threads.h"
  #include "BLI_utildefines.h"
  #include "BLI_linklist.h"
 +#include "BLI_edgehash.h"
 +#include "BLI_cellalloc.h"
  
  #include "BKE_main.h"
  #include "BKE_animsys.h"
@@@ -353,9 -352,9 +353,9 @@@ void psys_calc_dmcache(Object *ob, Deri
                        origindex= dm->getVertDataArray(dm, CD_ORIGINDEX);
                }
                else { /* FROM_FACE/FROM_VOLUME */
 -                      totdmelem= dm->getNumFaces(dm);
 +                      totdmelem= dm->getNumTessFaces(dm);
                        totelem= me->totface;
 -                      origindex= dm->getFaceDataArray(dm, CD_ORIGINDEX);
 +                      origindex= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
                }
        
                nodedmelem= MEM_callocN(sizeof(LinkNode)*totdmelem, "psys node elems");
@@@ -524,8 -523,8 +524,8 @@@ static void distribute_grid(DerivedMes
                int a, a1, a2, a0mul, a1mul, a2mul, totface;
                int amax= from==PART_FROM_FACE ? 3 : 1;
  
 -              totface=dm->getNumFaces(dm);
 -              mface_array= dm->getFaceDataArray(dm,CD_MFACE);
 +              totface=dm->getNumTessFaces(dm);
 +              mface=mface_array=dm->getTessFaceDataArray(dm,CD_MFACE);
                
                for(a=0; a<amax; a++){
                        if(a==0){ a0mul=res*res; a1mul=res; a2mul=1; }
@@@ -784,7 -783,7 +784,7 @@@ static void distribute_threads_exec(Par
                MFace *mface;
  
                pa->num = i = ctx->index[p];
 -              mface = dm->getFaceData(dm,i,CD_MFACE);
 +              mface = dm->getTessFaceData(dm,i,CD_MFACE);
                
                switch(distr){
                case PART_DISTR_JIT:
                if(from==PART_FROM_VOLUME){
                        MVert *mvert=dm->getVertDataArray(dm,CD_MVERT);
  
 -                      tot=dm->getNumFaces(dm);
 +                      tot=dm->getNumTessFaces(dm);
  
                        psys_interpolate_face(mvert,mface,0,0,pa->fuv,co1,nor,0,0,0,0);
  
                        min_d=2.0;
                        intersect=0;
  
 -                      for(i=0,mface=dm->getFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){
 +                      for(i=0,mface=dm->getTessFaceDataArray(dm,CD_MFACE); i<tot; i++,mface++){
                                if(i==pa->num) continue;
  
                                v1=mvert[mface->v1].co;
                        return;
                }
  
 -              mf= dm->getFaceData(dm, ctx->index[p], CD_MFACE);
 +              mf= dm->getTessFaceData(dm, ctx->index[p], CD_MFACE);
  
                randu= rng_getFloat(thread->rng);
                randv= rng_getFloat(thread->rng);
@@@ -1041,7 -1040,7 +1041,7 @@@ static int distribute_threads_init_data
        if(totpart==0)
                return 0;
  
 -      if (!finaldm->deformedOnly && !finaldm->getFaceDataArray(finaldm, CD_ORIGINDEX)) {
 +      if (!finaldm->deformedOnly && !finaldm->getTessFaceDataArray(finaldm, CD_ORIGINDEX)) {
                printf("Can't create particles with the current modifier stack, disable destructive modifiers\n");
  // XXX                error("Can't paint with the current modifier stack, disable destructive modifiers");
                return 0;
        }
  
        /* Get total number of emission elements and allocate needed arrays */
 -      totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumFaces(dm);
 +      totelem = (from == PART_FROM_VERT) ? dm->getNumVerts(dm) : dm->getNumTessFaces(dm);
  
        if(totelem == 0){
                distribute_invalid(scene, psys, children ? PART_FROM_CHILD : 0);
                        fprintf(stderr,"Particle distribution error: Nothing to emit from!\n");
  
                if(dm != finaldm) dm->release(dm);
+               BLI_kdtree_free(tree);
                return 0;
        }
  
                orcodata= dm->getVertDataArray(dm, CD_ORCO);
  
                for(i=0; i<totelem; i++){
 -                      MFace *mf=dm->getFaceData(dm,i,CD_MFACE);
 +                      MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
  
                        if(orcodata) {
                                copy_v3_v3(co1, orcodata[mf->v1]);
                }
                else { /* PART_FROM_FACE / PART_FROM_VOLUME */
                        for(i=0;i<totelem; i++){
 -                              MFace *mf=dm->getFaceData(dm,i,CD_MFACE);
 +                              MFace *mf=dm->getTessFaceData(dm,i,CD_MFACE);
                                tweight = vweight[mf->v1] + vweight[mf->v2] + vweight[mf->v3];
                                
                                if(mf->v4) {
                                COMPARE_ORIG_INDEX= dm->getVertDataArray(dm, CD_ORIGINDEX);
                }
                else {
 -                      if(dm->numFaceData)
 -                              COMPARE_ORIG_INDEX= dm->getFaceDataArray(dm, CD_ORIGINDEX);
 +                      if(dm->numTessFaceData)
 +                              COMPARE_ORIG_INDEX= dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
                }
  
                if(COMPARE_ORIG_INDEX) {
@@@ -3499,7 -3501,7 +3502,7 @@@ static void do_hair_dynamics(ParticleSi
        }
  
        if(!dm) {
 -              dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0);
 +              dm = psys->hair_in_dm = CDDM_new(totpoint, totedge, 0, 0, 0);
                DM_add_vert_layer(dm, CD_MDEFORMVERT, CD_CALLOC, NULL);
        }
  
  
                                if(dvert) {
                                        if(!dvert->totweight) {
 -                                              dvert->dw = MEM_callocN (sizeof(MDeformWeight), "deformWeight");
 +                                              dvert->dw = BLI_cellalloc_calloc(sizeof(MDeformWeight), "deformWeight");
                                                dvert->totweight = 1;
                                        }
  
  
                        if(dvert) {
                                if(!dvert->totweight) {
 -                                      dvert->dw = MEM_callocN (sizeof(MDeformWeight), "deformWeight");
 +                                      dvert->dw = BLI_cellalloc_calloc(sizeof(MDeformWeight), "deformWeight");
                                        dvert->totweight = 1;
                                }
                                /* roots should be 1.0, the rest can be anything from 0.0 to 1.0 */
index fc313d3b1deda6774b266e21f5fdc6712020ff09,188ccccbfc41760adec1c96e36c340be68a6e1f5..6783e5d4788ac8415ca3a7b72ee56390c167faa0
@@@ -171,7 -171,7 +171,7 @@@ Mesh *rna_Object_to_mesh(Object *ob, Re
                                dm = mesh_create_derived_view( sce, ob, mask );
                        
                        tmpmesh = add_mesh( "Mesh" );
 -                      DM_to_mesh( dm, tmpmesh );
 +                      DM_to_mesh( dm, tmpmesh, ob );
                        dm->release( dm );
                }
                
@@@ -643,7 -643,7 +643,7 @@@ void RNA_api_object(StructRNA *srna
        parm= RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply");
        RNA_def_property_flag(parm, PROP_REQUIRED);
        /* weak!, no way to return dynamic string type */
-       parm= RNA_def_string(func, "result", "result", 16384, "result", "");
+       parm= RNA_def_string(func, "result", "", 16384, "result", "");
        RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
        RNA_def_function_output(func, parm);
  #endif /* NDEBUG */