[Bf-blender-cvs] [aae0598] temp_depsgraph_split_ubereval: Merge branch 'master' into temp_depsgraph_split_ubereval

Lukas Tönne noreply at git.blender.org
Wed Apr 20 16:45:54 CEST 2016


Commit: aae0598aa233d43d0ffc81a070b2ce20d6871c1d
Author: Lukas Tönne
Date:   Wed Apr 20 16:45:29 2016 +0200
Branches: temp_depsgraph_split_ubereval
https://developer.blender.org/rBaae0598aa233d43d0ffc81a070b2ce20d6871c1d

Merge branch 'master' into temp_depsgraph_split_ubereval

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



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

diff --cc source/blender/blenkernel/intern/DerivedMesh.c
index 65de8da,d120678..411d6ee
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@@ -50,9 -51,9 +51,10 @@@
  #include "BLI_linklist.h"
  
  #include "BKE_cdderivedmesh.h"
 +#include "BKE_depsgraph.h"
  #include "BKE_editmesh.h"
  #include "BKE_key.h"
+ #include "BKE_library.h"
  #include "BKE_material.h"
  #include "BKE_modifier.h"
  #include "BKE_mesh.h"
@@@ -1688,103 -1692,68 +1693,103 @@@ static void dm_ensure_display_normals(D
  	}
  }
  
 -/**
 - * new value for useDeform -1  (hack for the gameengine):
 - *
 - * - apply only the modifier stack of the object, skipping the virtual modifiers,
 - * - don't apply the key
 - * - apply deform modifiers and input vertexco
 - */
 -static void mesh_calc_modifiers(
 -        Scene *scene, Object *ob, float (*inputVertexCos)[3],
 -        const bool useRenderParams, int useDeform,
 -        const bool need_mapping, CustomDataMask dataMask,
 -        const int index, const bool useCache, const bool build_shapekey_layers,
 -        const bool allow_gpu,
 -        /* return args */
 -        DerivedMesh **r_deform, DerivedMesh **r_final)
 +/* immutable settings and precomputed temporary data */
 +typedef struct ModifierEvalContext {
 +	int draw_flag;
 +	int required_mode;
 +	bool need_mapping;
 +
 +	bool do_mod_mcol;
 +	bool do_final_wmcol;
 +	bool do_init_wmcol;
 +	bool do_mod_wmcol;
 +	
 +	bool do_loop_normals;
 +	float loop_normals_split_angle;
 +	
 +	ModifierApplyFlag app_flags;
 +	ModifierApplyFlag deform_app_flags;
 +	
 +	bool sculpt_mode;
 +	bool sculpt_dyntopo;
 +	bool sculpt_only_deform;
 +	bool has_multires;
 +	
 +	bool build_shapekey_layers;
 +	bool special_gameengine_hack;
 +	
 +	VirtualModifierData virtualModifierData;
 +	float (*inputVertexCos)[3]; /* XXX needed for freeing deformedVerts, not nice ... */
 +	
 +	ModifierData *md_begin;
 +	ModifierData *md_end;
 +	ModifierData *previewmd;
 +	CDMaskLink *datamasks;
 +} ModifierEvalContext;
 +
 +static void mesh_init_modifier_context(ModifierEvalContext *ctx,
 +                                       Scene *scene, Object *ob,
 +                                       float (*inputVertexCos)[3],
 +                                       const bool useRenderParams, int useDeform,
 +                                       const bool need_mapping,
 +                                       CustomDataMask dataMask,
 +                                       const int index,
 +                                       const bool useCache,
 +                                       const bool build_shapekey_layers,
 +                                       const bool allow_gpu)
  {
  	Mesh *me = ob->data;
 -	ModifierData *firstmd, *md, *previewmd = NULL;
 -	CDMaskLink *datamasks, *curr;
 -	/* XXX Always copying POLYINDEX, else tessellated data are no more valid! */
 -	CustomDataMask mask, nextmask, previewmask = 0, append_mask = CD_MASK_ORIGINDEX;
 -	float (*deformedVerts)[3] = NULL;
 -	DerivedMesh *dm = NULL, *orcodm, *clothorcodm, *finaldm;
 -	int numVerts = me->totvert;
 -	const int required_mode = useRenderParams ? eModifierMode_Render : eModifierMode_Realtime;
 -	bool isPrevDeform = false;
 -	const bool skipVirtualArmature = (useDeform < 0);
  	MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
 -	const bool has_multires = (mmd && mmd->sculptlvl != 0);
 -	bool multires_applied = false;
 -	const bool sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt && !useRenderParams;
 -	const bool sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm)  && !useRenderParams;
 -	const int draw_flag = dm_drawflag_calc(scene->toolsettings, me);
 +	CustomDataMask previewmask = 0;
 +	const bool skipVirtualArmature = (useDeform < 0);
 +
 +	ctx->inputVertexCos = inputVertexCos;
  
 +	ctx->app_flags =   (useRenderParams ? MOD_APPLY_RENDER : 0)
 +	                 | (useCache ? MOD_APPLY_USECACHE : 0)
 +	                 | (allow_gpu ? MOD_APPLY_ALLOW_GPU : 0);
 +	
 +	ctx->deform_app_flags =   ctx->app_flags
 +	                        | (useDeform ? MOD_APPLY_USECACHE : 0);
 +	
