diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-25 14:39:56 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-01-25 14:39:56 +0300 |
commit | cbb23d96bb4644bd4fdeadbfd790694e57983c53 (patch) | |
tree | 544b5674164199f17f423b94f976cdf12dadc756 /source/blender | |
parent | aab5a7a4af19335f07231b30f86df8d2fc7bc9e7 (diff) |
Added simplification back for quicker preview renders with less subdivision
levels, child particles, and shadow/SSS/AO quality.. Now also works on what
is displayed in the 3d view instead of only rendering, see panel in the scene
properties.
Most file changes were to make scene available in the isDisabled modifier
callback function.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_DerivedMesh.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 11 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 14 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 11 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 58 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 1 |
16 files changed, 127 insertions, 55 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 01f863a4c2e..29b3d09807d 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -502,8 +502,8 @@ void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct EditMesh *em /* returns an array of deform matrices for crazyspace correction, and the number of modifiers left */ -int editmesh_get_first_deform_matrices(struct Object *, struct EditMesh *em, float (**deformmats)[3][3], - float (**deformcos)[3]); +int editmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct EditMesh *em, + float (**deformmats)[3][3], float (**deformcos)[3]); void weight_to_rgb(float input, float *fr, float *fg, float *fb); diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index dd5f391cc5c..562144d2edb 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -279,10 +279,10 @@ void modifier_unique_name(struct ListBase *modifiers, struct ModifierData *m void modifier_copyData(struct ModifierData *md, struct ModifierData *target); int modifier_dependsOnTime(struct ModifierData *md); int modifier_supportsMapping(struct ModifierData *md); -int modifier_couldBeCage(struct ModifierData *md); +int modifier_couldBeCage(struct Scene *scene, struct ModifierData *md); int modifier_isCorrectableDeformed(struct ModifierData *md); int modifier_sameTopology(ModifierData *md); -int modifier_isEnabled(struct ModifierData *md, int required_mode); +int modifier_isEnabled(struct Scene *scene, struct ModifierData *md, int required_mode); void modifier_setError(struct ModifierData *md, char *format, ...); void modifiers_foreachObjectLink(struct Object *ob, @@ -293,7 +293,7 @@ void modifiers_foreachIDLink(struct Object *ob, void *userData); struct ModifierData *modifiers_findByType(struct Object *ob, ModifierType type); void modifiers_clearErrors(struct Object *ob); -int modifiers_getCageIndex(struct Object *ob, +int modifiers_getCageIndex(struct Scene *scene, struct Object *ob, int *lastPossibleCageIndex_r, int virtual_); int modifiers_isSoftbodyEnabled(struct Object *ob); @@ -313,7 +313,8 @@ int modifiers_indexInObject(struct Object *ob, struct ModifierData *md * evaluation, assuming the data indicated by dataMask is required at the * end of the stack. */ -struct LinkNode *modifiers_calcDataMasks(struct Object *ob, +struct LinkNode *modifiers_calcDataMasks(struct Scene *scene, + struct Object *ob, struct ModifierData *md, CustomDataMask dataMask, int required_mode); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3ffa32c700d..28c9dfb317c 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1643,7 +1643,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* we always want to keep original indices */ dataMask |= CD_MASK_ORIGINDEX; - datamasks = modifiers_calcDataMasks(ob, md, dataMask, required_mode); + datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode); curr = datamasks; if(deform_r) *deform_r = NULL; @@ -1659,7 +1659,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos md->scene= scene; - if(!modifier_isEnabled(md, required_mode)) continue; + if(!modifier_isEnabled(scene, md, required_mode)) continue; if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; if(mti->type == eModifierTypeType_OnlyDeform) { @@ -1708,7 +1708,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos md->scene= scene; - if(!modifier_isEnabled(md, required_mode)) continue; + if(!modifier_isEnabled(scene, md, required_mode)) continue; if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue; if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { modifier_setError(md, "Modifier requires original data, bad stack position."); @@ -1884,12 +1884,12 @@ static float (*editmesh_getVertexCos(EditMesh *em, int *numVerts_r))[3] return cos; } -static int editmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm) +static int editmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *dm) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; - if(!modifier_isEnabled(md, required_mode)) return 0; + if(!modifier_isEnabled(scene, md, required_mode)) return 0; if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { modifier_setError(md, "Modifier requires original data, bad stack position."); return 0; @@ -1906,7 +1906,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri float (*deformedVerts)[3] = NULL; CustomDataMask mask; DerivedMesh *dm, *orcodm = NULL; - int i, numVerts = 0, cageIndex = modifiers_getCageIndex(ob, NULL, 1); + int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1); LinkNode *datamasks, *curr; int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; @@ -1922,7 +1922,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri /* we always want to keep original indices */ dataMask |= CD_MASK_ORIGINDEX; - datamasks = modifiers_calcDataMasks(ob, md, dataMask, required_mode); + datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode); curr = datamasks; for(i = 0; md; i++, md = md->next, curr = curr->next) { @@ -1930,7 +1930,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri md->scene= scene; - if(!editmesh_modifier_is_enabled(md, dm)) + if(!editmesh_modifier_is_enabled(scene, md, dm)) continue; /* add an orco layer if needed by this modifier */ @@ -2348,12 +2348,12 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob) /* ********* crazyspace *************** */ -int editmesh_get_first_deform_matrices(Object *ob, EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) +int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) { ModifierData *md; DerivedMesh *dm; int i, a, numleft = 0, numVerts = 0; - int cageIndex = modifiers_getCageIndex(ob, NULL, 1); + int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1); float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL; modifiers_clearErrors(ob); @@ -2367,7 +2367,7 @@ int editmesh_get_first_deform_matrices(Object *ob, EditMesh *em, float (**deform for(i = 0; md && i <= cageIndex; i++, md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(!editmesh_modifier_is_enabled(md, dm)) + if(!editmesh_modifier_is_enabled(scene, md, dm)) continue; if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { @@ -2388,7 +2388,7 @@ int editmesh_get_first_deform_matrices(Object *ob, EditMesh *em, float (**deform } for(; md && i <= cageIndex; md = md->next, i++) - if(editmesh_modifier_is_enabled(md, dm) && modifier_isCorrectableDeformed(md)) + if(editmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md)) numleft++; if(dm) diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index f09c92d6091..df46943d7b1 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -101,6 +101,7 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_scene.h" #include "BKE_smoke.h" #include "BKE_softbody.h" #include "BKE_subsurf.h" @@ -427,8 +428,9 @@ static void subsurfModifier_freeData(ModifierData *md) static int subsurfModifier_isDisabled(ModifierData *md, int useRenderParams) { SubsurfModifierData *smd = (SubsurfModifierData*) md; + int levels= (useRenderParams)? smd->renderLevels: smd->levels; - return (useRenderParams)? (smd->renderLevels == 0): (smd->levels == 0); + return get_render_subsurf_level(&md->scene->r, levels) == 0; } static DerivedMesh *subsurfModifier_applyModifier( @@ -9181,10 +9183,12 @@ void modifier_copyData(ModifierData *md, ModifierData *target) mti->copyData(md, target); } -int modifier_couldBeCage(ModifierData *md) +int modifier_couldBeCage(Scene *scene, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + md->scene= scene; + return ( (md->mode & eModifierMode_Realtime) && (md->mode & eModifierMode_Editmode) && (!mti->isDisabled || !mti->isDisabled(md, 0)) && @@ -9219,11 +9223,13 @@ void modifier_setError(ModifierData *md, char *format, ...) * also used in transform_conversion.c, to detect CrazySpace [tm] (2nd arg * then is NULL) */ -int modifiers_getCageIndex(Object *ob, int *lastPossibleCageIndex_r, int virtual_) +int modifiers_getCageIndex(Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) { ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first; int i, cageIndex = -1; + md->scene= scene; + /* Find the last modifier acting on the cage. */ for (i=0; md; i++,md=md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -9267,10 +9273,12 @@ int modifiers_isParticleEnabled(Object *ob) return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)); } -int modifier_isEnabled(ModifierData *md, int required_mode) +int modifier_isEnabled(Scene *scene, ModifierData *md, int required_mode) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + md->scene= scene; + if((md->mode & required_mode) != required_mode) return 0; if(mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0; if(md->mode & eModifierMode_DisableTemporary) return 0; @@ -9280,7 +9288,7 @@ int modifier_isEnabled(ModifierData *md, int required_mode) return 1; } -LinkNode *modifiers_calcDataMasks(Object *ob, ModifierData *md, CustomDataMask dataMask, int required_mode) +LinkNode *modifiers_calcDataMasks(Scene *scene, Object *ob, ModifierData *md, CustomDataMask dataMask, int required_mode) { LinkNode *dataMasks = NULL; LinkNode *curr, *prev; @@ -9290,7 +9298,7 @@ LinkNode *modifiers_calcDataMasks(Object *ob, ModifierData *md, CustomDataMask d ModifierTypeInfo *mti = modifierType_getInfo(md->type); CustomDataMask mask = 0; - if(modifier_isEnabled(md, required_mode)) + if(modifier_isEnabled(scene, md, required_mode)) if(mti->requiredDataMask) mask = mti->requiredDataMask(ob, md); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index f5414567da8..7f08846177a 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -50,6 +50,7 @@ #include "BKE_modifier.h" #include "BKE_multires.h" #include "BKE_object.h" +#include "BKE_scene.h" #include "BKE_subsurf.h" #include "BKE_utildefines.h" @@ -84,11 +85,11 @@ MultiresModifierData *find_multires_modifier(Object *ob) static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) { if(render) - return mmd->renderlvl; + return get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl); else if(ob->mode == OB_MODE_SCULPT) return mmd->sculptlvl; else - return mmd->lvl; + return get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl); } static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 19187ed35af..6dba1a2e9ba 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -247,12 +247,12 @@ static int get_psys_child_number(struct Scene *scene, ParticleSystem *psys) if(!psys->part->childtype) return 0; - if(psys->renderdata) { + if(psys->renderdata) nbr= psys->part->ren_child_nbr; - return get_render_child_particle_number(&scene->r, nbr); - } else - return psys->part->child_nbr; + nbr= psys->part->child_nbr; + + return get_render_child_particle_number(&scene->r, nbr); } static int get_psys_tot_child(struct Scene *scene, ParticleSystem *psys) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f17d11c40ce..a12fa36b519 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -925,7 +925,7 @@ void scene_add_render_layer(Scene *sce) int get_render_subsurf_level(RenderData *r, int lvl) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY)) + if(r->mode & R_SIMPLIFY) return MIN2(r->simplify_subsurf, lvl); else return lvl; @@ -933,7 +933,7 @@ int get_render_subsurf_level(RenderData *r, int lvl) int get_render_child_particle_number(RenderData *r, int num) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY)) + if(r->mode & R_SIMPLIFY) return (int)(r->simplify_particles*num); else return num; @@ -941,7 +941,7 @@ int get_render_child_particle_number(RenderData *r, int num) int get_render_shadow_samples(RenderData *r, int samples) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY) && samples > 0) + if((r->mode & R_SIMPLIFY) && samples > 0) return MIN2(r->simplify_shadowsamples, samples); else return samples; @@ -949,7 +949,7 @@ int get_render_shadow_samples(RenderData *r, int samples) float get_render_aosss_error(RenderData *r, float error) { - if(G.rt == 1 && (r->mode & R_SIMPLIFY)) + if(r->mode & R_SIMPLIFY) return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error; else return error; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 3997f83ed49..ef015208354 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2506,7 +2506,9 @@ struct DerivedMesh *subsurf_make_derived_from_derived( CCGDerivedMesh *result; if(editMode) { - smd->emCache = _getSubSurf(smd->emCache, smd->levels, useAging, 0, + int levels= get_render_subsurf_level(&smd->modifier.scene->r, smd->levels); + + smd->emCache = _getSubSurf(smd->emCache, levels, useAging, 0, useSimple); ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple); @@ -2518,7 +2520,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( CCGSubSurf *ss; int levels; - levels= smd->renderLevels; // XXX get_render_subsurf_level(&scene->r, smd->renderLevels); + levels= get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels); if(levels == 0) return dm; @@ -2533,6 +2535,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } else { int useIncremental = (smd->flags & eSubsurfModifierFlag_Incremental); int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr; + int levels= get_render_subsurf_level(&smd->modifier.scene->r, smd->levels); CCGSubSurf *ss; /* It is quite possible there is a much better place to do this. It @@ -2549,7 +2552,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } if(useIncremental && isFinalCalc) { - smd->mCache = ss = _getSubSurf(smd->mCache, smd->levels, + smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging, 0, useSimple); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); @@ -2563,7 +2566,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( smd->mCache = NULL; } - ss = _getSubSurf(NULL, smd->levels, 0, 1, useSimple); + ss = _getSubSurf(NULL, levels, 0, 1, useSimple); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 34e8f5c8e13..517a1e92f93 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -661,7 +661,7 @@ void uiTemplateAnyID(uiLayout *layout, struct bContext *C, struct PointerRNA *pt char *proptypename, char *text); void uiTemplatePathBuilder(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *root_ptr, char *text); -uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr, int compact); +uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, int compact); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot); void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index dcc5db81335..f9c27c8572f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -614,9 +614,10 @@ void uiTemplatePathBuilder(uiLayout *layout, bContext *C, PointerRNA *ptr, char static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v) { + Scene *scene = CTX_data_scene(C); Object *ob = ob_v; ModifierData *md= md_v; - int i, cageIndex = modifiers_getCageIndex(ob, NULL, 0); + int i, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 0); /* undo button operation */ md->mode ^= eModifierMode_OnCage; @@ -664,7 +665,7 @@ static int modifier_can_delete(ModifierData *md) return 1; } -static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex, int compact) +static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex, int compact) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); PointerRNA ptr; @@ -758,7 +759,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i if (mti->flags & eModifierTypeFlag_SupportsEditmode) uiItemR(row, "", 0, &ptr, "editmode", 0); } - if ((ob->type==OB_MESH) && modifier_couldBeCage(md) && (index <= lastCageIndex)) + if ((ob->type==OB_MESH) && modifier_couldBeCage(scene, md) && (index <= lastCageIndex)) { /* -- convert to rna ? */ but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, 16, 20, &md->mode, 0.0, 0.0, 0.0, 0.0, "Apply modifier to editing cage during Editmode"); @@ -830,8 +831,9 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i return result; } -uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr, int compact) +uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr, int compact) { + Scene *scene = CTX_data_scene(C); Object *ob; ModifierData *md, *vmd; int i, lastCageIndex, cageIndex; @@ -853,14 +855,14 @@ uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr, int compact) uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); /* find modifier and draw it */ - cageIndex = modifiers_getCageIndex(ob, &lastCageIndex, 0); + cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0); // XXX virtual modifiers are not accesible for python vmd = modifiers_getVirtualModifierList(ob); for(i=0; vmd; i++, vmd=vmd->next) { if(md == vmd) - return draw_modifier(layout, ob, md, i, cageIndex, lastCageIndex, compact); + return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex, compact); else if(vmd->mode & eModifierMode_Virtual) i--; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 6671fec783e..16c7bffd938 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1460,12 +1460,12 @@ static void sculpt_update_tex(Sculpt *sd, SculptSession *ss) } /* Checks whether full update mode (slower) needs to be used to work with modifiers */ -char sculpt_modifiers_active(Object *ob) +static int sculpt_modifiers_active(Scene *scene, Object *ob) { ModifierData *md; for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) { - if(modifier_isEnabled(md, eModifierMode_Realtime)) + if(modifier_isEnabled(scene, md, eModifierMode_Realtime)) if(!ELEM(md->type, eModifierType_Multires, eModifierType_ShapeKey)) return 1; } @@ -1801,7 +1801,9 @@ static void sculpt_update_cache_variants(Sculpt *sd, SculptSession *ss, struct P static void sculpt_stroke_modifiers_check(bContext *C, SculptSession *ss) { - if(sculpt_modifiers_active(ss->ob)) { + Scene *scene= CTX_data_scene(C); + + if(sculpt_modifiers_active(scene, ss->ob)) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = paint_brush(&sd->paint); @@ -1979,6 +1981,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) static void sculpt_flush_update(bContext *C) { + Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); @@ -1988,7 +1991,7 @@ static void sculpt_flush_update(bContext *C) if(mmd) multires_mark_as_modified(ob); - if(sculpt_modifiers_active(ob)) { + if(sculpt_modifiers_active(scene, ob)) { DAG_id_flush_update(&ob->id, OB_RECALC_DATA); ED_region_tag_redraw(ar); } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 0e1c0510902..0fd2eee60bd 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -54,7 +54,6 @@ struct MultiresModifierData *sculpt_multires_active(struct Object *ob); struct Brush *sculptmode_brush(void); //void do_symmetrical_brush_actions(struct Sculpt *sd, struct wmOperator *wm, struct BrushAction *a, short *, short *); -char sculpt_modifiers_active(struct Object *ob); void sculpt(Sculpt *sd); int sculpt_poll(struct bContext *C); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 811ebb13592..378ee85757f 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2216,11 +2216,11 @@ static void createTransEditVerts(bContext *C, TransInfo *t) /* detect CrazySpace [tm] */ if(propmode==0) { - if(modifiers_getCageIndex(t->obedit, NULL, 1)>=0) { + if(modifiers_getCageIndex(t->scene, t->obedit, NULL, 1)>=0) { if(modifiers_isCorrectableDeformed(t->scene, t->obedit)) { /* check if we can use deform matrices for modifier from the start up to stack, they are more accurate than quats */ - totleft= editmesh_get_first_deform_matrices(t->obedit, em, &defmats, &defcos); + totleft= editmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos); /* if we still have more modifiers, also do crazyspace correction with quats, relative to the coordinates after diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index a4fdf60dbb3..9e6f20cf4e6 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -540,14 +540,12 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna) prop= RNA_def_property(srna, "levels", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "levels"); - RNA_def_property_range(prop, 0, INT_MAX); RNA_def_property_ui_range(prop, 0, 6, 1, 0); RNA_def_property_ui_text(prop, "Levels", "Number of subdivisions to perform."); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "render_levels", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "renderLevels"); - RNA_def_property_range(prop, 0, INT_MAX); RNA_def_property_ui_range(prop, 0, 6, 1, 0); RNA_def_property_ui_text(prop, "Render Levels", "Number of subdivisions to perform when rendering."); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 8ae96b473f0..4c5fa1bea8c 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -29,6 +29,8 @@ #include "rna_internal.h" +#include "DNA_group_types.h" +#include "DNA_modifier_types.h" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" @@ -628,6 +630,33 @@ static void rna_Scene_editmesh_select_mode_update(Main *bmain, Scene *scene, Poi WM_main_add_notifier(NC_SCENE|ND_TOOLSETTINGS, NULL); } +static void object_simplify_update(Object *ob) +{ + ModifierData *md; + + for(md=ob->modifiers.first; md; md=md->next) + if(ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) + ob->recalc |= OB_RECALC_DATA; + + if(ob->dup_group) { + GroupObject *gob; + + for(gob=ob->dup_group->gobject.first; gob; gob=gob->next) + object_simplify_update(gob->ob); + } +} + +static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Base *base; + + for(base= scene->base.first; base; base= base->next) + object_simplify_update(base->object); + + DAG_ids_flush_update(0); + WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); +} + #else static void rna_def_transform_orientation(BlenderRNA *brna) @@ -2362,11 +2391,38 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Use Game Engine", "Current rendering engine is a game engine."); + /* simplify */ + prop= RNA_def_property(srna, "use_simplify", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SIMPLIFY); + RNA_def_property_ui_text(prop, "Use Simplify", "Enable simplification of scene for quicker preview renders."); + RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); + + prop= RNA_def_property(srna, "simplify_subdivision", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "simplify_subsurf"); + RNA_def_property_ui_range(prop, 0, 6, 1, 0); + RNA_def_property_ui_text(prop, "Simplify Subdivision", "Global maximum subdivision level."); + RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); + + prop= RNA_def_property(srna, "simplify_child_particles", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "simplify_particles"); + RNA_def_property_ui_text(prop, "Simplify Child Particles", "Global child particles percentage."); + RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); + + prop= RNA_def_property(srna, "simplify_shadow_samples", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "simplify_shadowsamples"); + RNA_def_property_ui_range(prop, 1, 16, 1, 0); + RNA_def_property_ui_text(prop, "Simplify Shadow Samples", "Global maximum shadow samples."); + RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); + + prop= RNA_def_property(srna, "simplify_ao_sss", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "simplify_aosss"); + RNA_def_property_ui_text(prop, "Simplify AO and SSS", "Global approximate AA and SSS quality factor."); + RNA_def_property_update(prop, 0, "rna_Scene_simplify_update"); + /* Scene API */ RNA_api_scene_render(srna); } - /* scene.objects */ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) { diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index c344173afb3..cd7051fc171 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -299,6 +299,7 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_string(func, "text", "", 0, "", "Custom label to display in UI."); func= RNA_def_function(srna, "template_modifier", "uiTemplateModifier"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm= RNA_def_pointer(func, "data", "Modifier", "", "Modifier data."); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); |