From fae903e263fd11d788a4e55900ff25f4fc8b26db Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Fri, 28 Oct 2011 14:46:09 +0000 Subject: Dynamic Paint: * More code changes pointed by Brecht in codereview. * Some user interface improvements. * Updating brush settings now also updates canvas preview. --- source/blender/blenkernel/BKE_bvhutils.h | 4 +- source/blender/blenkernel/BKE_dynamicpaint.h | 36 +- source/blender/blenkernel/intern/bvhutils.c | 4 +- source/blender/blenkernel/intern/dynamicpaint.c | 469 +++++++++------------ source/blender/blenlib/BLI_math_geom.h | 2 +- source/blender/blenlib/intern/math_geom.c | 2 +- source/blender/blenloader/intern/readfile.c | 1 - source/blender/editors/physics/dynamicpaint_ops.c | 176 ++++---- source/blender/editors/space_view3d/drawobject.c | 2 +- source/blender/makesdna/DNA_dynamicpaint_types.h | 4 +- source/blender/makesrna/intern/rna_dynamicpaint.c | 79 ++-- source/blender/modifiers/intern/MOD_dynamicpaint.c | 1 + source/blenderplayer/bad_level_call_stubs/stubs.c | 1 - 13 files changed, 333 insertions(+), 448 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index 11f5e93809f..5846b86e68a 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -110,8 +110,8 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data); /* * Math functions used by callbacks */ -float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float *v0, const float *v1, const float *v2); -float nearest_point_in_tri_surface(const float *v0,const float *v1,const float *v2,const float *p, int *v, int *e, float *nearest ); +float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float *v0, const float *v1, const float *v2); +float nearest_point_in_tri_surface(const float *v0,const float *v1,const float *v2,const float *p, int *v, int *e, float *nearest); /* * BVHCache diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h index d9cbed815fc..75b1f74a403 100644 --- a/source/blender/blenkernel/BKE_dynamicpaint.h +++ b/source/blender/blenkernel/BKE_dynamicpaint.h @@ -14,8 +14,6 @@ #ifndef BKE_DYNAMIC_PAINT_H_ #define BKE_DYNAMIC_PAINT_H_ -#include "DNA_dynamicpaint_types.h" - struct bContext; struct wmOperator; @@ -38,11 +36,7 @@ typedef struct PaintPoint { float e_color[3]; float e_alpha; float wetness; - short state; /* -1 = doesn't exist (On UV mapped image - * there can be points that doesn't exist on mesh surface) - * 0 = empty or dry - * 1 = wet paint - * 2 = new paint */ + short state; float color[3]; float alpha; } PaintPoint; @@ -52,9 +46,7 @@ typedef struct PaintWavePoint { float height; float velocity; - short state; /* 0 = neutral - * 1 = obstacle - * 2 = reflect only */ + short state; } PaintWavePoint; struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm); @@ -81,17 +73,17 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings /* image sequence baking */ int dynamicPaint_createUVSurface(struct DynamicPaintSurface *surface); int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Scene *scene, struct Object *cObject, int frame); -void dynamicPaint_outputImage(struct DynamicPaintSurface *surface, char* filename, short format, short type); - - -/* surface -> image file flags */ -#define DPOUTPUT_JPEG 0 -#define DPOUTPUT_PNG 1 -#define DPOUTPUT_OPENEXR 2 - -#define DPOUTPUT_PAINT 0 -#define DPOUTPUT_WET 1 -#define DPOUTPUT_DISPLACE 2 -#define DPOUTPUT_WAVES 3 +void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char* filename, short output_layer); + +/* PaintPoint state */ +#define DPAINT_PAINT_NONE -1 +#define DPAINT_PAINT_DRY 0 +#define DPAINT_PAINT_WET 1 +#define DPAINT_PAINT_NEW 2 + +/* PaintWavePoint state */ +#define DPAINT_WAVE_NONE 0 +#define DPAINT_WAVE_OBSTACLE 1 +#define DPAINT_WAVE_REFLECT_ONLY 2 #endif /* BKE_DYNAMIC_PAINT_H_ */ diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 72b456fa9ab..b81b52676fc 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -50,7 +50,7 @@ /* Math stuff for ray casting on mesh faces and for nearest surface */ -float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float *v0, const float *v1, const float *v2) +float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float *v0, const float *v1, const float *v2) { float dist; @@ -458,7 +458,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r { float dist; if(data->sphere_radius == 0.0f) - dist = ray_tri_intersection(ray, hit->dist, t0, t1, t2); + dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); else dist = sphereray_tri_intersection(ray, data->sphere_radius, hit->dist, t0, t1, t2); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 0aa06e5fda4..eb776bf2eda 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -32,6 +32,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_space_types.h" #include "DNA_texture_types.h" #include "BKE_animsys.h" @@ -98,9 +99,6 @@ static int neighY[8] = {0,1,1, 1, 0,-1,-1,-1}; #define EFF_MOVEMENT_PER_FRAME 0.05f /* initial wave time factor */ #define WAVE_TIME_FAC 0.1 -/* vector macros */ -#define VECADDVAL(v,val) {*(v)+=(val); *(v+1)+=(val); *(v+2)+=(val);} -#define VECMULVAL(v,val) {*(v)*=(val); *(v+1)*=(val); *(v+2)*=(val);} /* dissolve macro */ #define VALUE_DISSOLVE(VALUE, SPEED, SCALE, LOG) (VALUE) = (LOG) ? (VALUE) * 1.0f - 1.0f/((SPEED)/(SCALE)) : (VALUE) - 1.0f/(SPEED)*(SCALE) @@ -205,17 +203,11 @@ typedef struct PaintAdjData { /***************************** General Utils ******************************/ -/* -* Output error message to both ui and console -*/ -static int printError(DynamicPaintCanvasSettings *canvas, char *string) +/* Set canvas error string to display at the bake report */ +static int setError(DynamicPaintCanvasSettings *canvas, char *string) { /* Add error to canvas ui info label */ BLI_snprintf(canvas->error, sizeof(canvas->error), string); - - /* Print console output */ - printf("DynamicPaint bake failed: %s\n", canvas->error); - return 0; } @@ -328,7 +320,7 @@ static int surface_duplicateOutputExists(void *arg, const char *name) void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *basename, int output) { char name[64]; - strncpy(name, basename, 62); /* in case basename is surface->name use a copy */ + BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */ if (!output) BLI_uniquename_cb(surface_duplicateOutputExists, surface, name, '.', surface->output_name, sizeof(surface->output_name)); if (output) @@ -350,7 +342,7 @@ static int surface_duplicateNameExists(void *arg, const char *name) void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, char *basename) { char name[64]; - strncpy(name, basename, 62); /* in case basename is surface->name use a copy */ + BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */ BLI_uniquename_cb(surface_duplicateNameExists, surface, name, '.', surface->name, sizeof(surface->name)); } @@ -410,20 +402,12 @@ static int surface_totalSamples(DynamicPaintSurface *surface) /* assumes source alpha > 0.0f or results NaN colors */ static void mixColors(float *t_color, float t_alpha, float *s_color, float s_alpha) { - float invFact = (s_alphavalid) { - VECCOPY(b->min, point); - VECCOPY(b->max, point); + copy_v3_v3(b->min, point); + copy_v3_v3(b->max, point); b->valid = 1; } else { @@ -632,9 +616,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) float min_dim; /* calculate canvas dimensions */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { #ifdef _OPENMP int id = omp_get_thread_num(); @@ -694,9 +676,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) if (!error) { /* calculate number of points withing each cell */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { int co[3], j; for (j=0; j<3; j++) { @@ -737,9 +717,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) /* calculate cell bounds */ { int x; - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (x=0; xdim[0]; x++) { int y; for (y=0; ydim[1]; y++) { @@ -766,7 +744,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) grid->s_num = MEM_reallocN(grid->s_num, sizeof(int) * grid_cells); if (error || !grid->s_num) { - printError(surface->canvas, "Not enough free memory."); + setError(surface->canvas, "Not enough free memory."); freeGrid(sData); } } @@ -972,7 +950,8 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett surface->wave_timescale = 1.0f; surface->wave_spring = 0.20; - sprintf(surface->image_output_path, "%sdynamicpaint/", "/tmp/"); + BLI_snprintf(surface->image_output_path, sizeof(surface->image_output_path), "%sdynamicpaint", U.textudir); + BLI_cleanup_dir(NULL, surface->image_output_path); dynamicPaintSurface_setUniqueName(surface, "Surface"); surface->effector_weights = BKE_add_effector_weights(NULL); @@ -1004,8 +983,6 @@ int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, stru if (!dynamicPaint_createNewSurface(pmd->canvas, scene)) return 0; - pmd->canvas->ui_info[0] = '\0'; - } else if(type == MOD_DYNAMICPAINT_TYPE_BRUSH) { if(pmd->brush) @@ -1022,9 +999,9 @@ int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, stru pmd->brush->collision = MOD_DPAINT_COL_VOLUME; pmd->brush->mat = NULL; - pmd->brush->r = 0.0f; - pmd->brush->g = 0.0f; - pmd->brush->b = 1.0f; + pmd->brush->r = 0.15f; + pmd->brush->g = 0.4f; + pmd->brush->b = 0.8f; pmd->brush->alpha = 1.0f; pmd->brush->wetness = 1.0f; @@ -1090,8 +1067,6 @@ void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct Dyn if (tpmd->canvas) { tpmd->canvas->pmd = tpmd; - tpmd->canvas->ui_info[0] = '\0'; - } else if (tpmd->brush) { tpmd->brush->pmd = tpmd; @@ -1146,7 +1121,7 @@ static void dynamicPaint_allocateSurfaceType(DynamicPaintSurface *surface) break; } - if (sData->type_data == NULL) printError(surface->canvas, "Not enough free memory!"); + if (sData->type_data == NULL) setError(surface->canvas, "Not enough free memory!"); } static int surface_usesAdjDistance(DynamicPaintSurface *surface) @@ -1198,7 +1173,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for if (!ed->n_index || !ed->n_num || !ed->n_target || !temp_data) { dynamicPaint_freeAdjData(sData); if (temp_data) MEM_freeN(temp_data); - printError(surface->canvas, "Not enough free memory."); + setError(surface->canvas, "Not enough free memory."); return; } @@ -1286,11 +1261,9 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) /* Single color */ else if (surface->init_color_type == MOD_DPAINT_INITIAL_COLOR) { /* apply color to every surface point */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { - VECCOPY(pPoint[i].color, surface->init_color); + copy_v3_v3(pPoint[i].color, surface->init_color); pPoint[i].alpha = surface->init_color[3]; } } @@ -1312,9 +1285,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) /* for vertex surface loop through tfaces and find uv color * that provides highest alpha */ if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; i pPoint[*vert].alpha) { - VECCOPY(pPoint[*vert].color, &texres.tr); + copy_v3_v3(pPoint[*vert].color, &texres.tr); pPoint[*vert].alpha = texres.tin; } } @@ -1340,9 +1311,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) ImgSeqFormatData *f_data = (ImgSeqFormatData*)sData->format_data; int samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1; - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { float uv[9] = {0.0f}; float uv_final[3] = {0.0f}; @@ -1352,7 +1321,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) /* collect all uvs */ for (j=0; j<3; j++) { int v=(f_data->uv_p[i].quad && j>0) ? j+1 : j; - VECCOPY2D(&uv[j*3], tface[f_data->uv_p[i].face_index].uv[v]); + copy_v2_v2(&uv[j*3], tface[f_data->uv_p[i].face_index].uv[v]); } /* interpolate final uv pos */ @@ -1365,7 +1334,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) multitex_ext_safe(tex, uv_final, &texres); /* apply color */ - VECCOPY(pPoint[i].color, &texres.tr); + copy_v3_v3(pPoint[i].color, &texres.tr); pPoint[i].alpha = texres.tin; } } @@ -1380,9 +1349,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) MFace *mface = dm->getFaceArray(dm); int numOfFaces = dm->getNumFaces(dm); - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; iformat_data; int samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1; - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { int face_ind = f_data->uv_p[i].face_index; float colors[3][4] = {{0.0f,0.0f,0.0f,0.0f}}; @@ -1421,7 +1386,7 @@ void dynamicPaint_setInitialColor(DynamicPaintSurface *surface) interp_v4_v4v4v4( final_color, colors[0], colors[1], colors[2], f_data->barycentricWeights[i*samples].v); - VECCOPY(pPoint[i].color, final_color); + copy_v3_v3(pPoint[i].color, final_color); pPoint[i].alpha = final_color[3]; } } @@ -1504,9 +1469,7 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Deri int i; float* value = (float*)sData->type_data; - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { float normal[3], val=value[i]*surface->disp_factor; normal_short_to_float_v3(normal, mvert[i].no); @@ -1557,9 +1520,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData /* paint is stored on dry and wet layers, so mix final color first */ float *fcolor = MEM_callocN(sizeof(float)*sData->total_points*4, "Temp paint color"); - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { int j=i*4; @@ -1581,45 +1542,42 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData if (!col) col = CustomData_add_layer(&result->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numOfFaces); if (col) { - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; ipreview_id == MOD_DPAINT_SURFACE_PREV_PAINT) { + float c[3]; index *= 4; - invAlpha = 1.0f - fcolor[index+3]; /* Apply material color as base vertex color for preview */ col[i*4+j].a = 255; if (material) { - col[i*4+j].r = (unsigned char)(material->b*255); - col[i*4+j].g = (unsigned char)(material->g*255); - col[i*4+j].b = (unsigned char)(material->r*255); + c[0] = material->r; + c[1] = material->g; + c[2] = material->b; } - else { - col[i*4+j].r = 165; - col[i*4+j].g = 165; - col[i*4+j].b = 165; + else { /* default grey */ + c[0] = 0.65f; + c[1] = 0.65f; + c[2] = 0.65f; } - /* mix surface color */ - col[i*4+j].r = (char)(((float)col[i*4+j].r)*invAlpha + (fcolor[index+2]*255*fcolor[index+3])); - col[i*4+j].g = (char)(((float)col[i*4+j].g)*invAlpha + (fcolor[index+1]*255*fcolor[index+3])); - col[i*4+j].b = (char)(((float)col[i*4+j].b)*invAlpha + (fcolor[index]*255*fcolor[index+3])); + interp_v3_v3v3(c, c, &fcolor[index], fcolor[index+3]); + + col[i*4+j].r = FTOCHAR(c[2]); + col[i*4+j].g = FTOCHAR(c[1]); + col[i*4+j].b = FTOCHAR(c[0]); } else { - float wetness = (pPoint[index].wetness<1.0f) ? pPoint[index].wetness : 1.0f; col[i*4+j].a = 255; - col[i*4+j].r = (char)(wetness*255); - col[i*4+j].g = (char)(wetness*255); - col[i*4+j].b = (char)(wetness*255); + col[i*4+j].r = FTOCHAR(pPoint[index].wetness); + col[i*4+j].g = FTOCHAR(pPoint[index].wetness); + col[i*4+j].b = FTOCHAR(pPoint[index].wetness); } } } @@ -1633,19 +1591,17 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData /* paint layer */ col = CustomData_get_layer_named(&result->faceData, CD_MCOL, surface->output_name); if (col) { - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; ifaceData, CD_MCOL, surface->output_name2); if (col) { - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; ifaceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numOfFaces); if (col) { - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; icanvas->flags |= MOD_DPAINT_PREVIEW_READY; @@ -1717,17 +1666,8 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData if (defgrp_index >= 0 && dvert) { int i; for(i=0; itotal_points; i++) { - int j; MDeformVert *dv= &dvert[i]; - MDeformWeight *def_weight = NULL; - - /* check if this vertex has a weight */ - for (j=0; jtotweight; j++) { - if (dv->dw[j].def_nr == defgrp_index) { - def_weight = &dv->dw[j]; - break; - } - } + MDeformWeight *def_weight = defvert_find_index(dv, defgrp_index); /* skip if weight value is 0 and no existing weight is found */ if (!def_weight && !weight[i]) @@ -1758,9 +1698,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData int i; PaintWavePoint* wPoint = (PaintWavePoint*)sData->type_data; - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; itotal_points; i++) { float normal[3]; normal_short_to_float_v3(normal, mvert[i].no); @@ -2118,8 +2056,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) int *final_index; int aa_samples; - if (!dm) return printError(canvas, "Canvas mesh not updated."); - if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) return printError(canvas, "Can't bake non-\"image sequence\" formats."); + if (!dm) return setError(canvas, "Canvas mesh not updated."); + if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) return setError(canvas, "Can't bake non-\"image sequence\" formats."); numOfFaces = dm->getNumFaces(dm); mvert = dm->getVertArray(dm); @@ -2130,8 +2068,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname); /* Check for validity */ - if (!tface) return printError(canvas, "No UV data on canvas."); - if (surface->image_resolution < 16 || surface->image_resolution > 8192) return printError(canvas, "Invalid resolution."); + if (!tface) return setError(canvas, "No UV data on canvas."); + if (surface->image_resolution < 16 || surface->image_resolution > 8192) return setError(canvas, "Invalid resolution."); w = h = surface->image_resolution; @@ -2143,7 +2081,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) /* Init data struct */ if (surface->data) dynamicPaint_freeSurfaceData(surface); sData = surface->data = MEM_callocN(sizeof(PaintSurfaceData), "PaintSurfaceData"); - if (!surface->data) return printError(canvas, "Not enough free memory."); + if (!surface->data) return setError(canvas, "Not enough free memory."); aa_samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1; tempPoints = (struct PaintUVPoint *) MEM_callocN(w*h*sizeof(struct PaintUVPoint), "Temp PaintUVPoint"); @@ -2169,8 +2107,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) int numOfVert = (mface[ty].v4) ? 4 : 3; int i; - VECCOPY2D(faceBB[ty].min, tface[ty].uv[0]); - VECCOPY2D(faceBB[ty].max, tface[ty].uv[0]); + copy_v2_v2(faceBB[ty].min, tface[ty].uv[0]); + copy_v2_v2(faceBB[ty].max, tface[ty].uv[0]); for (i = 1; itotal_points; index++) { ImgSeqFormatData *f_data = (ImgSeqFormatData*)sData->format_data; @@ -2557,19 +2489,23 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) /* * Outputs an image file from uv surface data. */ -void dynamicPaint_outputImage(DynamicPaintSurface *surface, char* filename, short format, short type) +void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char* filename, short output_layer) { int index; ImBuf* ibuf = NULL; PaintSurfaceData *sData = surface->data; ImgSeqFormatData *f_data = (ImgSeqFormatData*)sData->format_data; - char output_file[250]; - - if (sData == NULL || sData->type_data == NULL) {printError(surface->canvas, "Image save failed: Invalid surface.");return;} - - if (format == DPOUTPUT_JPEG) BLI_snprintf(output_file, sizeof(output_file),"%s.jpg",filename); - else if (format == DPOUTPUT_OPENEXR) BLI_snprintf(output_file, sizeof(output_file),"%s.exr",filename); - else BLI_snprintf(output_file, sizeof(output_file),"%s.png",filename); + /* OpenEXR or PNG */ + int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_OPENEXR : R_PNG; + char output_file[FILE_MAX]; + + if (!sData || !sData->type_data) {setError(surface->canvas, "Image save failed: Invalid surface.");return;} + /* if selected format is openexr, but current build doesnt support one */ + #ifndef WITH_OPENEXR + if (format == R_OPENEXR) format = R_PNG; + #endif + BLI_strncpy(output_file, filename, sizeof(output_file)); + BKE_add_image_extension(output_file, format); /* Validate output file path */ BLI_path_abs(output_file, G.main->name); @@ -2577,87 +2513,88 @@ void dynamicPaint_outputImage(DynamicPaintSurface *surface, char* filename, shor /* Init image buffer */ ibuf = IMB_allocImBuf(surface->image_resolution, surface->image_resolution, 32, IB_rectfloat); - if (ibuf == NULL) {printError(surface->canvas, "Image save failed: Not enough free memory.");return;} + if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory.");return;} - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { int pos=f_data->uv_p[index].pixel_index*4; /* image buffer position */ /* Set values of preferred type */ - if (type == DPOUTPUT_WET) { - PaintPoint *point = &((PaintPoint*)sData->type_data)[index]; - float value = (point->wetness > 1.0f) ? 1.0f : point->wetness; - - ibuf->rect_float[pos]=value; - ibuf->rect_float[pos+1]=value; - ibuf->rect_float[pos+2]=value; - ibuf->rect_float[pos+3]=1.0f; - } - else if (type == DPOUTPUT_PAINT) { - PaintPoint *point = &((PaintPoint*)sData->type_data)[index]; - - ibuf->rect_float[pos] = point->color[0]; - ibuf->rect_float[pos+1] = point->color[1]; - ibuf->rect_float[pos+2] = point->color[2]; - /* mix wet layer */ - if (point->e_alpha) mixColors(&ibuf->rect_float[pos], point->alpha, point->e_color, point->e_alpha); - - /* use highest alpha */ - ibuf->rect_float[pos+3] = (point->e_alpha > point->alpha) ? point->e_alpha : point->alpha; - - /* Multiply color by alpha if enabled */ - if (surface->flags & MOD_DPAINT_MULALPHA) { - ibuf->rect_float[pos] *= ibuf->rect_float[pos+3]; - ibuf->rect_float[pos+1] *= ibuf->rect_float[pos+3]; - ibuf->rect_float[pos+2] *= ibuf->rect_float[pos+3]; + if (output_layer == 1) { + /* wetmap */ + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { + PaintPoint *point = &((PaintPoint*)sData->type_data)[index]; + float value = (point->wetness > 1.0f) ? 1.0f : point->wetness; + + ibuf->rect_float[pos]=value; + ibuf->rect_float[pos+1]=value; + ibuf->rect_float[pos+2]=value; + ibuf->rect_float[pos+3]=1.0f; } } - else if (type == DPOUTPUT_DISPLACE) { - float depth = ((float*)sData->type_data)[index]; - if (surface->depth_clamp) - depth /= surface->depth_clamp; - - if (surface->disp_type == MOD_DPAINT_DISP_DISPLACE) { - depth = (0.5f - depth/2.0f); + else if (output_layer == 0) { + /* Paintmap */ + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { + PaintPoint *point = &((PaintPoint*)sData->type_data)[index]; + + ibuf->rect_float[pos] = point->color[0]; + ibuf->rect_float[pos+1] = point->color[1]; + ibuf->rect_float[pos+2] = point->color[2]; + /* mix wet layer */ + if (point->e_alpha) mixColors(&ibuf->rect_float[pos], point->alpha, point->e_color, point->e_alpha); + + /* use highest alpha */ + ibuf->rect_float[pos+3] = (point->e_alpha > point->alpha) ? point->e_alpha : point->alpha; + + /* Multiply color by alpha if enabled */ + if (surface->flags & MOD_DPAINT_MULALPHA) { + ibuf->rect_float[pos] *= ibuf->rect_float[pos+3]; + ibuf->rect_float[pos+1] *= ibuf->rect_float[pos+3]; + ibuf->rect_float[pos+2] *= ibuf->rect_float[pos+3]; + } } + /* displace */ + else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) { + float depth = ((float*)sData->type_data)[index]; + if (surface->depth_clamp) + depth /= surface->depth_clamp; - CLAMP(depth, 0.0f, 1.0f); + if (surface->disp_type == MOD_DPAINT_DISP_DISPLACE) { + depth = (0.5f - depth/2.0f); + } - ibuf->rect_float[pos]=depth; - ibuf->rect_float[pos+1]=depth; - ibuf->rect_float[pos+2]=depth; - ibuf->rect_float[pos+3]=1.0f; - } - else if (type == DPOUTPUT_WAVES) { - PaintWavePoint *wPoint = &((PaintWavePoint*)sData->type_data)[index]; - float depth = wPoint->height; - if (surface->depth_clamp) - depth /= surface->depth_clamp; - depth = (0.5f + depth/2.0f); - CLAMP(depth, 0.0f, 1.0f); + CLAMP(depth, 0.0f, 1.0f); - ibuf->rect_float[pos]=depth; - ibuf->rect_float[pos+1]=depth; - ibuf->rect_float[pos+2]=depth; - ibuf->rect_float[pos+3]=1.0f; + ibuf->rect_float[pos]=depth; + ibuf->rect_float[pos+1]=depth; + ibuf->rect_float[pos+2]=depth; + ibuf->rect_float[pos+3]=1.0f; + } + /* waves */ + else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { + PaintWavePoint *wPoint = &((PaintWavePoint*)sData->type_data)[index]; + float depth = wPoint->height; + if (surface->depth_clamp) + depth /= surface->depth_clamp; + depth = (0.5f + depth/2.0f); + CLAMP(depth, 0.0f, 1.0f); + + ibuf->rect_float[pos]=depth; + ibuf->rect_float[pos+1]=depth; + ibuf->rect_float[pos+2]=depth; + ibuf->rect_float[pos+3]=1.0f; + } } } - /* Set output format*/ - if (format == DPOUTPUT_JPEG) { /* JPEG */ - ibuf->ftype= JPG|95; - } + /* Set output format, png in case exr isnt supported */ + ibuf->ftype= PNG|95; #ifdef WITH_OPENEXR - else if (format == DPOUTPUT_OPENEXR) { /* OpenEXR 32-bit float */ + if (format == R_OPENEXR) { /* OpenEXR 32-bit float */ ibuf->ftype = OPENEXR | OPENEXR_COMPRESS; } #endif - else { /* DPOUTPUT_PNG */ - ibuf->ftype= PNG|95; - } /* Save image */ IMB_saveiff(ibuf, output_file, IB_rectfloat); @@ -2766,7 +2703,7 @@ static void mesh_faces_spherecast_dp(void *userdata, int index, const BVHTreeRay do { - float dist = ray_tri_intersection(ray, hit->dist, t0, t1, t2); + float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); if(dist >= 0 && dist < hit->dist) { @@ -2812,7 +2749,7 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float * { nearest->index = index; nearest->dist = dist; - VECCOPY(nearest->co, nearest_tmp); + copy_v3_v3(nearest->co, nearest_tmp); nearest->no[0] = (quad) ? 1.0f : 0.0f; } @@ -2861,7 +2798,7 @@ static void dynamicPaint_mixPaintColors(DynamicPaintSurface *surface, int index, /* only increase wetness if it's below paint level */ wetness = (*paintWetness) * pPoint->e_alpha; if (pPoint->wetness < wetness) pPoint->wetness = wetness; - pPoint->state = 2; + pPoint->state = DPAINT_PAINT_NEW; } /* Erase paint */ else { @@ -2909,13 +2846,13 @@ static void dynamicPaint_mixWaveHeight(PaintWavePoint *wPoint, DynamicPaintBrush if (hit) { if (brush->wave_type == MOD_DPAINT_WAVEB_DEPTH) { wPoint->height = isect_height; - wPoint->state = 1; + wPoint->state = DPAINT_WAVE_OBSTACLE; wPoint->velocity = 0.0f; } else if (brush->wave_type == MOD_DPAINT_WAVEB_FORCE) wPoint->velocity = isect_height; else if (brush->wave_type == MOD_DPAINT_WAVEB_REFLECT) - wPoint->state = 2; + wPoint->state = DPAINT_WAVE_REFLECT_ONLY; } } @@ -3061,19 +2998,17 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy mvert_p = mvert_c; /* calculate speed */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; iobmat, p2); - VECSUB((*brushVel)[i].v, p2, p1); + sub_v3_v3v3((*brushVel)[i].v, p2, p1); mul_v3_fl((*brushVel)[i].v, 1.0f/timescale); } @@ -3111,7 +3046,7 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, mul_m4_v3(prev_obmat, prev_loc); mul_m4_v3(ob->obmat, cur_loc); - VECSUB(brushVel->v, cur_loc, prev_loc); + sub_v3_v3v3(brushVel->v, cur_loc, prev_loc); mul_v3_fl(brushVel->v, 1.0f/timescale); } @@ -3158,12 +3093,12 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus mul_mat3_m4_v3(brushOb->obmat, nor); normalize_v3(nor); - VECADD(avg_brushNor, avg_brushNor, nor); + add_v3_v3(avg_brushNor, nor); } } if (brush->collision & MOD_DPAINT_COL_DIST && brush->flags & MOD_DPAINT_PROX_PROJECT) { - VECMULVAL(avg_brushNor, 1.0f/(float)numOfVerts); + mul_v3_fl(avg_brushNor, 1.0f/(float)numOfVerts); /* instead of null vector use positive z */ if (!(MIN3(avg_brushNor[0],avg_brushNor[1],avg_brushNor[2]))) avg_brushNor[2] = 1.0f; @@ -3188,9 +3123,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus continue; /* loop through cell points and process brush */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (id = 0; id < grid->s_num[c_index]; id++) { int index = grid->t_index[grid->s_pos[c_index] + id]; @@ -3231,11 +3164,11 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus sample_factor = 1.0f; /* Get current sample position in world coordinates */ - VECCOPY(ray_start, bData->realCoord[bData->s_pos[index]+ss].v); - VECCOPY(ray_dir, bData->bNormal[index].invNorm); + copy_v3_v3(ray_start, bData->realCoord[bData->s_pos[index]+ss].v); + copy_v3_v3(ray_dir, bData->bNormal[index].invNorm); /* a simple hack to minimize chance of ray leaks at identical ray <-> edge locations */ - VECADDVAL(ray_start, 0.001f); + add_v3_fl(ray_start, 0.001f); hit.index = -1; hit.dist = 9999; @@ -3265,7 +3198,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus /* Also cast a ray in opposite direction to make sure * point is at least surrounded by two brush faces */ - VECMULVAL(ray_dir, -1.0f); + mul_v3_fl(ray_dir, -1.0f); hit.index = -1; hit.dist = 9999; @@ -3277,7 +3210,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus hit_found = HIT_VOLUME; /* Mark hit info */ - VECADDFAC(hitCoord, ray_start, ray_dir, hit.dist); /* Calculate final hit coordinates */ + madd_v3_v3v3fl(hitCoord, ray_start, ray_dir, hit.dist); /* Calculate final hit coordinates */ depth += dist*sample_factor; hitFace = f_index; hitQuad = quad; @@ -3310,11 +3243,11 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus float proj_ray[3] = {0.0f}; if (brush->ray_dir == MOD_DPAINT_RAY_CANVAS) { - VECCOPY(proj_ray, bData->bNormal[index].invNorm); + copy_v3_v3(proj_ray, bData->bNormal[index].invNorm); negate_v3(proj_ray); } else if (brush->ray_dir == MOD_DPAINT_RAY_BRUSH_AVG) { - VECCOPY(proj_ray, avg_brushNor); + copy_v3_v3(proj_ray, avg_brushNor); } else { /* MOD_DPAINT_RAY_ZPLUS */ proj_ray[2] = 1.0f; @@ -3326,7 +3259,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus if(BLI_bvhtree_ray_cast(treeData.tree, ray_start, proj_ray, 0.0f, &hit, mesh_faces_spherecast_dp, &treeData) != -1) { proxDist = hit.dist; - VECADDFAC(hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */ + madd_v3_v3v3fl(hitCo, ray_start, proj_ray, hit.dist); /* Calculate final hit coordinates */ hQuad = (hit.no[0] == 1.0f); face = hit.index; } @@ -3396,16 +3329,16 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, DynamicPaintBrus /* substract canvas point velocity */ if (bData->velocity) { - VECSUB(velocity, brushPointVelocity, bData->velocity[index].v); + sub_v3_v3v3(velocity, brushPointVelocity, bData->velocity[index].v); } else { - VECCOPY(velocity, brushPointVelocity); + copy_v3_v3(velocity, brushPointVelocity); } velocity_val = len_v3(velocity); /* if brush has smudge enabled store brush velocity */ if (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity) { - VECCOPY(&bData->brush_velocity[index*4], velocity); + copy_v3_v3(&bData->brush_velocity[index*4], velocity); mul_v3_fl(&bData->brush_velocity[index*4], 1.0f/velocity_val); bData->brush_velocity[index*4+3] = velocity_val; } @@ -3572,9 +3505,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, ParticleSys continue; /* loop through cell points */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (id = 0; id < grid->s_num[c_index]; id++) { int index = grid->t_index[grid->s_pos[c_index] + id]; @@ -3692,13 +3623,13 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, ParticleSys /* substract canvas point velocity */ if (bData->velocity) { - VECSUB(velocity, velocity, bData->velocity[index].v); + sub_v3_v3(velocity, bData->velocity[index].v); } velocity_val = len_v3(velocity); /* store brush velocity for smudge */ if (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity) { - VECCOPY(&bData->brush_velocity[index*4], velocity); + copy_v3_v3(&bData->brush_velocity[index*4], velocity); mul_v3_fl(&bData->brush_velocity[index*4], 1.0f/velocity_val); bData->brush_velocity[index*4+3] = velocity_val; } @@ -3743,9 +3674,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po /* * Loop through every surface point */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { float distance = len_v3v3(pointCoord, bData->realCoord[bData->s_pos[index]].v); @@ -3774,7 +3703,7 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po float hit_coord[3]; MVert *mvert = brush->dm->getVertArray(brush->dm); /* use dummy coord of first vertex */ - VECCOPY(hit_coord, mvert[0].co); + copy_v3_v3(hit_coord, mvert[0].co); mul_m4_v3(brushOb->obmat, hit_coord); dynamicPaint_doMaterialTex(bMats, paintColor, &alpha_factor, brushOb, bData->realCoord[bData->s_pos[index]].v, hit_coord, 0, 0, brush->dm); @@ -3789,16 +3718,16 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po /* substract canvas point velocity */ if (bData->velocity) { - VECSUB(velocity, brushVel.v, bData->velocity[index].v); + sub_v3_v3v3(velocity, brushVel.v, bData->velocity[index].v); } else { - VECCOPY(velocity, brushVel.v); + copy_v3_v3(velocity, brushVel.v); } velocity_val = len_v3(velocity); /* store brush velocity for smudge */ if (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity) { - VECCOPY(&bData->brush_velocity[index*4], velocity); + copy_v3_v3(&bData->brush_velocity[index*4], velocity); mul_v3_fl(&bData->brush_velocity[index*4], 1.0f/velocity_val); bData->brush_velocity[index*4+3] = velocity_val; } @@ -3855,9 +3784,7 @@ static void dynamicPaint_prepareNeighbourData(DynamicPaintSurface *surface, int bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets*sizeof(struct BakeNeighPoint),"PaintEffectBake"); if (!bNeighs) return; - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { int i; @@ -4049,9 +3976,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s *force = MEM_mallocN(sData->total_points*4*sizeof(float), "PaintEffectForces"); if (*force) { - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { float forc[3] = {0}; @@ -4079,7 +4004,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s /* acceleration */ if (bData->prev_velocity && surface->drip_acc) { float acc[3]; - VECCOPY(acc, bData->velocity[index].v); + copy_v3_v3(acc, bData->velocity[index].v); sub_v3_v3(acc, bData->prev_velocity[index].v); madd_v3_v3fl(forc, acc, surface->drip_acc*(-1.0f)); } @@ -4089,7 +4014,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s (*force)[index*4+3] = len_v3(forc); /* normalize and copy */ if ((*force)[index*4+3]) mul_v3_fl(forc, 1.0f/(*force)[index*4+3]); - VECCOPY(&((*force)[index*4]), forc); + copy_v3_v3(&((*force)[index*4]), forc); } /* calculate average values (single thread) */ @@ -4140,9 +4065,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force /* Copy current surface to the previous points array to read unmodified values */ memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { int i; @@ -4202,9 +4125,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force /* Copy current surface to the previous points array to read unmodified values */ memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(struct PaintPoint)); - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { int i; @@ -4296,9 +4217,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force } /* Keep values within acceptable range */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { PaintPoint *cPoint = &((PaintPoint*)sData->type_data)[index]; @@ -4353,9 +4272,7 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) /* copy previous frame data */ memcpy(prevPoint, sData->type_data, sData->total_points*sizeof(PaintWavePoint)); - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { PaintWavePoint *wPoint = &((PaintWavePoint*)sData->type_data)[index]; int numOfNeighs = sData->adj_data->n_num[index]; @@ -4409,12 +4326,10 @@ void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) } /* reset state */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index = 0; index < sData->total_points; index++) { PaintWavePoint *wPoint = &((PaintWavePoint*)sData->type_data)[index]; - wPoint->state = 0; + wPoint->state = DPAINT_WAVE_NONE; } MEM_freeN(prevPoint); @@ -4426,9 +4341,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time PaintSurfaceData *sData = surface->data; int index; - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index=0; indextotal_points; index++) { /* Do drying dissolve effects */ @@ -4438,7 +4351,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time if (pPoint->wetness > 0.0f || pPoint->state > 0) { /* for every drying step blend wet paint to the background */ if (pPoint->e_alpha) mixColors(pPoint->color, pPoint->alpha, pPoint->e_color, pPoint->e_alpha); - pPoint->state = 1; + pPoint->state = DPAINT_PAINT_WET; /* only increase alpha if wet paint has higher */ if (pPoint->e_alpha > pPoint->alpha) pPoint->alpha = pPoint->e_alpha; @@ -4450,7 +4363,7 @@ static void dynamicPaint_surfacePreStep(DynamicPaintSurface *surface, float time if (pPoint->wetness <= 0.0f) { pPoint->wetness = 0.0f; pPoint->e_alpha = 0.0f; - pPoint->state = 0; + pPoint->state = DPAINT_PAINT_DRY; } if (surface->flags & MOD_DPAINT_DISSOLVE) { @@ -4496,9 +4409,7 @@ static int dynamicPaint_surfaceHasMoved(DynamicPaintSurface *surface, Object *ob } /* vertices */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (i=0; irealCoord) MEM_freeN(bData->realCoord); if (canvas_verts) MEM_freeN(canvas_verts); - return printError(surface->canvas, "Not enough free memory."); + return setError(surface->canvas, "Not enough free memory."); } new_bdata = 1; @@ -4606,25 +4517,21 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc /* * Make a transformed copy of canvas derived mesh vertices to avoid recalculation. */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index=0; indexobmat, canvas_verts[index].v); } /* * Prepare each surface point for a new step */ - #ifdef _OPENMP #pragma omp parallel for schedule(static) - #endif for (index=0; indextotal_points; index++) { float prev_point[3]; if (do_velocity_data && !new_bdata) { - VECCOPY(prev_point, bData->realCoord[bData->s_pos[index]].v); + copy_v3_v3(prev_point, bData->realCoord[bData->s_pos[index]].v); } /* * Calculate current 3D-position and normal of each surface point @@ -4671,7 +4578,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc /* calculate position for each sample */ for (ss=0; sss_num[index]; ss++) { /* first sample is always point center */ - VECCOPY(bData->realCoord[bData->s_pos[index]+ss].v, canvas_verts[index].v); + copy_v3_v3(bData->realCoord[bData->s_pos[index]+ss].v, canvas_verts[index].v); if (ss > 0) { int t_index = adj_data->n_index[index]+(ss-1); /* get vertex position at 1/3 of each neigh edge */ @@ -4714,7 +4621,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc /* calculate speed vector */ if (do_velocity_data && !new_bdata && !bData->clear) { - VECSUB(bData->velocity[index].v, bData->realCoord[bData->s_pos[index]].v, prev_point); + sub_v3_v3v3(bData->velocity[index].v, bData->realCoord[bData->s_pos[index]].v, prev_point); } } @@ -4878,7 +4785,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* Allocate memory for surface previous points to read unchanged values from */ prevPoint = MEM_mallocN(sData->total_points*sizeof(struct PaintPoint), "PaintSurfaceDataCopy"); if (!prevPoint) - return printError(canvas, "Not enough free memory."); + return setError(canvas, "Not enough free memory."); /* Prepare effects and get number of required steps */ steps = dynamicPaint_prepareEffectStep(surface, scene, ob, &force, timescale); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 234c191eb6b..4ae29eb0c51 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -60,7 +60,7 @@ float area_poly_v3(int nr, float verts[][3], const float normal[3]); float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]); float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]); -void closest_to_line_segment_v2(float *closest, float p[2], float l1[2], float l2[2]); +void closest_to_line_segment_v2(float closest[2], const float p[2], const float l1[2], const float l2[2]); float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]); float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d0e86c44edb..05b90eed4ab 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -210,7 +210,7 @@ float dist_to_line_segment_v2(const float v1[2], const float v2[2], const float } /* point closest to v1 on line v2-v3 in 2D */ -void closest_to_line_segment_v2(float *closest, float p[2], float l1[2], float l2[2]) +void closest_to_line_segment_v2(float closest[2], const float p[2], const float l1[2], const float l2[2]) { float lambda, cp[2]; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index eadf9cd0cdb..c6986531c9e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4110,7 +4110,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) pmd->canvas = newdataadr(fd, pmd->canvas); pmd->canvas->pmd = pmd; pmd->canvas->dm = NULL; - pmd->canvas->ui_info[0] = '\0'; pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */ if (pmd->canvas->surfaces.first) { diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 9a7e5a564c4..888b5af01bb 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -56,22 +56,23 @@ static int surface_slot_add_exec(bContext *C, wmOperator *op) { DynamicPaintModifierData *pmd = 0; Object *cObject = CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + DynamicPaintCanvasSettings *canvas; DynamicPaintSurface *surface; /* Make sure we're dealing with a canvas */ pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint); - if (!pmd) return OPERATOR_CANCELLED; - if (!pmd->canvas) return OPERATOR_CANCELLED; + if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED; - surface = dynamicPaint_createNewSurface(pmd->canvas, CTX_data_scene(C)); + canvas = pmd->canvas; + surface = dynamicPaint_createNewSurface(canvas, CTX_data_scene(C)); if (!surface) return OPERATOR_CANCELLED; /* set preview for this surface only and set active */ - pmd->canvas->active_sur = 0; + canvas->active_sur = 0; for(surface=surface->prev; surface; surface=surface->prev) { surface->flags &= ~MOD_DPAINT_PREVIEW; - pmd->canvas->active_sur++; + canvas->active_sur++; } return OPERATOR_FINISHED; @@ -97,27 +98,28 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *op) { DynamicPaintModifierData *pmd = 0; Object *cObject = CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + DynamicPaintCanvasSettings *canvas; DynamicPaintSurface *surface; int id=0; /* Make sure we're dealing with a canvas */ pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint); - if (!pmd) return OPERATOR_CANCELLED; - if (!pmd->canvas) return OPERATOR_CANCELLED; + if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED; - surface = pmd->canvas->surfaces.first; + canvas = pmd->canvas; + surface = canvas->surfaces.first; /* find active surface and remove it */ for(; surface; surface=surface->next) { - if(id == pmd->canvas->active_sur) { - pmd->canvas->active_sur -= 1; + if(id == canvas->active_sur) { + canvas->active_sur -= 1; dynamicPaint_freeSurface(surface); break; } id++; } - dynamicPaint_resetPreview(pmd->canvas); + dynamicPaint_resetPreview(canvas); DAG_id_tag_update(&cObject->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, cObject); @@ -197,42 +199,39 @@ static int output_toggle_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data; Scene *scene = CTX_data_scene(C); + DynamicPaintSurface *surface; DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); int index= RNA_int_get(op->ptr, "index"); - if (!pmd) return OPERATOR_CANCELLED; - + if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED; + surface = get_activeSurface(pmd->canvas); /* if type is already enabled, toggle it off */ - if (pmd->canvas) { - DynamicPaintSurface *surface = get_activeSurface(pmd->canvas); - - if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { - int exists = dynamicPaint_outputLayerExists(surface, ob, index); - char *name; - - if (index == 0) - name = surface->output_name; - else if (index == 1) - name = surface->output_name2; - - /* Vertex Color Layer */ - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { - if (!exists) - ED_mesh_color_add(C, scene, ob, ob->data, name, 1); - else - ED_mesh_color_remove_named(C, ob, ob->data, name); - } - /* Vertex Weight Layer */ - else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) { - if (!exists) - ED_vgroup_add_name(ob, name); - else { - bDeformGroup *defgroup = defgroup_find_name(ob, name); - if (defgroup) ED_vgroup_delete(ob, defgroup); - } - } + if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { + int exists = dynamicPaint_outputLayerExists(surface, ob, index); + char *name; + + if (index == 0) + name = surface->output_name; + else if (index == 1) + name = surface->output_name2; + + /* Vertex Color Layer */ + if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { + if (!exists) + ED_mesh_color_add(C, scene, ob, ob->data, name, 1); + else + ED_mesh_color_remove_named(C, ob, ob->data, name); + } + /* Vertex Weight Layer */ + else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) { + if (!exists) + ED_vgroup_add_name(ob, name); + else { + bDeformGroup *defgroup = defgroup_find_name(ob, name); + if (defgroup) ED_vgroup_delete(ob, defgroup); } + } } return OPERATOR_FINISHED; @@ -275,11 +274,9 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf int frames; frames = surface->end_frame - surface->start_frame + 1; - if (frames <= 0) {sprintf(canvas->error, "No frames to bake.");printf("DynamicPaint bake failed: %s", canvas->error);return 0;} + if (frames <= 0) {BLI_strncpy(canvas->error, "No frames to bake.", sizeof(canvas->error)); return 0;} - /* - * Set frame to start point (also inits modifier data) - */ + /* Set frame to start point (also inits modifier data) */ frame = surface->start_frame; scene->r.cfra = (int)frame; ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1); @@ -287,9 +284,7 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf /* Init surface */ if (!dynamicPaint_createUVSurface(surface)) return 0; - /* - * Loop through selected frames - */ + /* Loop through selected frames */ for (frame=surface->start_frame; frame<=surface->end_frame; frame++) { float progress = (frame - surface->start_frame) / (float)frames * 100; @@ -300,7 +295,6 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf /* Update progress bar cursor */ WM_timecursor(win, (int)progress); - printf("DynamicPaint: Baking frame %i\n", frame); /* calculate a frame */ scene->r.cfra = (int)frame; @@ -311,48 +305,25 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf * Save output images */ { - char filename[250]; - char pad[4]; - char dir_slash[2]; - /* OpenEXR or PNG */ - short format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? DPOUTPUT_OPENEXR : DPOUTPUT_PNG; - - /* Add frame number padding */ - if (frame<10) sprintf(pad,"000"); - else if (frame<100) sprintf(pad,"00"); - else if (frame<1000) sprintf(pad,"0"); - else pad[0] = '\0'; - - /* make sure directory path is valid to append filename */ - if (surface->image_output_path[strlen(surface->image_output_path)-1] != 47 && - surface->image_output_path[strlen(surface->image_output_path)-1] != 92) - strcpy(dir_slash,"/"); - else - dir_slash[0] = '\0'; - - - /* color map */ - if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { - if (surface->flags & MOD_DPAINT_OUT1) { - BLI_snprintf(filename, sizeof(filename), "%s%s%s%s%i", surface->image_output_path, dir_slash, surface->output_name, pad, (int)frame); - dynamicPaint_outputImage(surface, filename, format, DPOUTPUT_PAINT); - } - if (surface->flags & MOD_DPAINT_OUT2) { - BLI_snprintf(filename, sizeof(filename), "%s%s%s%s%i", surface->image_output_path, dir_slash, surface->output_name2, pad, (int)frame); - dynamicPaint_outputImage(surface, filename, format, DPOUTPUT_WET); - } + char filename[FILE_MAX]; + /* make sure output path has ending slash */ + BLI_add_slash(surface->image_output_path); + + /* primary output layer */ + if (surface->flags & MOD_DPAINT_OUT1) { + /* set filepath */ + BLI_snprintf(filename, sizeof(filename), "%s%s", surface->image_output_path, surface->output_name); + BLI_path_frame(filename, frame, 4); + /* save image */ + dynamicPaint_outputSurfaceImage(surface, filename, 0); } - - /* displacement map */ - else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) { - BLI_snprintf(filename, sizeof(filename), "%s%s%s%s%i", surface->image_output_path, dir_slash, surface->output_name, pad, (int)frame); - dynamicPaint_outputImage(surface, filename, format, DPOUTPUT_DISPLACE); - } - - /* waves */ - else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { - BLI_snprintf(filename, sizeof(filename), "%s%s%s%s%i", surface->image_output_path, dir_slash, surface->output_name, pad, (int)frame); - dynamicPaint_outputImage(surface, filename, format, DPOUTPUT_WAVES); + /* secondary output */ + if (surface->flags & MOD_DPAINT_OUT2 && surface->type == MOD_DPAINT_SURFACE_T_PAINT) { + /* set filepath */ + BLI_snprintf(filename, sizeof(filename), "%s%s", surface->image_output_path, surface->output_name2); + BLI_path_frame(filename, frame, 4); + /* save image */ + dynamicPaint_outputSurfaceImage(surface, filename, 1); } } } @@ -370,6 +341,7 @@ int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) Object *ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data; int status = 0; double timer = PIL_check_seconds_timer(); + char result_str[80]; DynamicPaintSurface *surface; /* @@ -397,35 +369,31 @@ int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) /* Bake Dynamic Paint */ status = dynamicPaint_bakeImageSequence(C, surface, ob); /* Clear bake */ - pmd->canvas->flags &= ~MOD_DPAINT_BAKING; + canvas->flags &= ~MOD_DPAINT_BAKING; WM_cursor_restore(CTX_wm_window(C)); dynamicPaint_freeSurfaceData(surface); /* Bake was successful: * Report for ended bake and how long it took */ if (status) { - /* Format time string */ - char timestr[30]; + char time_str[30]; double time = PIL_check_seconds_timer() - timer; - BLI_timestr(time, timestr); + BLI_timestr(time, time_str); /* Show bake info */ - BLI_snprintf(canvas->ui_info, sizeof(canvas->ui_info), "Bake Complete! (%s)", timestr); - printf("%s\n", canvas->ui_info); + BLI_snprintf(result_str, sizeof(result_str), "Bake Complete! (%s)", time_str); + BKE_report(op->reports, RPT_INFO, result_str); } else { - if (strlen(pmd->canvas->error)) { /* If an error occured */ - BLI_snprintf(canvas->ui_info, sizeof(canvas->ui_info), "Bake Failed: %s", pmd->canvas->error); - BKE_report(op->reports, RPT_ERROR, canvas->ui_info); + if (strlen(canvas->error)) { /* If an error occured */ + BLI_snprintf(result_str, sizeof(result_str), "Bake Failed: %s", canvas->error); + BKE_report(op->reports, RPT_ERROR, result_str); } else { /* User cancelled the bake */ - sprintf(pmd->canvas->ui_info, "Baking Cancelled!"); - BKE_report(op->reports, RPT_WARNING, canvas->ui_info); + BLI_strncpy(result_str, "Baking Cancelled!", sizeof(result_str)); + BKE_report(op->reports, RPT_WARNING, result_str); } - - /* Print failed bake to console */ - printf("Baking Cancelled!\n"); } return status; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b39ef4b462b..2c6c4572948 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2695,7 +2695,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint))) { /* check if target has an active dp modifier */ - if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) + if(md && (md->mode & eModifierMode_Realtime)) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; /* if canvas is ready to preview vertex colors */ diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h index aebd8d0f07a..c8dfdf83a57 100644 --- a/source/blender/makesdna/DNA_dynamicpaint_types.h +++ b/source/blender/makesdna/DNA_dynamicpaint_types.h @@ -129,9 +129,7 @@ typedef struct DynamicPaintCanvasSettings { short active_sur, flags; int pad; - - char ui_info[128]; // UI info text - char error[64]; // Bake error description + char error[64]; /* Bake error description */ } DynamicPaintCanvasSettings; diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index c3dcc65c3d4..f4a955349f6 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -316,7 +316,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) {MOD_DPAINT_INITIAL_NONE, "NONE", 0, "None", ""}, {MOD_DPAINT_INITIAL_COLOR, "COLOR", ICON_COLOR, "Color", ""}, {MOD_DPAINT_INITIAL_TEXTURE, "TEXTURE", ICON_TEXTURE, "UV Texture", ""}, - {MOD_DPAINT_INITIAL_VERTEXCOLOR, "VERTEXCOLOR", ICON_GROUP_VCOL, "Vertex Color", ""}, + {MOD_DPAINT_INITIAL_VERTEXCOLOR, "VERTEX_COLOR", ICON_GROUP_VCOL, "Vertex Color", ""}, {0, NULL, 0, NULL, NULL}}; /* Effect type @@ -336,7 +336,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; /* Displacemap type */ - static EnumPropertyItem prop_dynamicpaint_disp_type[] = { + static EnumPropertyItem prop_dynamicpaint_displace_type[] = { {MOD_DPAINT_DISP_DISPLACE, "DISPLACE", 0, "Displacement", ""}, {MOD_DPAINT_DISP_DEPTH, "DEPTH", 0, "Depth", ""}, {0, NULL, 0, NULL, NULL}}; @@ -387,7 +387,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) /* - * Paint, wet and disp + * Paint, wet and displace */ prop= RNA_def_property(srna, "use_dissolve", PROP_BOOLEAN, PROP_NONE); @@ -419,26 +419,29 @@ static void rna_def_canvas_surface(BlenderRNA *brna) RNA_def_property_ui_text(prop, "UV Layer", "UV layer name"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DynamicPaint_uvlayer_set"); - prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "start_frame"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1.0, 9999.0); RNA_def_property_ui_range(prop, 1.0, 9999, 1, 0); RNA_def_property_ui_text(prop, "Start Frame", "Simulation start frame"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames"); - prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "end_frame"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1.0, 9999.0); RNA_def_property_ui_range(prop, 1.0, 9999.0, 1, 0); RNA_def_property_ui_text(prop, "End Frame", "Simulation end frame"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaintSurfaces_updateFrames"); - prop= RNA_def_property(srna, "substeps", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "frame_substeps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "substeps"); RNA_def_property_range(prop, 0.0, 10.0); RNA_def_property_ui_range(prop, 0.0, 10, 1, 0); RNA_def_property_ui_text(prop, "Sub-Steps", "Do extra frames between scene frames to ensure smooth motion"); - prop= RNA_def_property(srna, "use_anti_aliasing", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ANTIALIAS); RNA_def_property_ui_text(prop, "Anti-aliasing", "Use 5x multisampling to smoothen paint edges"); @@ -556,12 +559,12 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop= RNA_def_property(srna, "do_output1", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT1); - RNA_def_property_ui_text(prop, "Save layer", ""); + RNA_def_property_ui_text(prop, "Save layer", "Output name"); /* output for secondary sufrace data */ prop= RNA_def_property(srna, "output_name2", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "output_name2"); - RNA_def_property_ui_text(prop, "Output name", ""); + RNA_def_property_ui_text(prop, "Output name", "Output name"); prop= RNA_def_property(srna, "do_output2", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_OUT2); @@ -592,7 +595,8 @@ static void rna_def_canvas_surface(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Max Displace", "Maximum level of depth intersection in object space. Use 0.0 to disable"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop= RNA_def_property(srna, "disp_factor", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "displace_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "disp_factor"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, -50.0, 50.0); RNA_def_property_ui_range(prop, -5.0, 5.0, 1, 2); @@ -604,12 +608,13 @@ static void rna_def_canvas_surface(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_dynamicpaint_image_fileformat); RNA_def_property_ui_text(prop, "File Format", ""); - prop= RNA_def_property(srna, "disp_type", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "displace_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "disp_type"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_enum_items(prop, prop_dynamicpaint_disp_type); + RNA_def_property_enum_items(prop, prop_dynamicpaint_displace_type); RNA_def_property_ui_text(prop, "Data Type", ""); - prop= RNA_def_property(srna, "incremental_disp", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_incremental_displace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_DISP_INCREMENTAL); RNA_def_property_ui_text(prop, "Incremental", "New displace is added cumulatively on top of existing"); @@ -672,10 +677,6 @@ static void rna_def_dynamic_paint_canvas_settings(BlenderRNA *brna) RNA_def_property_struct_type(prop, "DynamicPaintSurface"); RNA_def_property_ui_text(prop, "Paint Surface List", "Paint surface list"); rna_def_canvas_surfaces(brna, prop); - - prop= RNA_def_property(srna, "ui_info", PROP_STRING, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Bake Info", "Info on bake status"); } static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) @@ -685,10 +686,10 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) /* paint collision type */ static EnumPropertyItem prop_dynamicpaint_collisiontype[] = { - {MOD_DPAINT_COL_PSYS, "PSYS", ICON_PARTICLES, "Particle System", ""}, + {MOD_DPAINT_COL_PSYS, "PARTICLE_SYSTEM", ICON_PARTICLES, "Particle System", ""}, {MOD_DPAINT_COL_POINT, "POINT", ICON_META_EMPTY, "Object Center", ""}, {MOD_DPAINT_COL_DIST, "DISTANCE", ICON_META_EMPTY, "Proximity", ""}, - {MOD_DPAINT_COL_VOLDIST, "VOLDIST", ICON_META_CUBE, "Mesh Volume + Proximity", ""}, + {MOD_DPAINT_COL_VOLDIST, "VOLUME_DISTANCE", ICON_META_CUBE, "Mesh Volume + Proximity", ""}, {MOD_DPAINT_COL_VOLUME, "VOLUME", ICON_MESH_CUBE, "Mesh Volume", ""}, {0, NULL, 0, NULL, NULL}}; @@ -707,7 +708,7 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) static EnumPropertyItem prop_dynamicpaint_brush_ray_dir[] = { {MOD_DPAINT_RAY_CANVAS, "CANVAS", 0, "Canvas Normal", ""}, {MOD_DPAINT_RAY_BRUSH_AVG, "BRUSH", 0, "Brush Normal", ""}, - {MOD_DPAINT_RAY_ZPLUS, "ZPLUS", 0, "Z-Axis", ""}, + {MOD_DPAINT_RAY_ZPLUS, "Z_AXIS", 0, "Z-Axis", ""}, {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "DynamicPaintBrushSettings", NULL); @@ -722,22 +723,25 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Paint Color", "Color of the paint"); - RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "paint_alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "alpha"); RNA_def_property_range(prop, 0.0, 10.0); RNA_def_property_ui_range(prop, 0.0, 10.0, 5, 2); RNA_def_property_ui_text(prop, "Paint Alpha", "Paint alpha"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_USE_MATERIAL); RNA_def_property_ui_text(prop, "Use object material", "Use object material to define color and influence"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mat"); RNA_def_property_ui_text(prop, "Material", "Material to use. If not defined, material linked to the mesh is used"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "absolute_alpha", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ABS_ALPHA); @@ -748,10 +752,12 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 2); RNA_def_property_ui_text(prop, "Paint Wetness", "Paint wetness. Visible in wetmap. Some effects only affect wet paint"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "paint_erase", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ERASE); RNA_def_property_ui_text(prop, "Erase Paint", "Erase / remove paint instead of adding it"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "wave_type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -785,14 +791,17 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "velocity_alpha", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_VELOCITY_ALPHA); RNA_def_property_ui_text(prop, "Multiply Alpha", "Multiply brush influence by velocity color ramp alpha"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "velocity_depth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_VELOCITY_DEPTH); RNA_def_property_ui_text(prop, "Multiply Depth", "Multiply brush intersection depth (displace, waves) by velocity ramp alpha"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "velocity_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_VELOCITY_COLOR); RNA_def_property_ui_text(prop, "Replace Color", "Replace brush color by velocity color ramp"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); /* * Paint Area / Collision @@ -802,41 +811,48 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "collision"); RNA_def_property_enum_items(prop, prop_dynamicpaint_collisiontype); RNA_def_property_ui_text(prop, "Paint Source", ""); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "paint_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "paint_distance"); RNA_def_property_range(prop, 0.0, 500.0); RNA_def_property_ui_range(prop, 0.0, 500.0, 10, 3); RNA_def_property_ui_text(prop, "Proximity Distance", "Maximum distance from brush to mesh surface to affect paint"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop= RNA_def_property(srna, "prox_ramp_alpha", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "proximity_ramp_alpha", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_RAMP_ALPHA); RNA_def_property_ui_text(prop, "Only Use Alpha", "Only reads color ramp alpha"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop= RNA_def_property(srna, "prox_falloff", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "proximity_falloff", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_sdna(prop, NULL, "proximity_falloff"); RNA_def_property_enum_items(prop, prop_dynamicpaint_prox_falloff); RNA_def_property_ui_text(prop, "Falloff", "Proximity falloff type"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop= RNA_def_property(srna, "prox_project", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "proximity_project", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PROX_PROJECT); RNA_def_property_ui_text(prop, "Project", "Brush is projected to canvas from defined direction within brush proximity"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop= RNA_def_property(srna, "ray_dir", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "ray_direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ray_dir"); RNA_def_property_enum_items(prop, prop_dynamicpaint_brush_ray_dir); - RNA_def_property_ui_text(prop, "Ray Dir", "Defines ray direction to use for projection. If brush object is located in that direction it's painted"); + RNA_def_property_ui_text(prop, "Ray Direction", "Defines ray direction to use for projection. If brush object is located in that direction it's painted"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); - prop= RNA_def_property(srna, "prox_inverse", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "proximity_inverse", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_INVERSE_PROX); RNA_def_property_ui_text(prop, "Inner Proximity", "Proximity falloff is applied inside the volume"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); /* * Particle */ - prop= RNA_def_property(srna, "psys", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "psys"); RNA_def_property_struct_type(prop, "ParticleSystem"); RNA_def_property_flag(prop, PROP_EDITABLE); @@ -844,21 +860,24 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_resetDependancy"); - prop= RNA_def_property(srna, "use_part_radius", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_particle_radius", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_PART_RAD); RNA_def_property_ui_text(prop, "Use Particle Radius", "Uses radius from particle settings"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "solid_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "particle_radius"); RNA_def_property_range(prop, 0.01, 10.0); RNA_def_property_ui_range(prop, 0.01, 2.0, 5, 3); RNA_def_property_ui_text(prop, "Solid Radius", "Radius that will be painted solid"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "smooth_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "particle_smooth"); RNA_def_property_range(prop, 0.0, 10.0); RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 0); RNA_def_property_ui_text(prop, "Smooth Radius", "Smooth falloff added after solid radius"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); /* @@ -868,11 +887,13 @@ static void rna_def_dynamic_paint_brush_settings(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "paint_ramp"); RNA_def_property_struct_type(prop, "ColorRamp"); RNA_def_property_ui_text(prop, "Paint Color Ramp", "Color ramp used to define proximity falloff"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); prop= RNA_def_property(srna, "velocity_ramp", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "vel_ramp"); RNA_def_property_struct_type(prop, "ColorRamp"); RNA_def_property_ui_text(prop, "Velocity Color Ramp", "Color ramp used to define brush velocity effect"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_DynamicPaint_redoModifier"); } void RNA_def_dynamic_paint(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 707de14cab5..df1eb662a8c 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -14,6 +14,7 @@ #include +#include "DNA_dynamicpaint_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index cda15d3bf9b..09bbe1db9b1 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -124,7 +124,6 @@ int multitex_ext(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osa int multitex_ext_safe(struct Tex *tex, float *texvec, struct TexResult *texres){return 0;} int multitex_nodes(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres, short thread, short which_output, struct ShadeInput *shi, struct MTex *mtex) {return 0;} -/* material_ext.c */ struct Material *RE_init_sample_material(struct Material *orig_mat, struct Scene *scene) {return (struct Material *)NULL;} void RE_free_sample_material(struct Material *mat) {} void RE_sample_material_color(struct Material *mat, float color[3], float *alpha, const float volume_co[3], const float surface_co[3], -- cgit v1.2.3