Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/dynamicpaint.c
| Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| /* to read material/texture color */ | /* to read material/texture color */ | ||||
| #include "RE_render_ext.h" | #include "RE_render_ext.h" | ||||
| #include "RE_shader_ext.h" | #include "RE_shader_ext.h" | ||||
| #include "atomic_ops.h" | #include "atomic_ops.h" | ||||
| #include "CLG_log.h" | |||||
| /* could enable at some point but for now there are far too many conversions */ | /* could enable at some point but for now there are far too many conversions */ | ||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||
| //# pragma GCC diagnostic ignored "-Wdouble-promotion" | //# pragma GCC diagnostic ignored "-Wdouble-promotion" | ||||
| #endif | #endif | ||||
| static CLG_LogRef LOG = {"bke.dynamicpaint"}; | |||||
| /* precalculated gaussian factors for 5x super sampling */ | /* precalculated gaussian factors for 5x super sampling */ | ||||
| static const float gaussianFactors[5] = { | static const float gaussianFactors[5] = { | ||||
| 0.996849f, | 0.996849f, | ||||
| 0.596145f, | 0.596145f, | ||||
| 0.596145f, | 0.596145f, | ||||
| 0.596145f, | 0.596145f, | ||||
| 0.524141f}; | 0.524141f}; | ||||
| static const float gaussianTotal = 3.309425f; | static const float gaussianTotal = 3.309425f; | ||||
| ▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | |||||
| /***************************** General Utils ******************************/ | /***************************** General Utils ******************************/ | ||||
| /* Set canvas error string to display at the bake report */ | /* Set canvas error string to display at the bake report */ | ||||
| static int setError(DynamicPaintCanvasSettings *canvas, const char *string) | static int setError(DynamicPaintCanvasSettings *canvas, const char *string) | ||||
| { | { | ||||
| /* Add error to canvas ui info label */ | /* Add error to canvas ui info label */ | ||||
| BLI_strncpy(canvas->error, string, sizeof(canvas->error)); | BLI_strncpy(canvas->error, string, sizeof(canvas->error)); | ||||
| CLOG_STR_ERROR(&LOG, string); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* Get number of surface points for cached types */ | /* Get number of surface points for cached types */ | ||||
| static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface) | static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface) | ||||
| { | { | ||||
| if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) { | if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) { | ||||
| return 0; /* not supported atm */ | return 0; /* not supported atm */ | ||||
| ▲ Show 20 Lines • Show All 2,554 Lines • ▼ Show 20 Lines | if (surface->image_resolution < 16 || surface->image_resolution > 8192) | ||||
| return setError(canvas, N_("Invalid resolution")); | return setError(canvas, N_("Invalid resolution")); | ||||
| const int w = surface->image_resolution; | const int w = surface->image_resolution; | ||||
| const int h = w; | const int h = w; | ||||
| /* | /* | ||||
| * Start generating the surface | * Start generating the surface | ||||
| */ | */ | ||||
| printf("DynamicPaint: Preparing UV surface of %ix%i pixels and %i tris.\n", w, h, tottri); | CLOG_INFO(&LOG, 1, "Preparing UV surface of %ix%i pixels and %i tris.", w, h, tottri); | ||||
| /* Init data struct */ | /* Init data struct */ | ||||
| if (surface->data) | if (surface->data) | ||||
| dynamicPaint_freeSurfaceData(surface); | dynamicPaint_freeSurfaceData(surface); | ||||
| sData = surface->data = MEM_callocN(sizeof(PaintSurfaceData), "PaintSurfaceData"); | sData = surface->data = MEM_callocN(sizeof(PaintSurfaceData), "PaintSurfaceData"); | ||||
| if (!surface->data) | if (!surface->data) | ||||
| return setError(canvas, N_("Not enough free memory")); | return setError(canvas, N_("Not enough free memory")); | ||||
| ▲ Show 20 Lines • Show All 1,621 Lines • ▼ Show 20 Lines | for (ParticleData *pa = psys->particles; p < psys->totpart; p++, pa++) { | ||||
| BLI_kdtree_insert(tree, p, pa->state.co); | BLI_kdtree_insert(tree, p, pa->state.co); | ||||
| /* calc particle system bounds */ | /* calc particle system bounds */ | ||||
| boundInsert(&part_bb, pa->state.co); | boundInsert(&part_bb, pa->state.co); | ||||
| particlesAdded++; | particlesAdded++; | ||||
| } | } | ||||
| if (invalidParticles) | if (invalidParticles) | ||||
| printf("Warning: Invalid particle(s) found!\n"); | CLOG_WARN(&LOG, "Invalid particle(s) found!"); | ||||
| /* If no suitable particles were found, exit */ | /* If no suitable particles were found, exit */ | ||||
| if (particlesAdded < 1) { | if (particlesAdded < 1) { | ||||
| BLI_kdtree_free(tree); | BLI_kdtree_free(tree); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| /* begin thread safe malloc */ | /* begin thread safe malloc */ | ||||
| ▲ Show 20 Lines • Show All 1,610 Lines • Show Last 20 Lines | |||||