[Bf-blender-cvs] [faec430] blender2.8: Merge branch 'master' into blender2.8

Bastien Montagne noreply at git.blender.org
Tue May 24 16:48:33 CEST 2016


Commit: faec4309147988fbab7b7d7ec661f5130358d169
Author: Bastien Montagne
Date:   Tue May 24 16:48:10 2016 +0200
Branches: blender2.8
https://developer.blender.org/rBfaec4309147988fbab7b7d7ec661f5130358d169

Merge branch 'master' into blender2.8

Conflicts:
	intern/cycles/blender/blender_curves.cpp
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/particle.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/physics/particle_edit.c
	source/blender/editors/transform/transform_snap_object.c
	source/blender/editors/util/undo.c
	source/blender/makesrna/intern/rna_object_force.c

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/dynamicpaint.c
index 73d64c2,2d531e3..7842d56
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@@ -65,8 -65,11 +66,9 @@@
  #include "BKE_image.h"
  #include "BKE_main.h"
  #include "BKE_material.h"
+ #include "BKE_mesh_mapping.h"
  #include "BKE_modifier.h"
  #include "BKE_object.h"
 -#include "BKE_particle.h"
 -#include "BKE_pointcache.h"
  #include "BKE_scene.h"
  #include "BKE_texture.h"
  
@@@ -565,13 -559,15 +558,15 @@@ static bool boundsIntersectDist(Bounds3
  }
  
  /* check whether bounds intersects a point with given radius */
- static int UNUSED_FUNCTION(boundIntersectPoint)(Bounds3D *b, float point[3], float radius)
 -static bool boundIntersectPoint(Bounds3D *b, float point[3], const float radius)
++static bool UNUSED_FUNCTION(boundIntersectPoint)(Bounds3D *b, float point[3], const float radius)
  {
- 	int i = 2;
- 	if (!b->valid) return 0;
- 	for (; i >= 0; i -= 1)
- 		if (!(b->min[i] <= (point[i] + radius) && b->max[i] >= (point[i] - radius))) return 0;
- 	return 1;
+ 	if (!b->valid)
+ 		return false;
+ 	for (int i = 2; i--;) {
+ 		if (!(b->min[i] <= (point[i] + radius) && b->max[i] >= (point[i] - radius)))
+ 			return false;
+ 	}
+ 	return true;
  }
  
  /* expand bounds by a new point */
