Cleanup: remove G.main from BKE modifier.
This commit is contained in:
@@ -326,14 +326,14 @@ static bool ObtainCacheParticleVcol(Mesh *mesh,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void set_resolution(BL::Object *b_ob, BL::Scene *scene, bool render)
|
||||
static void set_resolution(BL::BlendData *b_data, BL::Object *b_ob, BL::Scene *scene, bool render)
|
||||
{
|
||||
BL::Object::modifiers_iterator b_mod;
|
||||
for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
|
||||
if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && ((b_mod->show_viewport()) || (b_mod->show_render()))) {
|
||||
BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
|
||||
BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
|
||||
b_psys.set_resolution(*scene, *b_ob, (render)? 2: 1);
|
||||
b_psys.set_resolution(*b_data, *scene, *b_ob, (render)? 2: 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -920,7 +920,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
|
||||
ParticleCurveData CData;
|
||||
|
||||
if(!preview)
|
||||
set_resolution(&b_ob, &b_scene, true);
|
||||
set_resolution(&b_data, &b_ob, &b_scene, true);
|
||||
|
||||
ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, !preview);
|
||||
|
||||
@@ -1065,7 +1065,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
|
||||
}
|
||||
|
||||
if(!preview)
|
||||
set_resolution(&b_ob, &b_scene, false);
|
||||
set_resolution(&b_data, &b_ob, &b_scene, false);
|
||||
|
||||
mesh->compute_bounds();
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ void test_object_modifiers(struct Object *ob);
|
||||
void modifier_mdef_compact_influences(struct ModifierData *md);
|
||||
|
||||
void modifier_path_init(char *path, int path_maxlen, const char *name);
|
||||
const char *modifier_path_relbase(struct Object *ob);
|
||||
const char *modifier_path_relbase(struct Main *bmain, struct Object *ob);
|
||||
|
||||
|
||||
/* wrappers for modifier callbacks */
|
||||
|
||||
@@ -389,7 +389,7 @@ void psys_check_boid_data(struct ParticleSystem *psys);
|
||||
|
||||
void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra);
|
||||
|
||||
void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
|
||||
void particle_system_update(struct Main *bmain, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
|
||||
|
||||
/* Callback format for performing operations on ID-pointers for particle systems */
|
||||
typedef void (*ParticleSystemIDFunc)(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, int cb_flag);
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_library_query.h"
|
||||
@@ -65,7 +66,6 @@
|
||||
#include "BKE_DerivedMesh.h"
|
||||
|
||||
/* may move these, only for modifier_path_relbase */
|
||||
#include "BKE_global.h" /* ugh, G.main->name only */
|
||||
#include "BKE_main.h"
|
||||
/* end */
|
||||
|
||||
@@ -765,10 +765,10 @@ void test_object_modifiers(Object *ob)
|
||||
* - else if the file has been saved return the blend file path.
|
||||
* - else if the file isn't saved and the ID isn't from a library, return the temp dir.
|
||||
*/
|
||||
const char *modifier_path_relbase(Object *ob)
|
||||
const char *modifier_path_relbase(Main *bmain, Object *ob)
|
||||
{
|
||||
if (G.relbase_valid || ID_IS_LINKED(ob)) {
|
||||
return ID_BLEND_PATH(G.main, &ob->id);
|
||||
return ID_BLEND_PATH(bmain, &ob->id);
|
||||
}
|
||||
else {
|
||||
/* last resort, better then using "" which resolves to the current
|
||||
|
||||
@@ -260,7 +260,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
|
||||
ob->transflag |= OB_DUPLIPARTS;
|
||||
}
|
||||
|
||||
particle_system_update(scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER));
|
||||
particle_system_update(G.main, scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER));
|
||||
psys = psys->next;
|
||||
}
|
||||
else if (psys->flag & PSYS_DELETE) {
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_effect.h"
|
||||
#include "BKE_library_query.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_particle.h"
|
||||
|
||||
#include "BKE_DerivedMesh.h"
|
||||
@@ -3796,7 +3797,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
|
||||
}
|
||||
}
|
||||
|
||||
static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra), const bool use_render_params)
|
||||
static void particles_fluid_step(Main *bmain, ParticleSimulationData *sim, int UNUSED(cfra), const bool use_render_params)
|
||||
{
|
||||
ParticleSystem *psys = sim->psys;
|
||||
if (psys->particles) {
|
||||
@@ -3827,7 +3828,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra),
|
||||
// ok, start loading
|
||||
BLI_join_dirfile(filename, sizeof(filename), fss->surfdataPath, OB_FLUIDSIM_SURF_PARTICLES_FNAME);
|
||||
|
||||
BLI_path_abs(filename, modifier_path_relbase(sim->ob));
|
||||
BLI_path_abs(filename, modifier_path_relbase(bmain, sim->ob));
|
||||
|
||||
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
|
||||
|
||||
@@ -4205,7 +4206,7 @@ static int hair_needs_recalc(ParticleSystem *psys)
|
||||
|
||||
/* main particle update call, checks that things are ok on the large scale and
|
||||
* then advances in to actual particle calculations depending on particle type */
|
||||
void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
|
||||
void particle_system_update(Main *bmain, Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
|
||||
{
|
||||
ParticleSimulationData sim= {0};
|
||||
ParticleSettings *part = psys->part;
|
||||
@@ -4301,7 +4302,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys, cons
|
||||
}
|
||||
case PART_FLUID:
|
||||
{
|
||||
particles_fluid_step(&sim, (int)cfra, use_render_params);
|
||||
particles_fluid_step(bmain, &sim, (int)cfra, use_render_params);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -1293,6 +1293,7 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot)
|
||||
|
||||
static int multires_external_save_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Object *ob = ED_object_active_context(C);
|
||||
Mesh *me = (ob) ? ob->data : op->customdata;
|
||||
char path[FILE_MAX];
|
||||
@@ -1307,7 +1308,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
|
||||
RNA_string_get(op->ptr, "filepath", path);
|
||||
|
||||
if (relative)
|
||||
BLI_path_rel(path, G.main->name);
|
||||
BLI_path_rel(path, bmain->name);
|
||||
|
||||
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
|
||||
CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0);
|
||||
@@ -2129,6 +2130,7 @@ static void oceanbake_endjob(void *customdata)
|
||||
|
||||
static int ocean_bake_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Object *ob = ED_object_active_context(C);
|
||||
OceanModifierData *omd = (OceanModifierData *)edit_modifier_property_get(op, ob, eModifierType_Ocean);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -2150,7 +2152,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(ob),
|
||||
och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(bmain, ob),
|
||||
omd->bakestart, omd->bakeend, omd->wave_scale,
|
||||
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
|
||||
|
||||
@@ -2164,7 +2166,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
|
||||
*
|
||||
* XXX: This can't be used due to an anim sys optimization that ignores recalc object animation,
|
||||
* leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ )
|
||||
* --> BKE_animsys_evaluate_all_animation(G.main, eval_time);
|
||||
* --> BKE_animsys_evaluate_all_animation(bmain, eval_time);
|
||||
* This doesn't work with drivers:
|
||||
* --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL);
|
||||
*/
|
||||
@@ -2173,7 +2175,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
|
||||
* this part of the process before a threaded job is created */
|
||||
|
||||
//scene->r.cfra = f;
|
||||
//ED_update_for_newframe(CTX_data_main(C), scene, 1);
|
||||
//ED_update_for_newframe(bmain, scene, 1);
|
||||
|
||||
/* ok, this doesn't work with drivers, but is way faster.
|
||||
* let's use this for now and hope nobody wants to drive the time value... */
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_fluidsim.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_report.h"
|
||||
@@ -632,13 +633,13 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom
|
||||
#define FLUID_SUFFIX_SURFACE "fluidsurface"
|
||||
|
||||
static bool fluid_init_filepaths(
|
||||
ReportList *reports, FluidsimSettings *domainSettings, Object *fsDomain,
|
||||
Main *bmain, ReportList *reports, FluidsimSettings *domainSettings, Object *fsDomain,
|
||||
char *targetDir, char *targetFile)
|
||||
{
|
||||
const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP;
|
||||
|
||||
/* prepare names... */
|
||||
const char *relbase = modifier_path_relbase(fsDomain);
|
||||
const char *relbase = modifier_path_relbase(bmain, fsDomain);
|
||||
|
||||
/* We do not accept empty paths, they can end in random places silently, see T51176. */
|
||||
if (domainSettings->surfdataPath[0] == '\0') {
|
||||
@@ -835,6 +836,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *r
|
||||
|
||||
static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, short do_job)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int i;
|
||||
FluidsimSettings *domainSettings;
|
||||
@@ -842,7 +844,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
|
||||
char debugStrBuffer[256];
|
||||
|
||||
int gridlevels = 0;
|
||||
const char *relbase= modifier_path_relbase(fsDomain);
|
||||
const char *relbase= modifier_path_relbase(bmain, fsDomain);
|
||||
const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp
|
||||
const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP;
|
||||
const char *suffixSurface = FLUID_SUFFIX_SURFACE;
|
||||
@@ -934,7 +936,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
|
||||
|
||||
|
||||
/* ******** prepare output file paths ******** */
|
||||
if (!fluid_init_filepaths(reports, domainSettings, fsDomain, targetDir, targetFile)) {
|
||||
if (!fluid_init_filepaths(bmain, reports, domainSettings, fsDomain, targetDir, targetFile)) {
|
||||
fluidbake_free_data(channels, fobjects, fsset, fb);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -86,14 +86,14 @@ static void rna_fluid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
|
||||
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
|
||||
}
|
||||
|
||||
static int fluidsim_find_lastframe(Object *ob, FluidsimSettings *fss)
|
||||
static int fluidsim_find_lastframe(Main *bmain, Object *ob, FluidsimSettings *fss)
|
||||
{
|
||||
char targetFileTest[FILE_MAX];
|
||||
char targetFile[FILE_MAX];
|
||||
int curFrame = 1;
|
||||
|
||||
BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME);
|
||||
BLI_path_abs(targetFile, modifier_path_relbase(ob));
|
||||
BLI_path_abs(targetFile, modifier_path_relbase(bmain, ob));
|
||||
|
||||
do {
|
||||
BLI_strncpy(targetFileTest, targetFile, sizeof(targetFileTest));
|
||||
@@ -109,7 +109,7 @@ static void rna_fluid_find_enframe(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
|
||||
|
||||
if (fluidmd->fss->flag & OB_FLUIDSIM_REVERSE) {
|
||||
fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(ob, fluidmd->fss);
|
||||
fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(bmain, ob, fluidmd->fss);
|
||||
}
|
||||
else {
|
||||
fluidmd->fss->lastgoodframe = -1;
|
||||
|
||||
@@ -612,7 +612,8 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Scene *scene, Object *object, int resolution)
|
||||
static void rna_ParticleSystem_set_resolution(
|
||||
ParticleSystem *particlesystem, Main *bmain, Scene *scene, Object *object, int resolution)
|
||||
{
|
||||
if (resolution == eModifierMode_Render) {
|
||||
ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem);
|
||||
@@ -622,7 +623,7 @@ static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Sc
|
||||
|
||||
psys_render_set(object, particlesystem, mat, mat, 1, 1, 0.f);
|
||||
psmd->flag &= ~eParticleSystemFlag_psys_updated;
|
||||
particle_system_update(scene, object, particlesystem, true);
|
||||
particle_system_update(bmain, scene, object, particlesystem, true);
|
||||
}
|
||||
else {
|
||||
ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem);
|
||||
@@ -632,7 +633,7 @@ static void rna_ParticleSystem_set_resolution(ParticleSystem *particlesystem, Sc
|
||||
}
|
||||
|
||||
psmd->flag &= ~eParticleSystemFlag_psys_updated;
|
||||
particle_system_update(scene, object, particlesystem, false);
|
||||
particle_system_update(bmain, scene, object, particlesystem, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3604,6 +3605,7 @@ static void rna_def_particle_system(BlenderRNA *brna)
|
||||
/* set viewport or render resolution */
|
||||
func = RNA_def_function(srna, "set_resolution", "rna_ParticleSystem_set_resolution");
|
||||
RNA_def_function_ui_description(func, "Set the resolution to use for the number of particles");
|
||||
RNA_def_function_flag(func, FUNC_USE_MAIN);
|
||||
RNA_def_pointer(func, "scene", "Scene", "", "Scene");
|
||||
RNA_def_pointer(func, "object", "Object", "", "Object");
|
||||
RNA_def_enum(func, "resolution", resolution_items, 0, "", "Resolution settings to apply");
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include "BKE_fluidsim.h" /* ensure definitions here match */
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_main.h"
|
||||
#ifdef WITH_MOD_FLUID
|
||||
# include "BKE_global.h"
|
||||
#endif
|
||||
@@ -427,7 +428,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
|
||||
}
|
||||
|
||||
static DerivedMesh *fluidsim_read_cache(
|
||||
Object *ob, DerivedMesh *orgdm,
|
||||
Main *bmain, Object *ob, DerivedMesh *orgdm,
|
||||
FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
|
||||
{
|
||||
int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
|
||||
@@ -462,7 +463,7 @@ static DerivedMesh *fluidsim_read_cache(
|
||||
/* offset baked frame */
|
||||
curFrame += fss->frameOffset;
|
||||
|
||||
BLI_path_abs(targetFile, modifier_path_relbase(ob));
|
||||
BLI_path_abs(targetFile, modifier_path_relbase(bmain, ob));
|
||||
BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no
|
||||
|
||||
/* assign material + flags to new dm
|
||||
@@ -545,7 +546,7 @@ DerivedMesh *fluidsimModifier_do(
|
||||
|
||||
/* try to read from cache */
|
||||
/* if the frame is there, fine, otherwise don't do anything */
|
||||
if ((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
|
||||
if ((result = fluidsim_read_cache(G.main, ob, dm, fluidmd, framenr, useRenderParams)))
|
||||
return result;
|
||||
|
||||
return dm;
|
||||
|
||||
@@ -41,15 +41,17 @@
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_ocean.h"
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
|
||||
#ifdef WITH_OCEANSIM
|
||||
static void init_cache_data(Object *ob, struct OceanModifierData *omd)
|
||||
static void init_cache_data(Main *bmain, Object *ob, struct OceanModifierData *omd)
|
||||
{
|
||||
const char *relbase = modifier_path_relbase(ob);
|
||||
const char *relbase = modifier_path_relbase(bmain, ob);
|
||||
|
||||
omd->oceancache = BKE_ocean_init_cache(omd->cachepath, relbase,
|
||||
omd->bakestart, omd->bakeend, omd->wave_scale,
|
||||
@@ -447,7 +449,7 @@ static DerivedMesh *doOcean(
|
||||
/* do ocean simulation */
|
||||
if (omd->cached == true) {
|
||||
if (!omd->oceancache) {
|
||||
init_cache_data(ob, omd);
|
||||
init_cache_data(G.main, ob, omd);
|
||||
}
|
||||
BKE_ocean_simulate_cache(omd->oceancache, md->scene->r.cfra);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_particle.h"
|
||||
|
||||
@@ -189,7 +190,7 @@ static void deformVerts(
|
||||
|
||||
if (!(ob->transflag & OB_NO_PSYS_UPDATE)) {
|
||||
psmd->flag &= ~eParticleSystemFlag_psys_updated;
|
||||
particle_system_update(md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
|
||||
particle_system_update(G.main, md->scene, ob, psys, (flag & MOD_APPLY_RENDER) != 0);
|
||||
psmd->flag |= eParticleSystemFlag_psys_updated;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user