- 	ctx->draw_flag = dm_drawflag_calc(scene->toolsettings);
++	ctx->draw_flag = dm_drawflag_calc(scene->toolsettings, me);
 +	ctx->required_mode = useRenderParams ? eModifierMode_Render : eModifierMode_Realtime;
 +	ctx->need_mapping = need_mapping;
 +	
  	/* Generic preview only in object mode! */
 -	const bool do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
 +	ctx->do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
  #if 0 /* XXX Will re-enable this when we have global mod stack options. */
 -	const bool do_final_wmcol = (scene->toolsettings->weights_preview == WP_WPREVIEW_FINAL) && do_wmcol;
 +	ctx->do_final_wmcol = (scene->toolsettings->weights_preview == WP_WPREVIEW_FINAL) && do_wmcol;
 +#else
 +	ctx->do_final_wmcol = false;
  #endif
 -	const bool do_final_wmcol = false;
 -	const bool do_init_wmcol = ((dataMask & CD_MASK_PREVIEW_MLOOPCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && !do_final_wmcol);
 +	ctx->do_init_wmcol = ((dataMask & CD_MASK_PREVIEW_MLOOPCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && !ctx->do_final_wmcol);
  	/* XXX Same as above... For now, only weights preview in WPaint mode. */
 -	const bool do_mod_wmcol = do_init_wmcol;
 +	ctx->do_mod_wmcol = ctx->do_init_wmcol;
  
 -	const bool do_loop_normals = (me->flag & ME_AUTOSMOOTH) != 0;
 -	const float loop_normals_split_angle = me->smoothresh;
 +	ctx->do_loop_normals = (me->flag & ME_AUTOSMOOTH) != 0;
 +	ctx->loop_normals_split_angle = me->smoothresh;
  
 -	VirtualModifierData virtualModifierData;
 +	ctx->sculpt_mode = (ob->mode & OB_MODE_SCULPT) && ob->sculpt && !useRenderParams;
 +	ctx->sculpt_dyntopo = (ctx->sculpt_mode && ob->sculpt->bm)  && !useRenderParams;
 +	ctx->sculpt_only_deform = (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM);
  
 -	ModifierApplyFlag app_flags = useRenderParams ? MOD_APPLY_RENDER : 0;
 -	ModifierApplyFlag deform_app_flags = app_flags;
 +	ctx->has_multires = (mmd && mmd->sculptlvl != 0);
  
 +	/*
 +	 * new value for useDeform -1  (hack for the gameengine):
 +	 *
 +	 * - apply only the modifier stack of the object, skipping the virtual modifiers,
 +	 * - don't apply the key
 +	 * - apply deform modifiers and input vertexco
 +	 */
 +	ctx->special_gameengine_hack = (useDeform < 0);
 +	ctx->build_shapekey_layers = build_shapekey_layers;
  
 -	if (useCache)
 -		app_flags |= MOD_APPLY_USECACHE;
 -	if (allow_gpu)
 -		app_flags |= MOD_APPLY_ALLOW_GPU;
 -	if (useDeform)
 -		deform_app_flags |= MOD_APPLY_USECACHE;
 +	/* precompute data */
  
  	if (!skipVirtualArmature) {
 -		firstmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
 +		ctx->md_begin = modifiers_getVirtualModifierList(ob, &ctx->virtualModifierData);
  	}
  	else {
  		/* game engine exception */
@@@ -1810,291 -1780,334 +1815,291 @@@
  			}
  		}
  	}
 +	else
 +		ctx->previewmd = NULL;
  
 -	datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, previewmd, previewmask);
 -	curr = datamasks;
 -
 -	if (r_deform) {
 -		*r_deform = NULL;
 -	}
 -	*r_final = NULL;
 -
 -	if (useDeform) {
 -		if (inputVertexCos)
 -			deformedVerts = inputVertexCos;
 -		
 -		/* Apply all leading deforming modifiers */
 -		for (; md; md = md->next, curr = curr->next) {
 -			const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 -
 -			md->scene = scene;
 -			
 -			if (!modifier_isEnabled(scene, md, required_mode)) {
 -				continue;
 -			}
 +	ctx->datamasks = modifiers_calcDataMasks(scene, ob, ctx->md_begin, dataMask, ctx->required_mode, ctx->previewmd, previewmask);
 +}
  
 -			if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) {
 -				continue;
 -			}
 +static void mesh_free_modifier_context(ModifierEvalContext *ctx)
 +{
 +	BLI_linklist_free((LinkNode *)ctx->datamasks, NULL);
 +}
  
 -			if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) {
 -				if (!deformedVerts)
 -					deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
 +/* combined iterator for modifier and associated data mask */
 +typedef struct ModifierEvalIterator {
 +	ModifierData *modifier;
 +	CDMaskLink *datamask;
  
 -				modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, deform_app_flags);
 -			}
 -			else {
 -				break;
 -			}
 -			
 -			/* grab modifiers until index i */
 -			if ((index != -1) && (BLI_findindex(&ob->modifiers, md) >= index))
 -				break;
 -		}
 +	/* mutable flags */
 +	bool multires_applied;
 +	bool isPrevDeform;
 +	CustomDataMask append_mask;
 +} ModifierEvalIterator;
  
 -		/* Result of all leading deforming modifiers is cached for
 -		 * places that wish to use the original mesh but with deformed
 -		 * coordinates (vpaint, etc.)
 -		 */
 -		if (r_deform) {
 -			*r_deform = CDDM_from_mesh(me);
 +static bool mesh_calc_modifier_sculptmode_skip(const ModifierEvalContext *ctx, ModifierData *md,
 +                                               const bool multires_applied)
 +{
 +	const bool multires_pending = ctx->has_multires && !multires_applied;
 +	
 +	if (ctx->sculpt_mode && (!multires_pending || ctx->sculpt_dyntopo))
 +	{
 +		const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
 +		const bool useRenderParams = ctx->app_flags & MOD_APPLY_RENDER;
 +		bool unsupported = false;
  
 -			if (build_shapekey_layers)
 -				add_shapekey_layers(dm, me, ob);
 -			
 -			if (deformedVerts) {
 -				CDDM_apply_vert_coords(*r_deform, deformedVerts);
 +		if (md->type == eModifierType_Multires && ((MultiresModifierData *)md)->sculptlvl == 0) {
 +			/* If multires is on level 0 skip it silently without warning message. */
 +			if (!ctx->sculpt_dyntopo) {
 +				return true;
  			}
  		}
 -	}
 -	else {
 -		/* default behavior for meshes */
 -		if (inputVertexCos)
 -			deformedVerts = inputVertexCos;
 -		else
 -			deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
 -	}
  
 +		if (ctx->sculpt_dyntopo && !useRenderParams)
 +			unsupported = true;
  
 -	/* Now apply all remaining modifiers. If useDeform is off then skip
 -	 * OnlyDeform ones. 
 -	 */
 -	dm = NULL;
 -	orcodm = NULL;
 -	clothorcodm = NULL;
 -
 -	for (; md; md = md->next, curr = curr->next) {
 -		const ModifierTypeInfo *mti = modifierType_getInfo(md->t

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list