@@@ -834,11 -854,11 +853,11 @@@ static void free_bakeData(PaintSurfaceD
  /* free surface data if it's not used anymore */
  static void surface_freeUnusedData(DynamicPaintSurface *surface)
  {
- 	if (!surface->data) return;
+ 	if (!surface->data)
+ 		return;
  
  	/* free bakedata if not active or surface is baked */
- 	if (!(surface->flags & MOD_DPAINT_ACTIVE))
- 	{
 -	if (!(surface->flags & MOD_DPAINT_ACTIVE) || (surface->pointcache && surface->pointcache->flag & PTCACHE_BAKED)) {
++	if (!(surface->flags & MOD_DPAINT_ACTIVE)) {
  		free_bakeData(surface->data);
  	}
  }
@@@ -1020,9 -1052,11 +1042,9 @@@ bool dynamicPaint_createType(struct Dyn
  				return false;
  			brush->pmd = pmd;
  
 -			brush->psys = NULL;
 -
  			brush->flags = MOD_DPAINT_ABS_ALPHA | MOD_DPAINT_RAMP_ALPHA;
  			brush->collision = MOD_DPAINT_COL_VOLUME;
- 			
+ 
  			brush->mat = NULL;
  			brush->r = 0.15f;
  			brush->g = 0.4f;
@@@ -1837,11 -1994,32 +1972,13 @@@ static void dynamicPaint_frameUpdate(Dy
  			/* limit frame range */
  			CLAMP(current_frame, surface->start_frame, surface->end_frame);
  
- 			if (no_surface_data || current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
+ 			if (no_surface_data || current_frame != surface->current_frame ||
+ 			    (int)scene->r.cfra == surface->start_frame)
+ 			{
 -				PointCache *cache = surface->pointcache;
 -				PTCacheID pid;
  				surface->current_frame = current_frame;
  
 -				/* read point cache */
 -				BKE_ptcache_id_from_dynamicpaint(&pid, ob, surface);
 -				pid.cache->startframe = surface->start_frame;
 -				pid.cache->endframe = surface->end_frame;
 -				BKE_ptcache_id_time(&pid, scene, (float)scene->r.cfra, NULL, NULL, NULL);
 -
 -				/* reset non-baked cache at first frame */
 -				if ((int)scene->r.cfra == surface->start_frame && !(cache->flag & PTCACHE_BAKED)) {
 -					cache->flag |= PTCACHE_REDO_NEEDED;
 -					BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
 -					cache->flag &= ~PTCACHE_REDO_NEEDED;
 -				}
 -
 -				/* try to read from cache */
 -				if (BKE_ptcache_read(&pid, (float)scene->r.cfra)) {
 -					BKE_ptcache_validate(cache, (int)scene->r.cfra);
 -				}
 -				/* if read failed and we're on surface range do recalculate */
 -				else if ((int)scene->r.cfra == current_frame && !(cache->flag & PTCACHE_BAKED)) {
 +				/* if we're on surface range do recalculate */
 +				if ((int)scene->r.cfra == current_frame) {
  					/* calculate surface frame */
  					canvas->flags |= MOD_DPAINT_BAKING;
  					dynamicPaint_calculateFrame(surface, scene, ob, current_frame);
@@@ -3100,6 -3443,31 +3399,30 @@@ static void dynamicPaint_brushObjectCal
  	mul_v3_fl(brushVel->v, 1.0f / timescale);
  }
  
+ typedef struct DynamicPaintPaintData {
+ 	const DynamicPaintSurface *surface;
+ 	const DynamicPaintBrushSettings *brush;
+ 	Object *brushOb;
+ 	const BrushMaterials *bMats;
+ 	const Scene *scene;
+ 	const float timescale;
+ 	const int c_index;
+ 
+ 	DerivedMesh *dm;
+ 	const MVert *mvert;
+ 	const MLoop *mloop;
+ 	const MLoopTri *mlooptri;
+ 	const float brush_radius;
+ 	const float *avg_brushNor;
+ 	const Vec3f *brushVelocity;
+ 
 -	const ParticleSystem *psys;
+ 	const float solidradius;
+ 
+ 	void *treeData;
+ 
+ 	float *pointCoord;
+ } DynamicPaintPaintData;
+ 
  /*
   *	Paint a brush object mesh to the surface
   */
@@@ -3487,111 -3909,420 +3864,143 @@@ static int dynamicPaint_paintMesh(Dynam
  	return 1;
  }
  
 -/*
 - *	Paint a particle system to the surface
 - */
 -static void dynamic_paint_paint_particle_cell_point_cb_ex(
 -        void *userdata, void *UNUSED(userdata_chunk), const int id, const int UNUSED(threadid))
 -{
 -	const DynamicPaintPaintData *data = userdata;
 -
 -	const DynamicPaintSurface *surface = data->surface;
 -	const PaintSurfaceData *sData = surface->data;
 -	const PaintBakeData *bData = sData->bData;
 -	VolumeGrid *grid = bData->grid;
 -
 -	const DynamicPaintBrushSettings *brush = data->brush;
 -
 -	const ParticleSystem *psys = data->psys;
 -
 -	const float timescale = data->timescale;
 -	const int c_index = data->c_index;
 -
 -	KDTree *tree = data->treeData;
 -
 -	const float solidradius = data->solidradius;
 -	const float smooth = brush->particle_smooth * surface->radius_scale;
 -	const float range = solidradius + smooth;
 -	const float particle_timestep = 0.04f * psys->part->timetweak;
 -
 -	const int index = grid->t_index[grid->s_pos[c_index] + id];
 -	float disp_intersect = 0.0f;
 -	float radius = 0.0f;
 -	float strength = 0.0f;
 -	int part_index = -1;
 -
 -	/*
 -	 *	With predefined radius, there is no variation between particles.
 -	 *	It's enough to just find the nearest one.
 -	 */
 -	{
 -		KDTreeNearest nearest;
 -		float smooth_range, part_solidradius;
 -
 -		/* Find nearest particle and get distance to it	*/
 -		BLI_kdtree_find_nearest(tree, bData->realCoord[bData->s_pos[index]].v, &nearest);
 -		/* if outside maximum range, no other particle can influence either */
 -		if (nearest.dist > range)
 -			return;
 -
 -		if (brush->flags & MOD_DPAINT_PART_RAD) {
 -			/* use particles individual size */
 -			ParticleData *pa = psys->particles + nearest.index;
 -			part_solidradius = pa->size;
 -		}
 -		else {
 -			part_solidradius = solidradius;
 -		}
 -		radius = part_solidradius + smooth;
 -		if (nearest.dist < radius) {
 -			/* distances inside solid radius has maximum influence -> dist = 0	*/
 -			smooth_range = max_ff(0.0f, (nearest.dist - part_solidradius));
 -			/* do smoothness if enabled	*/
 -			if (smooth)
 -				smooth_range /= smooth;
 -
 -			strength = 1.0f - smooth_range;
 -			disp_intersect = radius - nearest.dist;
 -			part_index = nearest.index;
 -		}
 -	}
 -	/* If using random per particle radius and closest particle didn't give max influence	*/
 -	if (brush->flags & MOD_DPAINT_PART_RAD && strength < 1.0f && psys->part->randsize > 0.0f) {
 -		/*
 -		 *	If we use per particle radius, we have to sample all particles
 -		 *	within max radius range
 -		 */
 -		KDTreeNearest *nearest;
 -
 -		float smooth_range = smooth * (1.0f - strength), dist;
 -		/* calculate max range that can have particles with higher influence than the nearest one */
 -		const float max_range = smooth - strength * smooth + solidradius;
 -		/* Make gcc happy! */
 -		dist = max_range;
 -
 -		const int particles = BLI_kdtree_range_search(
 -		                          tree, bData->realCoord[bData->s_pos[index]].v, &nearest, max_range);
 -
 -		/* Find particle that produces highest influence */
 -		for (int n = 0; n < particles; n++) {
 -			ParticleData *pa = &psys->particles[nearest[n].index];
 -
 -			/* skip if out of range */
 -			if (nearest[n].dist > (pa->size + smooth))
 -				continue;
 -
 -			/* update hit data */
 -			const float s_range = nearest[n].dist - pa->size;
 -			/* skip if higher influence is already found */
 -			if (smooth_range < s_range)
 -				continue;
 -
 -			/* update hit data */
 -			smooth_range = s_range;
 -			dist = nearest[n].dist;
 -			part_index = nearest[n].index;
 -
 -			/* If inside solid range and no disp depth required, no need to seek further */
 -			if ((s_range < 0.0f) && !ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE)) {
 -				break;
 -			}
 -		}
 -
 -		if (nearest)
 -			MEM_freeN(nearest);
 -
 -		/* now calculate influence for this particle */
 -		const float rad = radius + smooth;
 -		if ((rad - dist) > disp_intersect) {
 -			disp_intersect = radius - dist;
 -			radius = rad;
 -		}
 -
 -		/* do smoothness if enabled	*/
 -		CLAMP_MIN(smooth_range, 0.0f);
 -		if (smooth)
 -			smooth_range /= smooth;
 -
 -		const float str = 1.0f - smooth_range;
 -		/* if influence is greater, use this one	*/
 -		if (str > strength)
 -			strength = str;
 -	}
 -
 -	if (strength > 0.001f) {
 -		float paintColor[4] = {0.0f};
 -		float depth = 0.0f;
 -		float velocity_val = 0.0f;
 -
 -		/* apply velocity */
 -		if ((brush->flags & MOD_DPAINT_USES_VELOCITY) && (part_index != -1)) {
 -			float velocity[3];
 -			ParticleData *pa = psys->particles + part_index;
 -			mul_v3_v3fl(velocity, pa->state.vel, particle_timestep);
 -
 -			/* substract canvas point velocity */
 -			if (bData->velocity) {
 -				sub_v3_v3(velocity, bData->velocity[index].v);
 -			}
 -			velocity_val = normalize_v3(velocity);
 -
 -			/* store brush velocity for smudge */
 -			if ((surface->type == MOD_DPAINT_SURFACE_T_PAINT) &&
 -			    (brush->flags & MOD_DPAINT_DO_SMUDGE && bData->brush_velocity))
 -			{
 -				copy_v3_v3(&bData->brush_velocity[index * 4], velocity);
 -				bData->brush_velocity[index * 4 + 3] = velocity_val;
 -			}
 -		}
 -
 -		if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
 -			copy_v3_v3(paintColor, &brush->r);
 -		}
 -		else if (ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE)) {
 -			/* get displace depth	*/
 -			disp_intersect = (1.0f - sqrtf(disp_intersect / radius)) * radius;
 -			dep

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list