Pass EvaluationContext argument everywhere

Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.
This commit is contained in:
2017-07-21 11:53:13 +02:00
parent 9edb7e49d7
commit 1c4c288727
281 changed files with 2302 additions and 1648 deletions

View File

@@ -325,14 +325,14 @@ static bool ObtainCacheParticleVcol(Mesh *mesh,
return true; return true;
} }
static void set_resolution(BL::Object *b_ob, BL::Scene *scene, bool render) static void set_resolution(BL::Object *b_ob, BL::Scene *scene, BL::SceneLayer *sl, bool render)
{ {
BL::Object::modifiers_iterator b_mod; BL::Object::modifiers_iterator b_mod;
for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++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()))) { 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::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().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(*scene, *sl, *b_ob, (render)? 2: 1);
} }
} }
} }
@@ -912,7 +912,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
ParticleCurveData CData; ParticleCurveData CData;
if(!preview) if(!preview)
set_resolution(&b_ob, &b_scene, true); set_resolution(&b_ob, &b_scene, &b_scene_layer, true);
ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, !preview); ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, !preview);
@@ -1057,7 +1057,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
} }
if(!preview) if(!preview)
set_resolution(&b_ob, &b_scene, false); set_resolution(&b_ob, &b_scene, &b_scene_layer, false);
mesh->compute_bounds(); mesh->compute_bounds();
} }

View File

@@ -1053,6 +1053,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object& b_ob,
BL::Mesh b_mesh = object_to_mesh(b_data, BL::Mesh b_mesh = object_to_mesh(b_data,
b_ob, b_ob,
b_scene, b_scene,
b_scene_layer,
true, true,
!preview, !preview,
need_undeformed, need_undeformed,
@@ -1184,6 +1185,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
b_mesh = object_to_mesh(b_data, b_mesh = object_to_mesh(b_data,
b_ob, b_ob,
b_scene, b_scene,
b_scene_layer,
true, true,
!preview, !preview,
false, false,

View File

@@ -60,6 +60,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
b_render(b_engine.render()), b_render(b_engine.render()),
b_depsgraph(b_depsgraph), b_depsgraph(b_depsgraph),
b_scene(b_scene), b_scene(b_scene),
b_scene_layer(b_engine.scene_layer()),
b_v3d(PointerRNA_NULL), b_v3d(PointerRNA_NULL),
b_rv3d(PointerRNA_NULL), b_rv3d(PointerRNA_NULL),
python_thread_state(NULL) python_thread_state(NULL)
@@ -89,6 +90,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine,
b_render(b_scene.render()), b_render(b_scene.render()),
b_depsgraph(b_depsgraph), b_depsgraph(b_depsgraph),
b_scene(b_scene), b_scene(b_scene),
b_scene_layer(b_engine.scene_layer()),
b_v3d(b_v3d), b_v3d(b_v3d),
b_rv3d(b_rv3d), b_rv3d(b_rv3d),
width(width), width(width),
@@ -1301,7 +1303,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
BL::ShaderNodeTexPointDensity b_point_density_node(b_node); BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
int length; int length;
int settings = background ? 1 : 0; /* 1 - render settings, 0 - vewport settings. */ int settings = background ? 1 : 0; /* 1 - render settings, 0 - vewport settings. */
b_point_density_node.calc_point_density(b_scene, settings, &length, &pixels); b_point_density_node.calc_point_density(b_scene, b_scene_layer, settings, &length, &pixels);
} }
} }

View File

@@ -108,6 +108,7 @@ public:
BL::RenderSettings b_render; BL::RenderSettings b_render;
BL::Depsgraph b_depsgraph; BL::Depsgraph b_depsgraph;
BL::Scene b_scene; BL::Scene b_scene;
BL::SceneLayer b_scene_layer;
BL::SpaceView3D b_v3d; BL::SpaceView3D b_v3d;
BL::RegionView3D b_rv3d; BL::RegionView3D b_rv3d;
string b_rlay_name; string b_rlay_name;

View File

@@ -243,6 +243,7 @@ static ShaderNode *add_node(Scene *scene,
BL::RenderEngine& b_engine, BL::RenderEngine& b_engine,
BL::BlendData& b_data, BL::BlendData& b_data,
BL::Scene& b_scene, BL::Scene& b_scene,
BL::SceneLayer b_scene_layer,
const bool background, const bool background,
ShaderGraph *graph, ShaderGraph *graph,
BL::ShaderNodeTree& b_ntree, BL::ShaderNodeTree& b_ntree,
@@ -839,7 +840,7 @@ static ShaderNode *add_node(Scene *scene,
/* TODO(sergey): Use more proper update flag. */ /* TODO(sergey): Use more proper update flag. */
if(true) { if(true) {
b_point_density_node.cache_point_density(b_scene, settings); b_point_density_node.cache_point_density(b_scene, b_scene_layer, settings);
scene->image_manager->tag_reload_image( scene->image_manager->tag_reload_image(
point_density->filename.string(), point_density->filename.string(),
point_density->builtin_data, point_density->builtin_data,
@@ -857,7 +858,7 @@ static ShaderNode *add_node(Scene *scene,
BL::Object b_ob(b_point_density_node.object()); BL::Object b_ob(b_point_density_node.object());
if(b_ob) { if(b_ob) {
float3 loc, size; float3 loc, size;
point_density_texture_space(b_scene, point_density_texture_space(b_scene, b_scene_layer,
b_point_density_node, b_point_density_node,
settings, settings,
loc, loc,
@@ -954,6 +955,7 @@ static void add_nodes(Scene *scene,
BL::RenderEngine& b_engine, BL::RenderEngine& b_engine,
BL::BlendData& b_data, BL::BlendData& b_data,
BL::Scene& b_scene, BL::Scene& b_scene,
BL::SceneLayer& b_scene_layer,
const bool background, const bool background,
ShaderGraph *graph, ShaderGraph *graph,
BL::ShaderNodeTree& b_ntree, BL::ShaderNodeTree& b_ntree,
@@ -1044,6 +1046,7 @@ static void add_nodes(Scene *scene,
b_engine, b_engine,
b_data, b_data,
b_scene, b_scene,
b_scene_layer,
background, background,
graph, graph,
b_group_ntree, b_group_ntree,
@@ -1093,6 +1096,7 @@ static void add_nodes(Scene *scene,
b_engine, b_engine,
b_data, b_data,
b_scene, b_scene,
b_scene_layer,
background, background,
graph, graph,
b_ntree, b_ntree,
@@ -1156,6 +1160,7 @@ static void add_nodes(Scene *scene,
BL::RenderEngine& b_engine, BL::RenderEngine& b_engine,
BL::BlendData& b_data, BL::BlendData& b_data,
BL::Scene& b_scene, BL::Scene& b_scene,
BL::SceneLayer& b_scene_layer,
const bool background, const bool background,
ShaderGraph *graph, ShaderGraph *graph,
BL::ShaderNodeTree& b_ntree) BL::ShaderNodeTree& b_ntree)
@@ -1165,6 +1170,7 @@ static void add_nodes(Scene *scene,
b_engine, b_engine,
b_data, b_data,
b_scene, b_scene,
b_scene_layer,
background, background,
graph, graph,
b_ntree, b_ntree,
@@ -1203,7 +1209,7 @@ void BlenderSync::sync_materials(bool update_all)
if(b_mat->use_nodes() && b_mat->node_tree()) { if(b_mat->use_nodes() && b_mat->node_tree()) {
BL::ShaderNodeTree b_ntree(b_mat->node_tree()); BL::ShaderNodeTree b_ntree(b_mat->node_tree());
add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree); add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
} }
else { else {
DiffuseBsdfNode *diffuse = new DiffuseBsdfNode(); DiffuseBsdfNode *diffuse = new DiffuseBsdfNode();
@@ -1274,7 +1280,7 @@ void BlenderSync::sync_world(bool update_all)
if(b_world && b_world.use_nodes() && b_world.node_tree()) { if(b_world && b_world.use_nodes() && b_world.node_tree()) {
BL::ShaderNodeTree b_ntree(b_world.node_tree()); BL::ShaderNodeTree b_ntree(b_world.node_tree());
add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree); add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
/* volume */ /* volume */
PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles"); PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
@@ -1369,7 +1375,7 @@ void BlenderSync::sync_lamps(bool update_all)
BL::ShaderNodeTree b_ntree(b_lamp->node_tree()); BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
add_nodes(scene, b_engine, b_data, b_scene, !preview, graph, b_ntree); add_nodes(scene, b_engine, b_data, b_scene, b_scene_layer, !preview, graph, b_ntree);
} }
else { else {
float strength = 1.0f; float strength = 1.0f;

View File

@@ -54,6 +54,7 @@ BlenderSync::BlenderSync(BL::RenderEngine& b_engine,
b_data(b_data), b_data(b_data),
b_depsgraph(b_depsgraph), b_depsgraph(b_depsgraph),
b_scene(b_scene), b_scene(b_scene),
b_scene_layer(b_engine.scene_layer()),
shader_map(&scene->shaders), shader_map(&scene->shaders),
object_map(&scene->objects), object_map(&scene->objects),
mesh_map(&scene->meshes), mesh_map(&scene->meshes),

View File

@@ -43,6 +43,7 @@ class Mesh;
class Object; class Object;
class ParticleSystem; class ParticleSystem;
class Scene; class Scene;
class SceneLayer;
class Shader; class Shader;
class ShaderGraph; class ShaderGraph;
class ShaderNode; class ShaderNode;
@@ -165,6 +166,7 @@ private:
BL::BlendData b_data; BL::BlendData b_data;
BL::Depsgraph b_depsgraph; BL::Depsgraph b_depsgraph;
BL::Scene b_scene; BL::Scene b_scene;
BL::SceneLayer b_scene_layer;
id_map<void*, Shader> shader_map; id_map<void*, Shader> shader_map;
id_map<ObjectKey, Object> object_map; id_map<ObjectKey, Object> object_map;

View File

@@ -34,7 +34,7 @@ void density_texture_space_invert(float3& loc,
} /* namespace */ } /* namespace */
void point_density_texture_space(BL::Scene& b_scene, void point_density_texture_space(BL::Scene& b_scene, BL::SceneLayer& b_scene_layer,
BL::ShaderNodeTexPointDensity& b_point_density_node, BL::ShaderNodeTexPointDensity& b_point_density_node,
int settings, int settings,
float3& loc, float3& loc,
@@ -48,6 +48,7 @@ void point_density_texture_space(BL::Scene& b_scene,
} }
float3 min, max; float3 min, max;
b_point_density_node.calc_point_density_minmax(b_scene, b_point_density_node.calc_point_density_minmax(b_scene,
b_scene_layer,
settings, settings,
&min[0], &min[0],
&max[0]); &max[0]);

View File

@@ -22,7 +22,7 @@
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
void point_density_texture_space(BL::Scene& b_scene, void point_density_texture_space(BL::Scene& b_scene, BL::SceneLayer& b_scene_layer,
BL::ShaderNodeTexPointDensity& b_point_density_node, BL::ShaderNodeTexPointDensity& b_point_density_node,
const int settings, const int settings,
float3& loc, float3& loc,

View File

@@ -46,6 +46,7 @@ void python_thread_state_restore(void **python_thread_state);
static inline BL::Mesh object_to_mesh(BL::BlendData& data, static inline BL::Mesh object_to_mesh(BL::BlendData& data,
BL::Object& object, BL::Object& object,
BL::Scene& scene, BL::Scene& scene,
BL::SceneLayer scene_layer,
bool apply_modifiers, bool apply_modifiers,
bool render, bool render,
bool calc_undeformed, bool calc_undeformed,
@@ -64,7 +65,7 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data,
subsurf_mod.show_viewport(false); subsurf_mod.show_viewport(false);
} }
BL::Mesh me = data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1, false, calc_undeformed); BL::Mesh me = data.meshes.new_from_object(scene, scene_layer, object, apply_modifiers, (render)? 2: 1, false, calc_undeformed);
if(subdivision_type != Mesh::SUBDIVISION_NONE) { if(subdivision_type != Mesh::SUBDIVISION_NONE) {
BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1]; BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1];

View File

@@ -21,7 +21,7 @@ public:
int addFrame(const std::string& name, const Frame& frame); int addFrame(const std::string& name, const Frame& frame);
virtual void updateCoordinates(const Timestamp& timestamp) {}; virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
virtual int addEndEffector(const std::string& name); virtual int addEndEffector(const std::string& name);
virtual bool finalize(); virtual bool finalize();
virtual const Frame& getPose(const unsigned int frameIndex); virtual const Frame& getPose(const unsigned int frameIndex);

View File

@@ -90,7 +90,7 @@ bool MovingFrame::setCallback(MovingFrameCallback _function, void* _param)
return true; return true;
} }
void MovingFrame::updateCoordinates(const Timestamp& timestamp) void MovingFrame::updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp)
{ {
// don't compute the velocity during substepping, it is assumed constant. // don't compute the velocity during substepping, it is assumed constant.
if (!timestamp.substep) { if (!timestamp.substep) {
@@ -98,7 +98,7 @@ void MovingFrame::updateCoordinates(const Timestamp& timestamp)
if (!timestamp.reiterate) { if (!timestamp.reiterate) {
cacheAvail = popInternalFrame(timestamp.cacheTimestamp); cacheAvail = popInternalFrame(timestamp.cacheTimestamp);
if (m_function) if (m_function)
(*m_function)(timestamp, m_internalPose, m_nextPose, m_param); (*m_function)(eval_ctx, timestamp, m_internalPose, m_nextPose, m_param);
} }
// only compute velocity if we have a previous pose // only compute velocity if we have a previous pose
if (cacheAvail && timestamp.interpolate) { if (cacheAvail && timestamp.interpolate) {

View File

@@ -11,10 +11,11 @@
#include "UncontrolledObject.hpp" #include "UncontrolledObject.hpp"
#include <vector> #include <vector>
struct EvaluationContext;
namespace iTaSC{ namespace iTaSC{
typedef bool (*MovingFrameCallback)(const Timestamp& timestamp, const Frame& _current, Frame& _next, void *param); typedef bool (*MovingFrameCallback)(struct EvaluationContext *eval_ctx, const Timestamp& timestamp, const Frame& _current, Frame& _next, void *param);
class MovingFrame: public UncontrolledObject { class MovingFrame: public UncontrolledObject {
public: public:
@@ -24,7 +25,7 @@ public:
bool setFrame(const Frame& frame); bool setFrame(const Frame& frame);
bool setCallback(MovingFrameCallback _function, void* _param); bool setCallback(MovingFrameCallback _function, void* _param);
virtual void updateCoordinates(const Timestamp& timestamp); virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp);
virtual void updateKinematics(const Timestamp& timestamp); virtual void updateKinematics(const Timestamp& timestamp);
virtual void pushCache(const Timestamp& timestamp); virtual void pushCache(const Timestamp& timestamp);
virtual void initCache(Cache *_cache); virtual void initCache(Cache *_cache);

View File

@@ -257,7 +257,7 @@ bool Scene::getConstraintPose(ConstraintSet* constraint, void *_param, KDL::Fram
return true; return true;
} }
bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate) bool Scene::update(struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep, bool reiterate, bool cache, bool interpolate)
{ {
// we must have valid timestep and timestamp // we must have valid timestep and timestamp
if (timestamp < KDL::epsilon || timestep < 0.0) if (timestamp < KDL::epsilon || timestep < 0.0)
@@ -316,7 +316,7 @@ bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, b
} }
} }
if (os->object->getType()==Object::UnControlled && ((UncontrolledObject*)os->object)->getNrOfCoordinates() != 0) { if (os->object->getType()==Object::UnControlled && ((UncontrolledObject*)os->object)->getNrOfCoordinates() != 0) {
((UncontrolledObject*)(os->object))->updateCoordinates(ts); ((UncontrolledObject*)(os->object))->updateCoordinates(eval_ctx, ts);
if (!ts.substep) { if (!ts.substep) {
// velocity of uncontrolled object remains constant during substepping // velocity of uncontrolled object remains constant during substepping
project(m_xdot,os->coordinaterange) = ((UncontrolledObject*)(os->object))->getXudot(); project(m_xdot,os->coordinaterange) = ((UncontrolledObject*)(os->object))->getXudot();

View File

@@ -39,7 +39,7 @@ public:
bool addSolver(Solver* _solver); bool addSolver(Solver* _solver);
bool addCache(Cache* _cache); bool addCache(Cache* _cache);
bool initialize(); bool initialize();
bool update(double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true); bool update(struct EvaluationContext *eval_ctx, double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
bool setParam(SceneParam paramId, double value); bool setParam(SceneParam paramId, double value);
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW

View File

@@ -11,6 +11,9 @@
#include "eigen_types.hpp" #include "eigen_types.hpp"
#include "Object.hpp" #include "Object.hpp"
struct EvaluationContext;
namespace iTaSC{ namespace iTaSC{
class UncontrolledObject: public Object { class UncontrolledObject: public Object {
@@ -26,7 +29,7 @@ public:
virtual void initialize(unsigned int _nu, unsigned int _nf); virtual void initialize(unsigned int _nu, unsigned int _nf);
virtual const e_matrix& getJu(unsigned int frameIndex) const; virtual const e_matrix& getJu(unsigned int frameIndex) const;
virtual const e_vector& getXudot() const {return m_xudot;} virtual const e_vector& getXudot() const {return m_xudot;}
virtual void updateCoordinates(const Timestamp& timestamp)=0; virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp)=0;
virtual const unsigned int getNrOfCoordinates(){return m_nu;}; virtual const unsigned int getNrOfCoordinates(){return m_nu;};
virtual const unsigned int getNrOfFrames(){return m_nf;}; virtual const unsigned int getNrOfFrames(){return m_nf;};

View File

@@ -16,7 +16,7 @@ public:
WorldObject(); WorldObject();
virtual ~WorldObject(); virtual ~WorldObject();
virtual void updateCoordinates(const Timestamp& timestamp) {}; virtual void updateCoordinates(struct EvaluationContext *eval_ctx, const Timestamp& timestamp) {};
virtual void updateKinematics(const Timestamp& timestamp) {}; virtual void updateKinematics(const Timestamp& timestamp) {};
virtual void pushCache(const Timestamp& timestamp) {}; virtual void pushCache(const Timestamp& timestamp) {};
virtual void initCache(Cache *_cache) {}; virtual void initCache(Cache *_cache) {};

View File

@@ -49,12 +49,13 @@ using Alembic::AbcGeom::kWrapExisting;
/* ************************************************************************** */ /* ************************************************************************** */
AbcCameraWriter::AbcCameraWriter(Scene *scene, AbcCameraWriter::AbcCameraWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings) ExportSettings &settings)
: AbcObjectWriter(scene, ob, time_sampling, settings, parent) : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{ {
OCamera camera(parent->alembicXform(), m_name, m_time_sampling); OCamera camera(parent->alembicXform(), m_name, m_time_sampling);
m_camera_schema = camera.getSchema(); m_camera_schema = camera.getSchema();

View File

@@ -35,7 +35,8 @@ class AbcCameraWriter : public AbcObjectWriter {
Alembic::AbcGeom::OFloatProperty m_eye_separation; Alembic::AbcGeom::OFloatProperty m_eye_separation;
public: public:
AbcCameraWriter(Scene *scene, AbcCameraWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,

View File

@@ -71,12 +71,13 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */ /* ************************************************************************** */
AbcCurveWriter::AbcCurveWriter(Scene *scene, AbcCurveWriter::AbcCurveWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings) ExportSettings &settings)
: AbcObjectWriter(scene, ob, time_sampling, settings, parent) : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{ {
OCurves curves(parent->alembicXform(), m_name, m_time_sampling); OCurves curves(parent->alembicXform(), m_name, m_time_sampling);
m_schema = curves.getSchema(); m_schema = curves.getSchema();

View File

@@ -36,7 +36,8 @@ class AbcCurveWriter : public AbcObjectWriter {
Alembic::AbcGeom::OCurvesSchema::Sample m_sample; Alembic::AbcGeom::OCurvesSchema::Sample m_sample;
public: public:
AbcCurveWriter(Scene *scene, AbcCurveWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,

View File

@@ -163,11 +163,12 @@ static bool export_object(const ExportSettings * const settings, const Base * co
/* ************************************************************************** */ /* ************************************************************************** */
AbcExporter::AbcExporter(Scene *scene, const char *filename, ExportSettings &settings) AbcExporter::AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings)
: m_settings(settings) : m_settings(settings)
, m_filename(filename) , m_filename(filename)
, m_trans_sampling_index(0) , m_trans_sampling_index(0)
, m_shape_sampling_index(0) , m_shape_sampling_index(0)
, m_eval_ctx(eval_ctx)
, m_scene(scene) , m_scene(scene)
, m_writer(NULL) , m_writer(NULL)
{} {}
@@ -383,7 +384,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
} }
if (object_type_is_exportable(ob)) { if (object_type_is_exportable(ob)) {
createTransformWriter(ob, parent, dupliObParent); createTransformWriter(eval_ctx, ob, parent, dupliObParent);
} }
ListBase *lb = object_duplilist(eval_ctx, m_scene, ob); ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
@@ -415,7 +416,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
free_object_duplilist(lb); free_object_duplilist(lb);
} }
AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupliObParent) AbcTransformWriter * AbcExporter::createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent)
{ {
/* An object should not be its own parent, or we'll get infinite loops. */ /* An object should not be its own parent, or we'll get infinite loops. */
BLI_assert(ob != parent); BLI_assert(ob != parent);
@@ -450,29 +451,29 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare
* return the parent's AbcTransformWriter pointer. */ * return the parent's AbcTransformWriter pointer. */
if (parent->parent) { if (parent->parent) {
if (parent == dupliObParent) { if (parent == dupliObParent) {
parent_writer = createTransformWriter(parent, parent->parent, NULL); parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, NULL);
} }
else { else {
parent_writer = createTransformWriter(parent, parent->parent, dupliObParent); parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, dupliObParent);
} }
} }
else if (parent == dupliObParent) { else if (parent == dupliObParent) {
if (dupliObParent->parent == NULL) { if (dupliObParent->parent == NULL) {
parent_writer = createTransformWriter(parent, NULL, NULL); parent_writer = createTransformWriter(eval_ctx, parent, NULL, NULL);
} }
else { else {
parent_writer = createTransformWriter(parent, dupliObParent->parent, dupliObParent->parent); parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent->parent, dupliObParent->parent);
} }
} }
else { else {
parent_writer = createTransformWriter(parent, dupliObParent, dupliObParent); parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent, dupliObParent);
} }
BLI_assert(parent_writer); BLI_assert(parent_writer);
alembic_parent = parent_writer->alembicXform(); alembic_parent = parent_writer->alembicXform();
} }
my_writer = new AbcTransformWriter(ob, alembic_parent, parent_writer, my_writer = new AbcTransformWriter(eval_ctx, ob, alembic_parent, parent_writer,
m_trans_sampling_index, m_settings); m_trans_sampling_index, m_settings);
/* When flattening, the matrix of the dupliobject has to be added. */ /* When flattening, the matrix of the dupliobject has to be added. */
@@ -540,10 +541,10 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x
if (m_settings.export_hair && psys->part->type == PART_HAIR) { if (m_settings.export_hair && psys->part->type == PART_HAIR) {
m_settings.export_child_hairs = true; m_settings.export_child_hairs = true;
m_shapes.push_back(new AbcHairWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys)); m_shapes.push_back(new AbcHairWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
} }
else if (m_settings.export_particles && psys->part->type == PART_EMITTER) { else if (m_settings.export_particles && psys->part->type == PART_EMITTER) {
m_shapes.push_back(new AbcPointsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys)); m_shapes.push_back(new AbcPointsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
} }
} }
} }
@@ -583,7 +584,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return; return;
} }
m_shapes.push_back(new AbcMeshWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); m_shapes.push_back(new AbcMeshWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break; break;
} }
case OB_SURF: case OB_SURF:
@@ -594,7 +595,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return; return;
} }
m_shapes.push_back(new AbcNurbsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); m_shapes.push_back(new AbcNurbsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break; break;
} }
case OB_CURVE: case OB_CURVE:
@@ -605,7 +606,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
return; return;
} }
m_shapes.push_back(new AbcCurveWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); m_shapes.push_back(new AbcCurveWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break; break;
} }
case OB_CAMERA: case OB_CAMERA:
@@ -613,7 +614,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
Camera *cam = static_cast<Camera *>(ob->data); Camera *cam = static_cast<Camera *>(ob->data);
if (cam->type == CAM_PERSP) { if (cam->type == CAM_PERSP) {
m_shapes.push_back(new AbcCameraWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); m_shapes.push_back(new AbcCameraWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings));
} }
break; break;

View File

@@ -90,6 +90,7 @@ class AbcExporter {
unsigned int m_trans_sampling_index, m_shape_sampling_index; unsigned int m_trans_sampling_index, m_shape_sampling_index;
EvaluationContext *m_eval_ctx;
Scene *m_scene; Scene *m_scene;
ArchiveWriter *m_writer; ArchiveWriter *m_writer;
@@ -101,7 +102,7 @@ class AbcExporter {
std::vector<AbcObjectWriter *> m_shapes; std::vector<AbcObjectWriter *> m_shapes;
public: public:
AbcExporter(Scene *scene, const char *filename, ExportSettings &settings); AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings);
~AbcExporter(); ~AbcExporter();
void operator()(Main *bmain, float &progress, bool &was_canceled); void operator()(Main *bmain, float &progress, bool &was_canceled);
@@ -116,7 +117,7 @@ private:
Alembic::Abc::TimeSamplingPtr createTimeSampling(double step); Alembic::Abc::TimeSamplingPtr createTimeSampling(double step);
void createTransformWritersHierarchy(EvaluationContext *eval_ctx); void createTransformWritersHierarchy(EvaluationContext *eval_ctx);
AbcTransformWriter * createTransformWriter(Object *ob, Object *parent, Object *dupliObParent); AbcTransformWriter * createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent);
void exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent); void exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent);
void exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent); void exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent);
void createShapeWriters(EvaluationContext *eval_ctx); void createShapeWriters(EvaluationContext *eval_ctx);

View File

@@ -49,13 +49,14 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */ /* ************************************************************************** */
AbcHairWriter::AbcHairWriter(Scene *scene, AbcHairWriter::AbcHairWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings, ExportSettings &settings,
ParticleSystem *psys) ParticleSystem *psys)
: AbcObjectWriter(scene, ob, time_sampling, settings, parent) : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
, m_uv_warning_shown(false) , m_uv_warning_shown(false)
{ {
m_psys = psys; m_psys = psys;
@@ -76,7 +77,7 @@ void AbcHairWriter::do_write()
return; return;
} }
DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH); DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
DM_ensure_tessface(dm); DM_ensure_tessface(dm);
std::vector<Imath::V3f> verts; std::vector<Imath::V3f> verts;

View File

@@ -40,7 +40,8 @@ class AbcHairWriter : public AbcObjectWriter {
bool m_uv_warning_shown; bool m_uv_warning_shown;
public: public:
AbcHairWriter(Scene *scene, AbcHairWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,

View File

@@ -286,12 +286,13 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob)
/* ************************************************************************** */ /* ************************************************************************** */
AbcMeshWriter::AbcMeshWriter(Scene *scene, AbcMeshWriter::AbcMeshWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings) ExportSettings &settings)
: AbcObjectWriter(scene, ob, time_sampling, settings, parent) : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{ {
m_is_animated = isAnimated(); m_is_animated = isAnimated();
m_subsurf_mod = NULL; m_subsurf_mod = NULL;
@@ -519,7 +520,7 @@ DerivedMesh *AbcMeshWriter::getFinalMesh()
m_subsurf_mod->mode |= eModifierMode_DisableTemporary; m_subsurf_mod->mode |= eModifierMode_DisableTemporary;
} }
DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH); DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH);
if (m_subsurf_mod) { if (m_subsurf_mod) {
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary; m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;

View File

@@ -50,7 +50,8 @@ class AbcMeshWriter : public AbcObjectWriter {
bool m_is_subd; bool m_is_subd;
public: public:
AbcMeshWriter(Scene *scene, AbcMeshWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,

View File

@@ -60,12 +60,13 @@ using Alembic::AbcGeom::ONuPatchSchema;
/* ************************************************************************** */ /* ************************************************************************** */
AbcNurbsWriter::AbcNurbsWriter(Scene *scene, AbcNurbsWriter::AbcNurbsWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings) ExportSettings &settings)
: AbcObjectWriter(scene, ob, time_sampling, settings, parent) : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{ {
m_is_animated = isAnimated(); m_is_animated = isAnimated();

View File

@@ -32,7 +32,8 @@ class AbcNurbsWriter : public AbcObjectWriter {
bool m_is_animated; bool m_is_animated;
public: public:
AbcNurbsWriter(Scene *scene, AbcNurbsWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,

View File

@@ -58,13 +58,15 @@ using Alembic::AbcGeom::OStringProperty;
/* ************************************************************************** */ /* ************************************************************************** */
AbcObjectWriter::AbcObjectWriter(Scene *scene, AbcObjectWriter::AbcObjectWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings, ExportSettings &settings,
AbcObjectWriter *parent) AbcObjectWriter *parent)
: m_object(ob) : m_object(ob)
, m_settings(settings) , m_settings(settings)
, m_eval_ctx(eval_ctx)
, m_scene(scene) , m_scene(scene)
, m_time_sampling(time_sampling) , m_time_sampling(time_sampling)
, m_first_frame(true) , m_first_frame(true)

View File

@@ -44,6 +44,7 @@ protected:
Object *m_object; Object *m_object;
ExportSettings &m_settings; ExportSettings &m_settings;
EvaluationContext *m_eval_ctx;
Scene *m_scene; Scene *m_scene;
uint32_t m_time_sampling; uint32_t m_time_sampling;
@@ -56,7 +57,8 @@ protected:
std::string m_name; std::string m_name;
public: public:
AbcObjectWriter(Scene *scene, AbcObjectWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings, ExportSettings &settings,

View File

@@ -58,13 +58,14 @@ using Alembic::AbcGeom::OPointsSchema;
/* ************************************************************************** */ /* ************************************************************************** */
AbcPointsWriter::AbcPointsWriter(Scene *scene, AbcPointsWriter::AbcPointsWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,
ExportSettings &settings, ExportSettings &settings,
ParticleSystem *psys) ParticleSystem *psys)
: AbcObjectWriter(scene, ob, time_sampling, settings, parent) : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent)
{ {
m_psys = psys; m_psys = psys;
@@ -86,6 +87,7 @@ void AbcPointsWriter::do_write()
ParticleKey state; ParticleKey state;
ParticleSimulationData sim; ParticleSimulationData sim;
sim.eval_ctx = m_eval_ctx;
sim.scene = m_scene; sim.scene = m_scene;
sim.ob = m_object; sim.ob = m_object;
sim.psys = m_psys; sim.psys = m_psys;

View File

@@ -38,7 +38,8 @@ class AbcPointsWriter : public AbcObjectWriter {
ParticleSystem *m_psys; ParticleSystem *m_psys;
public: public:
AbcPointsWriter(Scene *scene, AbcPointsWriter(EvaluationContext *eval_ctx,
Scene *scene,
Object *ob, Object *ob,
AbcTransformWriter *parent, AbcTransformWriter *parent,
uint32_t time_sampling, uint32_t time_sampling,

View File

@@ -57,12 +57,13 @@ static bool has_parent_camera(Object *ob)
/* ************************************************************************** */ /* ************************************************************************** */
AbcTransformWriter::AbcTransformWriter(Object *ob, AbcTransformWriter::AbcTransformWriter(EvaluationContext *eval_ctx,
Object *ob,
const OObject &abc_parent, const OObject &abc_parent,
AbcTransformWriter *parent, AbcTransformWriter *parent,
unsigned int time_sampling, unsigned int time_sampling,
ExportSettings &settings) ExportSettings &settings)
: AbcObjectWriter(NULL, ob, time_sampling, settings, parent) : AbcObjectWriter(eval_ctx, NULL, ob, time_sampling, settings, parent)
, m_proxy_from(NULL) , m_proxy_from(NULL)
{ {
m_is_animated = hasAnimation(m_object); m_is_animated = hasAnimation(m_object);

View File

@@ -44,7 +44,8 @@ public:
Object *m_proxy_from; Object *m_proxy_from;
public: public:
AbcTransformWriter(Object *ob, AbcTransformWriter(EvaluationContext *eval_ctx,
Object *ob,
const Alembic::AbcGeom::OObject &abc_parent, const Alembic::AbcGeom::OObject &abc_parent,
AbcTransformWriter *parent, AbcTransformWriter *parent,
unsigned int time_sampling, unsigned int time_sampling,

View File

@@ -230,6 +230,7 @@ static void find_iobject(const IObject &object, IObject &ret,
} }
struct ExportJobData { struct ExportJobData {
EvaluationContext eval_ctx;
Scene *scene; Scene *scene;
Main *bmain; Main *bmain;
@@ -262,7 +263,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
try { try {
Scene *scene = data->scene; Scene *scene = data->scene;
AbcExporter exporter(scene, data->filename, data->settings); AbcExporter exporter(&data->eval_ctx, scene, data->filename, data->settings);
const int orig_frame = CFRA; const int orig_frame = CFRA;
@@ -310,6 +311,9 @@ bool ABC_export(
bool as_background_job) bool as_background_job)
{ {
ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData")); ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
CTX_data_eval_ctx(C, &job->eval_ctx);
job->scene = scene; job->scene = scene;
job->bmain = CTX_data_main(C); job->bmain = CTX_data_main(C);
job->export_ok = false; job->export_ok = false;

View File

@@ -98,6 +98,7 @@ struct ColorBand;
struct GPUVertexAttribs; struct GPUVertexAttribs;
struct GPUDrawObject; struct GPUDrawObject;
struct PBVH; struct PBVH;
struct EvaluationContext;
/* number of sub-elements each mesh element has (for interpolation) */ /* number of sub-elements each mesh element has (for interpolation) */
#define SUB_ELEMS_VERT 0 #define SUB_ELEMS_VERT 0
@@ -658,56 +659,56 @@ void mesh_get_mapped_verts_coords(DerivedMesh *dm, float (*r_cos)[3], const int
/* */ /* */
DerivedMesh *mesh_get_derived_final( DerivedMesh *mesh_get_derived_final(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene,
CustomDataMask dataMask); struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_get_derived_deform( DerivedMesh *mesh_get_derived_deform(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene,
CustomDataMask dataMask); struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_for_modifier( DerivedMesh *mesh_create_derived_for_modifier(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
struct ModifierData *md, int build_shapekey_layers); struct ModifierData *md, int build_shapekey_layers);
DerivedMesh *mesh_create_derived_render( DerivedMesh *mesh_create_derived_render(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene,
CustomDataMask dataMask); struct Object *ob, CustomDataMask dataMask);
DerivedMesh *getEditDerivedBMesh( DerivedMesh *getEditDerivedBMesh(
struct BMEditMesh *em, struct Object *ob, CustomDataMask data_mask, struct BMEditMesh *em, struct Object *ob, CustomDataMask data_mask,
float (*vertexCos)[3]); float (*vertexCos)[3]);
DerivedMesh *mesh_create_derived_index_render( DerivedMesh *mesh_create_derived_index_render(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene,
CustomDataMask dataMask, int index); struct Object *ob, CustomDataMask dataMask, int index);
/* same as above but wont use render settings */ /* same as above but wont use render settings */
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]); DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
DerivedMesh *mesh_create_derived_view( DerivedMesh *mesh_create_derived_view(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene,
CustomDataMask dataMask); struct Object *ob, CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform( DerivedMesh *mesh_create_derived_no_deform(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene,
float (*vertCos)[3], struct Object *ob, float (*vertCos)[3],
CustomDataMask dataMask); CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_no_deform_render( DerivedMesh *mesh_create_derived_no_deform_render(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene,
float (*vertCos)[3], struct Object *ob, float (*vertCos)[3],
CustomDataMask dataMask); CustomDataMask dataMask);
/* for gameengine */ /* for gameengine */
DerivedMesh *mesh_create_derived_no_virtual( DerivedMesh *mesh_create_derived_no_virtual(
struct Scene *scene, struct Object *ob, float (*vertCos)[3], struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
CustomDataMask dataMask); float (*vertCos)[3], CustomDataMask dataMask);
DerivedMesh *mesh_create_derived_physics( DerivedMesh *mesh_create_derived_physics(
struct Scene *scene, struct Object *ob, float (*vertCos)[3], struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
CustomDataMask dataMask); float (*vertCos)[3], CustomDataMask dataMask);
DerivedMesh *editbmesh_get_derived_base( DerivedMesh *editbmesh_get_derived_base(
struct Object *ob, struct BMEditMesh *em, CustomDataMask data_mask); struct Object *ob, struct BMEditMesh *em, CustomDataMask data_mask);
DerivedMesh *editbmesh_get_derived_cage( DerivedMesh *editbmesh_get_derived_cage(
struct Scene *scene, struct Object *, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask); struct BMEditMesh *em, CustomDataMask dataMask);
DerivedMesh *editbmesh_get_derived_cage_and_final( DerivedMesh *editbmesh_get_derived_cage_and_final(
struct Scene *scene, struct Object *, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *,
struct BMEditMesh *em, CustomDataMask dataMask, struct BMEditMesh *em, CustomDataMask dataMask,
DerivedMesh **r_final); DerivedMesh **r_final);
@@ -716,7 +717,7 @@ DerivedMesh *object_get_derived_final(struct Object *ob, const bool for_render);
float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3]; float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm); bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
void makeDerivedMesh( void makeDerivedMesh(
struct Scene *scene, struct Object *ob, struct BMEditMesh *em, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers); CustomDataMask dataMask, const bool build_shapekey_layers);
void weight_to_rgb(float r_rgb[3], const float weight); void weight_to_rgb(float r_rgb[3], const float weight);

View File

@@ -41,6 +41,7 @@ struct bAnimVizSettings;
struct bMotionPath; struct bMotionPath;
struct bPoseChannel; struct bPoseChannel;
struct ReportList; struct ReportList;
struct bContext;
/* ---------------------------------------------------- */ /* ---------------------------------------------------- */
/* Animation Visualization */ /* Animation Visualization */
@@ -53,7 +54,7 @@ void animviz_free_motionpath(struct bMotionPath *mpath);
struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan); struct bMotionPath *animviz_verify_motionpaths(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan);
void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets); void animviz_get_object_motionpaths(struct Object *ob, ListBase *targets);
void animviz_calc_motionpaths(struct Scene *scene, ListBase *targets); void animviz_calc_motionpaths(struct bContext *C, struct Scene *scene, ListBase *targets);
/* ---------------------------------------------------- */ /* ---------------------------------------------------- */
/* Curve Paths */ /* Curve Paths */
@@ -80,7 +81,7 @@ typedef struct DupliApplyData {
DupliExtraData *extra; DupliExtraData *extra;
} DupliApplyData; } DupliApplyData;
DupliApplyData *duplilist_apply(struct Object *ob, struct Scene *scene, struct ListBase *duplilist); DupliApplyData *duplilist_apply(struct EvaluationContext *eval_ctx, struct Object *ob, struct Scene *scene, struct ListBase *duplilist);
void duplilist_restore(struct ListBase *duplilist, DupliApplyData *apply_data); void duplilist_restore(struct ListBase *duplilist, DupliApplyData *apply_data);
void duplilist_free_apply_data(DupliApplyData *apply_data); void duplilist_free_apply_data(DupliApplyData *apply_data);

View File

@@ -35,6 +35,7 @@
struct bPose; struct bPose;
struct Bone; struct Bone;
struct EvaluationContext;
struct GHash; struct GHash;
struct Main; struct Main;
struct bArmature; struct bArmature;
@@ -98,8 +99,8 @@ void BKE_armature_where_is(struct bArmature *arm);
void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion); void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone, const bool use_recursion);
void BKE_pose_clear_pointers(struct bPose *pose); void BKE_pose_clear_pointers(struct bPose *pose);
void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm); void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm);
void BKE_pose_where_is(struct Scene *scene, struct Object *ob); void BKE_pose_where_is(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
void BKE_pose_where_is_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra); void BKE_pose_where_is_bone(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, bool do_extra);
void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan); void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan);
/* get_objectspace_bone_matrix has to be removed still */ /* get_objectspace_bone_matrix has to be removed still */
@@ -116,7 +117,7 @@ void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc
void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]); void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], float arm_mat[4][4]); void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], float arm_mat[4][4]);
void BKE_armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]); void BKE_armature_mat_pose_to_bone_ex(struct EvaluationContext *eval_ctx, struct Object *ob, struct bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]);
void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat); void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat); void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
@@ -154,7 +155,6 @@ void b_bone_spline_setup(struct bPoseChannel *pchan, int rest, Mat4 result_array
struct bKinematicConstraint; struct bKinematicConstraint;
struct bPose; struct bPose;
struct bSplineIKConstraint; struct bSplineIKConstraint;
struct EvaluationContext;
struct bPoseChannel *BKE_armature_ik_solver_find_root( struct bPoseChannel *BKE_armature_ik_solver_find_root(
struct bPoseChannel *pchan, struct bPoseChannel *pchan,
@@ -164,7 +164,7 @@ struct bPoseChannel *BKE_armature_splineik_solver_find_root(
struct bSplineIKConstraint *data); struct bSplineIKConstraint *data);
void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float ctime); void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float ctime);
void BKE_splineik_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime); void BKE_splineik_execute_tree(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime);
void BKE_pose_eval_init(struct EvaluationContext *eval_ctx, void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
struct Scene *scene, struct Scene *scene,

View File

@@ -41,6 +41,7 @@ struct MFace;
struct DerivedMesh; struct DerivedMesh;
struct ClothModifierData; struct ClothModifierData;
struct CollisionModifierData; struct CollisionModifierData;
struct EvaluationContext;
#define DO_INLINE MALWAYS_INLINE #define DO_INLINE MALWAYS_INLINE
@@ -226,7 +227,7 @@ void cloth_free_contacts(ColliderContacts *collider_contacts, int totcolliders);
void cloth_free_modifier_extern (struct ClothModifierData *clmd ); void cloth_free_modifier_extern (struct ClothModifierData *clmd );
void cloth_free_modifier (struct ClothModifierData *clmd ); void cloth_free_modifier (struct ClothModifierData *clmd );
void cloth_init (struct ClothModifierData *clmd ); void cloth_init (struct ClothModifierData *clmd );
void clothModifier_do (struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]); void clothModifier_do (struct ClothModifierData *clmd, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]);
int cloth_uses_vgroup(struct ClothModifierData *clmd); int cloth_uses_vgroup(struct ClothModifierData *clmd);

View File

@@ -40,6 +40,7 @@ struct ListBase;
struct Object; struct Object;
struct Scene; struct Scene;
struct bPoseChannel; struct bPoseChannel;
struct EvaluationContext;
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
#ifdef __cplusplus #ifdef __cplusplus
@@ -102,7 +103,7 @@ typedef struct bConstraintTypeInfo {
/* evaluation */ /* evaluation */
/* set the ct->matrix for the given constraint target (at the given ctime) */ /* set the ct->matrix for the given constraint target (at the given ctime) */
void (*get_target_matrix)(struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime); void (*get_target_matrix)(struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime);
/* evaluate the constraint for the given time */ /* evaluate the constraint for the given time */
void (*evaluate_constraint)(struct bConstraint *con, struct bConstraintOb *cob, struct ListBase *targets); void (*evaluate_constraint)(struct bConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
} bConstraintTypeInfo; } bConstraintTypeInfo;
@@ -146,9 +147,10 @@ void BKE_constraints_clear_evalob(struct bConstraintOb *cob);
void BKE_constraint_mat_convertspace( void BKE_constraint_mat_convertspace(
struct Object *ob, struct bPoseChannel *pchan, float mat[4][4], short from, short to, const bool keep_scale); struct Object *ob, struct bPoseChannel *pchan, float mat[4][4], short from, short to, const bool keep_scale);
void BKE_constraint_target_matrix_get(struct Scene *scene, struct bConstraint *con, int n, short ownertype, void *ownerdata, float mat[4][4], float ctime); void BKE_constraint_target_matrix_get(struct EvaluationContext *eval_ctx, struct Scene *scene, struct bConstraint *con,
void BKE_constraint_targets_for_solving_get(struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime); int n, short ownertype, void *ownerdata, float mat[4][4], float ctime);
void BKE_constraints_solve(struct ListBase *conlist, struct bConstraintOb *cob, float ctime); void BKE_constraint_targets_for_solving_get(struct EvaluationContext *eval_ctx, struct bConstraint *con, struct bConstraintOb *ob, struct ListBase *targets, float ctime);
void BKE_constraints_solve(struct EvaluationContext *eval_ctx, struct ListBase *conlist, struct bConstraintOb *cob, float ctime);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -73,6 +73,7 @@ struct SpaceText;
struct SpaceImage; struct SpaceImage;
struct SpaceClip; struct SpaceClip;
struct ID; struct ID;
struct EvaluationContext;
/* Structs */ /* Structs */
@@ -308,6 +309,8 @@ int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list);
struct Depsgraph *CTX_data_depsgraph(const bContext *C); struct Depsgraph *CTX_data_depsgraph(const bContext *C);
void CTX_data_eval_ctx(const bContext *C, struct EvaluationContext *eval_ctx);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -38,23 +38,24 @@ struct Scene;
struct Object; struct Object;
struct BMEditMesh; struct BMEditMesh;
struct Mesh; struct Mesh;
struct EvaluationContext;
/* crazyspace.c */ /* crazyspace.c */
float (*BKE_crazyspace_get_mapped_editverts( float (*BKE_crazyspace_get_mapped_editverts(
struct Scene *scene, struct Object *obedit))[3]; struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *obedit))[3];
void BKE_crazyspace_set_quats_editmesh( void BKE_crazyspace_set_quats_editmesh(
struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4], struct BMEditMesh *em, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4],
const bool use_select); const bool use_select);
void BKE_crazyspace_set_quats_mesh( void BKE_crazyspace_set_quats_mesh(
struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]); struct Mesh *me, float (*origcos)[3], float (*mappedcos)[3], float (*quats)[4]);
int BKE_crazyspace_get_first_deform_matrices_editbmesh( int BKE_crazyspace_get_first_deform_matrices_editbmesh(
struct Scene *, struct Object *, struct BMEditMesh *em, struct EvaluationContext *eval_ctx, struct Scene *, struct Object *, struct BMEditMesh *em,
float (**deformmats)[3][3], float (**deformcos)[3]); float (**deformmats)[3][3], float (**deformcos)[3]);
int BKE_sculpt_get_first_deform_matrices( int BKE_sculpt_get_first_deform_matrices(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
float (**deformmats)[3][3], float (**deformcos)[3]); float (**deformmats)[3][3], float (**deformcos)[3]);
void BKE_crazyspace_build_sculpt( void BKE_crazyspace_build_sculpt(
struct Scene *scene, struct Object *ob, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
float (**deformmats)[3][3], float (**deformcos)[3]); float (**deformmats)[3][3], float (**deformcos)[3]);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -36,6 +36,7 @@
struct BezTriple; struct BezTriple;
struct Curve; struct Curve;
struct EditNurb; struct EditNurb;
struct EvaluationContext;
struct GHash; struct GHash;
struct ListBase; struct ListBase;
struct Main; struct Main;
@@ -121,12 +122,12 @@ void BKE_curve_editNurb_keyIndex_free(struct GHash **keyindex);
void BKE_curve_editNurb_free(struct Curve *cu); void BKE_curve_editNurb_free(struct Curve *cu);
struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu); struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
float *BKE_curve_make_orco(struct Scene *scene, struct Object *ob, int *r_numVerts); float *BKE_curve_make_orco(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, int *r_numVerts);
float *BKE_curve_surf_make_orco(struct Object *ob); float *BKE_curve_surf_make_orco(struct Object *ob);
void BKE_curve_bevelList_free(struct ListBase *bev); void BKE_curve_bevelList_free(struct ListBase *bev);
void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render); void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
void BKE_curve_bevel_make(struct Scene *scene, struct Object *ob, struct ListBase *disp, void BKE_curve_bevel_make(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *disp,
const bool for_render, const bool use_render_resolution); const bool for_render, const bool use_render_resolution);
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride); void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
@@ -212,8 +213,6 @@ void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles);
/* **** Depsgraph evaluation **** */ /* **** Depsgraph evaluation **** */
struct EvaluationContext;
void BKE_curve_eval_geometry(struct EvaluationContext *eval_ctx, void BKE_curve_eval_geometry(struct EvaluationContext *eval_ctx,
struct Curve *curve); struct Curve *curve);

View File

@@ -42,6 +42,7 @@ struct Object;
struct Scene; struct Scene;
struct SpaceTransform; struct SpaceTransform;
struct ReportList; struct ReportList;
struct EvaluationContext;
/* Warning, those def are stored in files (TransferData modifier), *DO NOT* modify those values. */ /* Warning, those def are stored in files (TransferData modifier), *DO NOT* modify those values. */
enum { enum {
@@ -129,11 +130,12 @@ enum {
}; };
void BKE_object_data_transfer_layout( void BKE_object_data_transfer_layout(
struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_delete, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src,
struct Object *ob_dst, const int data_types, const bool use_delete,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]); const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]);
bool BKE_object_data_transfer_mesh( bool BKE_object_data_transfer_mesh(
struct Scene *scene, struct EvaluationContext *eval_ctx, struct Scene *scene,
struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_create, struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,
struct SpaceTransform *space_transform, const bool auto_transform, struct SpaceTransform *space_transform, const bool auto_transform,
@@ -142,7 +144,7 @@ bool BKE_object_data_transfer_mesh(
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup, const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
struct ReportList *reports); struct ReportList *reports);
bool BKE_object_data_transfer_dm( bool BKE_object_data_transfer_dm(
struct Scene *scene, struct EvaluationContext *eval_ctx, struct Scene *scene,
struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst, struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst,
const int data_types, bool use_create, const int data_types, bool use_create,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode,

View File

@@ -86,22 +86,22 @@ void BKE_displist_count(struct ListBase *lb, int *totvert, int *totface, int *to
void BKE_displist_free(struct ListBase *lb); void BKE_displist_free(struct ListBase *lb);
bool BKE_displist_has_faces(struct ListBase *lb); bool BKE_displist_has_faces(struct ListBase *lb);
void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **r_dm_final, void BKE_displist_make_surf(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
const bool for_render, const bool for_orco, const bool use_render_resolution); struct DerivedMesh **r_dm_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, const bool for_orco); void BKE_displist_make_curveTypes(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, const bool for_orco);
void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **r_dm_final, void BKE_displist_make_curveTypes_forRender(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
const bool for_orco, const bool use_render_resolution); struct DerivedMesh **r_dm_final, const bool for_orco, const bool use_render_resolution);
void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); void BKE_displist_make_curveTypes_forOrco(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
void BKE_displist_make_mball(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); void BKE_displist_make_mball(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
void BKE_displist_make_mball_forRender(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase); void BKE_displist_make_mball_forRender(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4);
void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const float normal_proj[3], const bool flipnormal); void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const float normal_proj[3], const bool flipnormal);
float BKE_displist_calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); float BKE_displist_calc_taper(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *taperobj, int cur, int tot);
/* add Orco layer to the displist object which has got derived mesh and return orco */ /* add Orco layer to the displist object which has got derived mesh and return orco */
float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final, float *BKE_displist_make_orco(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
const bool for_render, const bool use_render_resolution); const bool for_render, const bool use_render_resolution);
void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]); void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);

View File

@@ -29,6 +29,7 @@
struct Scene; struct Scene;
struct SceneLayer; struct SceneLayer;
struct EvaluationContext;
/* Actual surface point */ /* Actual surface point */
typedef struct PaintSurfaceData { typedef struct PaintSurfaceData {
@@ -61,8 +62,8 @@ typedef struct PaintWavePoint {
short state; short state;
} PaintWavePoint; } PaintWavePoint;
struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct Scene *scene, struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData *pmd, struct EvaluationContext *eval_ctx, struct Scene *scene,
struct SceneLayer *sl, struct Object *ob, struct DerivedMesh *dm); struct Object *ob, struct DerivedMesh *dm);
void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd); void dynamicPaint_Modifier_free(struct DynamicPaintModifierData *pmd);
void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd); void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd);
@@ -85,7 +86,7 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings
/* image sequence baking */ /* image sequence baking */
int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update); int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, short *do_update);
int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct Scene *scene, struct SceneLayer *sl, struct Object *cObject, int frame); int dynamicPaint_calculateFrame(struct DynamicPaintSurface *surface, struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cObject, int frame);
void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer); void dynamicPaint_outputSurfaceImage(struct DynamicPaintSurface *surface, char *filename, short output_layer);
/* PaintPoint state */ /* PaintPoint state */

View File

@@ -40,6 +40,7 @@ struct Mesh;
struct Scene; struct Scene;
struct DerivedMesh; struct DerivedMesh;
struct MeshStatVis; struct MeshStatVis;
struct EvaluationContext;
/** /**
* This structure is used for mesh edit-mode. * This structure is used for mesh edit-mode.
@@ -98,6 +99,6 @@ float (*BKE_editmesh_vertexCos_get_orco(BMEditMesh *em, int *r_numVerts))[3]
void BKE_editmesh_statvis_calc(BMEditMesh *em, struct DerivedMesh *dm, void BKE_editmesh_statvis_calc(BMEditMesh *em, struct DerivedMesh *dm,
const struct MeshStatVis *statvis); const struct MeshStatVis *statvis);
float (*BKE_editmesh_vertexCos_get(struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3]; float (*BKE_editmesh_vertexCos_get(struct EvaluationContext *eval_ctx, struct BMEditMesh *em, struct Scene *scene, int *r_numVerts))[3];
#endif /* __BKE_EDITMESH_H__ */ #endif /* __BKE_EDITMESH_H__ */

View File

@@ -44,6 +44,7 @@ struct Group;
struct ParticleSimulationData; struct ParticleSimulationData;
struct ParticleData; struct ParticleData;
struct ParticleKey; struct ParticleKey;
struct EvaluationContext;
struct EffectorWeights *BKE_add_effector_weights(struct Group *group); struct EffectorWeights *BKE_add_effector_weights(struct Group *group);
struct PartDeflect *object_add_collision_fields(int type); struct PartDeflect *object_add_collision_fields(int type);
@@ -93,6 +94,7 @@ typedef struct EffectorData {
typedef struct EffectorCache { typedef struct EffectorCache {
struct EffectorCache *next, *prev; struct EffectorCache *next, *prev;
struct EvaluationContext *eval_ctx;
struct Scene *scene; struct Scene *scene;
struct Object *ob; struct Object *ob;
struct ParticleSystem *psys; struct ParticleSystem *psys;
@@ -110,9 +112,10 @@ typedef struct EffectorCache {
} EffectorCache; } EffectorCache;
void free_partdeflect(struct PartDeflect *pd); void free_partdeflect(struct PartDeflect *pd);
struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool for_simulation); struct ListBase *pdInitEffectors(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src,
struct EffectorWeights *weights, bool for_simulation);
void pdEndEffectors(struct ListBase **effectors); void pdEndEffectors(struct ListBase **effectors);
void pdPrecalculateEffectors(struct ListBase *effectors); void pdPrecalculateEffectors(struct EvaluationContext *eval_ctx, struct ListBase *effectors);
void pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse); void pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse);
void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point); void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point);

View File

@@ -36,10 +36,11 @@ struct Object;
struct Scene; struct Scene;
struct FluidsimSettings; struct FluidsimSettings;
struct MVert; struct MVert;
struct EvaluationContext;
/* old interface */ /* old interface */
void initElbeemMesh(struct Scene *scene, struct Object *ob, void initElbeemMesh(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
int *numVertices, float **vertices, int *numVertices, float **vertices,
int *numTriangles, int **triangles, int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex); int useGlobalCoords, int modifierIndex);

View File

@@ -43,6 +43,7 @@ struct Scene;
struct DerivedMesh; struct DerivedMesh;
struct BPoint; struct BPoint;
struct MDeformVert; struct MDeformVert;
struct EvaluationContext;
void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
void BKE_lattice_init(struct Lattice *lt); void BKE_lattice_init(struct Lattice *lt);
@@ -60,10 +61,10 @@ void end_latt_deform(struct LatticeDeformData *lattice_deform_data);
bool object_deform_mball(struct Object *ob, struct ListBase *dispbase); bool object_deform_mball(struct Object *ob, struct ListBase *dispbase);
void outside_lattice(struct Lattice *lt); void outside_lattice(struct Lattice *lt);
void curve_deform_verts(struct Scene *scene, struct Object *cuOb, struct Object *target, void curve_deform_verts(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cuOb, struct Object *target,
struct DerivedMesh *dm, float (*vertexCos)[3], struct DerivedMesh *dm, float (*vertexCos)[3],
int numVerts, const char *vgroup, short defaxis); int numVerts, const char *vgroup, short defaxis);
void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object *target, void curve_deform_vector(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *cuOb, struct Object *target,
float orco[3], float vec[3], float mat[3][3], int no_rot_axis); float orco[3], float vec[3], float mat[3][3], int no_rot_axis);
void lattice_deform_verts(struct Object *laOb, struct Object *target, void lattice_deform_verts(struct Object *laOb, struct Object *target,
@@ -76,7 +77,7 @@ void armature_deform_verts(struct Object *armOb, struct Object *target,
float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3]; float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3];
void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]); void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]);
void BKE_lattice_modifiers_calc(struct Scene *scene, struct Object *ob); void BKE_lattice_modifiers_calc(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *lattice); struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *lattice);
struct BPoint *BKE_lattice_active_point_get(struct Lattice *lt); struct BPoint *BKE_lattice_active_point_get(struct Lattice *lt);

View File

@@ -35,6 +35,7 @@ struct ID;
struct BMeshCreateParams; struct BMeshCreateParams;
struct BoundBox; struct BoundBox;
struct EdgeHash; struct EdgeHash;
struct EvaluationContext;
struct ListBase; struct ListBase;
struct LinkNode; struct LinkNode;
struct BLI_Stack; struct BLI_Stack;
@@ -117,7 +118,7 @@ void BKE_mesh_from_nurbs_displist(
struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name); struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name);
void BKE_mesh_from_nurbs(struct Object *ob); void BKE_mesh_from_nurbs(struct Object *ob);
void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test); void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test);
void BKE_mesh_to_curve(struct Scene *scene, struct Object *ob); void BKE_mesh_to_curve(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
void BKE_mesh_material_index_remove(struct Mesh *me, short index); void BKE_mesh_material_index_remove(struct Mesh *me, short index);
void BKE_mesh_material_index_clear(struct Mesh *me); void BKE_mesh_material_index_clear(struct Mesh *me);
void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len); void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len);
@@ -138,7 +139,7 @@ float (*BKE_mesh_vertexCos_get(const struct Mesh *me, int *r_numVerts))[3];
void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals); void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
struct Mesh *BKE_mesh_new_from_object(struct Main *bmain, struct Scene *sce, struct Object *ob, struct Mesh *BKE_mesh_new_from_object(struct EvaluationContext *eval_ctx, struct Main *bmain, struct Scene *sce, struct Object *ob,
int apply_modifiers, int settings, int calc_tessface, int calc_undeformed); int apply_modifiers, int settings, int calc_tessface, int calc_undeformed);
/* vertex level transformations & checks (no derived mesh) */ /* vertex level transformations & checks (no derived mesh) */
@@ -399,8 +400,6 @@ void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select);
/* **** Depsgraph evaluation **** */ /* **** Depsgraph evaluation **** */
struct EvaluationContext;
void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx, void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx,
struct Mesh *mesh); struct Mesh *mesh);

View File

@@ -36,6 +36,7 @@ struct ID;
struct DerivedMesh; struct DerivedMesh;
struct DagForest; struct DagForest;
struct DagNode; struct DagNode;
struct EvaluationContext;
struct Object; struct Object;
struct Scene; struct Scene;
struct SceneLayer; struct SceneLayer;
@@ -158,25 +159,27 @@ typedef struct ModifierTypeInfo {
* the object it can obtain it from the derivedData argument if non-NULL, * the object it can obtain it from the derivedData argument if non-NULL,
* and otherwise the ob argument. * and otherwise the ob argument.
*/ */
void (*deformVerts)(struct ModifierData *md, struct Object *ob, void (*deformVerts)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
struct DerivedMesh *derivedData, struct Object *ob, struct DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts, float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag); ModifierApplyFlag flag);
/* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */ /* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */
void (*deformMatrices)(struct ModifierData *md, struct Object *ob, void (*deformMatrices)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
struct DerivedMesh *derivedData, struct Object *ob, struct DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/* Like deformVerts but called during editmode (for supporting modifiers) /* Like deformVerts but called during editmode (for supporting modifiers)
*/ */
void (*deformVertsEM)(struct ModifierData *md, struct Object *ob, void (*deformVertsEM)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
struct BMEditMesh *editData, struct DerivedMesh *derivedData, struct Object *ob, struct BMEditMesh *editData,
struct DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts); float (*vertexCos)[3], int numVerts);
/* Set deform matrix per vertex for crazyspace correction */ /* Set deform matrix per vertex for crazyspace correction */
void (*deformMatricesEM)(struct ModifierData *md, struct Object *ob, void (*deformMatricesEM)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
struct BMEditMesh *editData, struct DerivedMesh *derivedData, struct Object *ob, struct BMEditMesh *editData,
struct DerivedMesh *derivedData,
float (*vertexCos)[3], float (*defMats)[3][3], int numVerts); float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
/********************* Non-deform modifier functions *********************/ /********************* Non-deform modifier functions *********************/
@@ -200,8 +203,8 @@ typedef struct ModifierTypeInfo {
* The modifier may reuse the derivedData argument (i.e. return it in * The modifier may reuse the derivedData argument (i.e. return it in
* modified form), but must not release it. * modified form), but must not release it.
*/ */
struct DerivedMesh *(*applyModifier)(struct ModifierData *md, struct Object *ob, struct DerivedMesh *(*applyModifier)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
struct DerivedMesh *derivedData, struct Object *ob, struct DerivedMesh *derivedData,
ModifierApplyFlag flag); ModifierApplyFlag flag);
/* Like applyModifier but called during editmode (for supporting /* Like applyModifier but called during editmode (for supporting
@@ -211,10 +214,9 @@ typedef struct ModifierTypeInfo {
* are expected from editmode objects. The same qualifications regarding * are expected from editmode objects. The same qualifications regarding
* derivedData apply as for applyModifier. * derivedData apply as for applyModifier.
*/ */
struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, struct Object *ob, struct DerivedMesh *(*applyModifierEM)(struct ModifierData *md, struct EvaluationContext *eval_ctx,
struct BMEditMesh *editData, struct Object *ob, struct BMEditMesh *editData,
struct DerivedMesh *derivedData, struct DerivedMesh *derivedData, ModifierApplyFlag flag);
ModifierApplyFlag flag);
/********************* Optional functions *********************/ /********************* Optional functions *********************/
@@ -417,24 +419,24 @@ const char *modifier_path_relbase(struct Object *ob);
/* wrappers for modifier callbacks */ /* wrappers for modifier callbacks */
struct DerivedMesh *modwrap_applyModifier( struct DerivedMesh *modwrap_applyModifier(
ModifierData *md, struct Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx,
struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm,
ModifierApplyFlag flag); ModifierApplyFlag flag);
struct DerivedMesh *modwrap_applyModifierEM( struct DerivedMesh *modwrap_applyModifierEM(
ModifierData *md, struct Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx,
struct BMEditMesh *em, struct Object *ob, struct BMEditMesh *em,
struct DerivedMesh *dm, struct DerivedMesh *dm,
ModifierApplyFlag flag); ModifierApplyFlag flag);
void modwrap_deformVerts( void modwrap_deformVerts(
ModifierData *md, struct Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx,
struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts, float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag); ModifierApplyFlag flag);
void modwrap_deformVertsEM( void modwrap_deformVertsEM(
ModifierData *md, struct Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx, struct Object *ob,
struct BMEditMesh *em, struct DerivedMesh *dm, struct BMEditMesh *em, struct DerivedMesh *dm,
float (*vertexCos)[3], int numVerts); float (*vertexCos)[3], int numVerts);

View File

@@ -34,6 +34,7 @@
enum MultiresModifiedFlags; enum MultiresModifiedFlags;
struct DerivedMesh; struct DerivedMesh;
struct EvaluationContext;
struct MDisps; struct MDisps;
struct Mesh; struct Mesh;
struct ModifierData; struct ModifierData;
@@ -80,18 +81,18 @@ struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm,
struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene,
struct ModifierData *lastmd); struct ModifierData *lastmd);
struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first); struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first);
struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd, struct DerivedMesh *get_multires_dm(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob); struct Object *ob);
void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob); void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob);
void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple); void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple);
void multiresModifier_sync_levels_ex( void multiresModifier_sync_levels_ex(
struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst); struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst);
int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd, int multiresModifier_reshape(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *dst, struct Object *src); struct Object *dst, struct Object *src);
int multiresModifier_reshapeFromDM(struct Scene *scene, struct MultiresModifierData *mmd, int multiresModifier_reshapeFromDM(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct DerivedMesh *srcdm); struct Object *ob, struct DerivedMesh *srcdm);
int multiresModifier_reshapeFromDeformMod(struct Scene *scene, struct MultiresModifierData *mmd, int multiresModifier_reshapeFromDeformMod(struct EvaluationContext *eval_ctx, struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob, struct ModifierData *md); struct Object *ob, struct ModifierData *md);
void multires_stitch_grids(struct Object *); void multires_stitch_grids(struct Object *);
@@ -109,8 +110,8 @@ void multires_free(struct Multires *mr);
void multires_load_old(struct Object *ob, struct Mesh *me); void multires_load_old(struct Object *ob, struct Mesh *me);
void multires_load_old_250(struct Mesh *); void multires_load_old_250(struct Mesh *);
void multiresModifier_scale_disp(struct Scene *scene, struct Object *ob); void multiresModifier_scale_disp(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
void multiresModifier_prepare_join(struct Scene *scene, struct Object *ob, struct Object *to_ob); void multiresModifier_prepare_join(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *to_ob);
int multires_mdisp_corners(struct MDisps *s); int multires_mdisp_corners(struct MDisps *s);

View File

@@ -51,7 +51,7 @@ struct HookModifierData;
struct ModifierData; struct ModifierData;
void BKE_object_workob_clear(struct Object *workob); void BKE_object_workob_clear(struct Object *workob);
void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob); void BKE_object_workob_calc_parent(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *workob);
void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src); void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src);
struct SoftBody *copy_softbody(const struct SoftBody *sb, bool copy_caches); struct SoftBody *copy_softbody(const struct SoftBody *sb, bool copy_caches);
@@ -126,11 +126,12 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
bool BKE_object_pose_context_check(struct Object *ob); bool BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob);
void BKE_object_get_parent_matrix(struct Scene *scene, struct Object *ob, struct Object *par, float parentmat[4][4]); void BKE_object_get_parent_matrix(struct Scene *scene, struct Object *ob,
void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob); struct Object *par, float parentmat[4][4]);
void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]); void BKE_object_where_is_calc(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob);
void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime); void BKE_object_where_is_calc_ex(struct EvaluationContext *eval_ctx, struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
void BKE_object_where_is_calc_time_ex(struct Scene *scene, struct Object *ob, float ctime, void BKE_object_where_is_calc_time(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime);
void BKE_object_where_is_calc_time_ex(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, float ctime,
struct RigidBodyWorld *rbw, float r_originmat[3][3]); struct RigidBodyWorld *rbw, float r_originmat[3][3]);
void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]); void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);
@@ -261,9 +262,8 @@ struct KDTree *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md); bool BKE_object_modifier_use_time(struct Object *ob, struct ModifierData *md);
bool BKE_object_modifier_update_subframe(struct Scene *scene, struct Object *ob, bool update_mesh, bool BKE_object_modifier_update_subframe(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
int parent_recursion, float frame, bool update_mesh, int parent_recursion, float frame, int type);
int type);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -58,6 +58,7 @@ struct StrokeCache;
struct Tex; struct Tex;
struct ImagePool; struct ImagePool;
struct UnifiedPaintSettings; struct UnifiedPaintSettings;
struct EvaluationContext;
enum OverlayFlags; enum OverlayFlags;
@@ -208,7 +209,7 @@ void BKE_sculptsession_free(struct Object *ob);
void BKE_sculptsession_free_deformMats(struct SculptSession *ss); void BKE_sculptsession_free_deformMats(struct SculptSession *ss);
void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder); void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
void BKE_sculptsession_bm_to_me_for_render(struct Object *object); void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
void BKE_sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob, void BKE_sculpt_update_mesh_elements(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Sculpt *sd, struct Object *ob,
bool need_pmap, bool need_mask); bool need_pmap, bool need_mask);
struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob); struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob);
int BKE_sculpt_mask_layers_ensure(struct Object *ob, int BKE_sculpt_mask_layers_ensure(struct Object *ob,

View File

@@ -62,6 +62,7 @@ struct RNG;
struct BVHTreeRay; struct BVHTreeRay;
struct BVHTreeRayHit; struct BVHTreeRayHit;
struct EdgeHash; struct EdgeHash;
struct EvaluationContext;
#define PARTICLE_COLLISION_MAX_COLLISIONS 10 #define PARTICLE_COLLISION_MAX_COLLISIONS 10
@@ -77,6 +78,7 @@ struct EdgeHash;
/* common stuff that many particle functions need */ /* common stuff that many particle functions need */
typedef struct ParticleSimulationData { typedef struct ParticleSimulationData {
struct EvaluationContext *eval_ctx;
struct Scene *scene; struct Scene *scene;
struct Object *ob; struct Object *ob;
struct ParticleSystem *psys; struct ParticleSystem *psys;
@@ -332,9 +334,9 @@ void psys_reset(struct ParticleSystem *psys, int mode);
void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params); void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params);
void psys_cache_paths(struct ParticleSimulationData *sim, float cfra, const bool use_render_params); void psys_cache_paths(struct ParticleSimulationData *sim, float cfra, const bool use_render_params);
void psys_cache_edit_paths(struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params); void psys_cache_edit_paths(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params);
void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, const bool editupdate, const bool use_render_params); void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, const bool editupdate, const bool use_render_params);
int do_guides(struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time); int do_guides(struct EvaluationContext *eval_ctx, struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int pa_num, float time);
void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors); void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors);
float psys_get_timestep(struct ParticleSimulationData *sim); float psys_get_timestep(struct ParticleSimulationData *sim);
float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime); float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime);
@@ -366,7 +368,7 @@ void psys_tasks_create(struct ParticleThreadContext *ctx, int startpart, int end
void psys_tasks_free(struct ParticleTask *tasks, int numtasks); void psys_tasks_free(struct ParticleTask *tasks, int numtasks);
void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]); void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
void psys_apply_hair_lattice(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys); void psys_apply_hair_lattice(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* particle_system.c */ /* particle_system.c */
struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt); struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt);
@@ -381,7 +383,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 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 EvaluationContext *eval_ctx, 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 */ /* 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); typedef void (*ParticleSystemIDFunc)(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, int cb_flag);

View File

@@ -37,6 +37,7 @@
struct RigidBodyWorld; struct RigidBodyWorld;
struct RigidBodyOb; struct RigidBodyOb;
struct EvaluationContext;
struct Scene; struct Scene;
struct Object; struct Object;
@@ -99,14 +100,12 @@ void BKE_rigidbody_aftertrans_update(struct Object *ob, float loc[3], float rot[
void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object *ob, float ctime); void BKE_rigidbody_sync_transforms(struct RigidBodyWorld *rbw, struct Object *ob, float ctime);
bool BKE_rigidbody_check_sim_running(struct RigidBodyWorld *rbw, float ctime); bool BKE_rigidbody_check_sim_running(struct RigidBodyWorld *rbw, float ctime);
void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw); void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw);
void BKE_rigidbody_rebuild_world(struct Scene *scene, float ctime); void BKE_rigidbody_rebuild_world(struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
void BKE_rigidbody_do_simulation(struct Scene *scene, float ctime); void BKE_rigidbody_do_simulation(struct EvaluationContext *eval_ctx, struct Scene *scene, float ctime);
/* -------------------- */ /* -------------------- */
/* Depsgraph evaluation */ /* Depsgraph evaluation */
struct EvaluationContext;
void BKE_rigidbody_rebuild_sim(struct EvaluationContext *eval_ctx, void BKE_rigidbody_rebuild_sim(struct EvaluationContext *eval_ctx,
struct Scene *scene); struct Scene *scene);

View File

@@ -421,7 +421,7 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seq
/* view3d draw callback, run when not in background view */ /* view3d draw callback, run when not in background view */
typedef struct ImBuf *(*SequencerDrawView)( typedef struct ImBuf *(*SequencerDrawView)(
struct Scene *, struct SceneLayer *sl, struct Object *, int, int, struct EvaluationContext *eval_ctx, struct Scene *, struct SceneLayer *sl, struct Object *, int, int,
unsigned int, int, bool, bool, bool, unsigned int, int, bool, bool, bool,
int, int, bool, const char *, int, int, bool, const char *,
struct GPUFX *, struct GPUOffScreen *, char[256]); struct GPUFX *, struct GPUOffScreen *, char[256]);

View File

@@ -35,7 +35,9 @@
typedef float (*bresenham_callback)(float *result, float *input, int res[3], int *pixel, float *tRay, float correct); typedef float (*bresenham_callback)(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct SceneLayer *sl, struct Object *ob, struct DerivedMesh *dm); struct DerivedMesh *smokeModifier_do(struct SmokeModifierData *smd, struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct Object *ob, struct DerivedMesh *dm);
void smoke_reallocate_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old); void smoke_reallocate_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);
void smoke_reallocate_highres_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old); void smoke_reallocate_highres_fluid(struct SmokeDomainSettings *sds, float dx, int res[3], int free_old);

View File

@@ -34,6 +34,7 @@
struct Object; struct Object;
struct Scene; struct Scene;
struct SoftBody; struct SoftBody;
struct EvaluationContext;
typedef struct BodyPoint { typedef struct BodyPoint {
float origS[3], origE[3], origT[3], pos[3], vec[3], force[3]; float origS[3], origE[3], origT[3], pos[3], vec[3], force[3];
@@ -59,7 +60,7 @@ extern void sbFree(struct SoftBody *sb);
extern void sbFreeSimulation(struct SoftBody *sb); extern void sbFreeSimulation(struct SoftBody *sb);
/* do one simul step, reading and writing vertex locs from given array */ /* do one simul step, reading and writing vertex locs from given array */
extern void sbObjectStep(struct Scene *scene, struct SceneLayer *sl, struct Object *ob, extern void sbObjectStep(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
float framnr, float (*vertexCos)[3], int numVerts); float framnr, float (*vertexCos)[3], int numVerts);
/* makes totally fresh start situation, resets time */ /* makes totally fresh start situation, resets time */

View File

@@ -47,6 +47,7 @@ struct MovieDistortion;
struct Camera; struct Camera;
struct Object; struct Object;
struct Scene; struct Scene;
struct EvaluationContext;
struct rcti; struct rcti;
/* **** Common functions **** */ /* **** Common functions **** */

View File

@@ -1126,7 +1126,7 @@ DerivedMesh *mesh_create_derived(Mesh *me, float (*vertCos)[3])
} }
DerivedMesh *mesh_create_derived_for_modifier( DerivedMesh *mesh_create_derived_for_modifier(
Scene *scene, Object *ob, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
ModifierData *md, int build_shapekey_layers) ModifierData *md, int build_shapekey_layers)
{ {
Mesh *me = ob->data; Mesh *me = ob->data;
@@ -1152,7 +1152,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
int numVerts; int numVerts;
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts); float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, 0); modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, 0);
dm = mesh_create_derived(me, deformedVerts); dm = mesh_create_derived(me, deformedVerts);
if (build_shapekey_layers) if (build_shapekey_layers)
@@ -1166,7 +1166,7 @@ DerivedMesh *mesh_create_derived_for_modifier(
if (build_shapekey_layers) if (build_shapekey_layers)
add_shapekey_layers(tdm, me, ob); add_shapekey_layers(tdm, me, ob);
dm = modwrap_applyModifier(md, ob, tdm, 0); dm = modwrap_applyModifier(md, eval_ctx, ob, tdm, 0);
ASSERT_IS_VALID_DM(dm); ASSERT_IS_VALID_DM(dm);
if (tdm != dm) tdm->release(tdm); if (tdm != dm) tdm->release(tdm);
@@ -1732,7 +1732,7 @@ static void dm_ensure_display_normals(DerivedMesh *dm)
* - apply deform modifiers and input vertexco * - apply deform modifiers and input vertexco
*/ */
static void mesh_calc_modifiers( static void mesh_calc_modifiers(
Scene *scene, Object *ob, float (*inputVertexCos)[3], struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (*inputVertexCos)[3],
const bool useRenderParams, int useDeform, const bool useRenderParams, int useDeform,
const bool need_mapping, CustomDataMask dataMask, const bool need_mapping, CustomDataMask dataMask,
const int index, const bool useCache, const bool build_shapekey_layers, const int index, const bool useCache, const bool build_shapekey_layers,
@@ -1843,7 +1843,7 @@ static void mesh_calc_modifiers(
if (!deformedVerts) if (!deformedVerts)
deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts); deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
modwrap_deformVerts(md, ob, NULL, deformedVerts, numVerts, deform_app_flags); modwrap_deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, deform_app_flags);
} }
else { else {
break; break;
@@ -1984,7 +1984,7 @@ static void mesh_calc_modifiers(
} }
} }
modwrap_deformVerts(md, ob, dm, deformedVerts, numVerts, deform_app_flags); modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, deform_app_flags);
} }
else { else {
DerivedMesh *ndm; DerivedMesh *ndm;
@@ -2059,7 +2059,7 @@ static void mesh_calc_modifiers(
} }
} }
ndm = modwrap_applyModifier(md, ob, dm, app_flags); ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, app_flags);
ASSERT_IS_VALID_DM(ndm); ASSERT_IS_VALID_DM(ndm);
if (ndm) { if (ndm) {
@@ -2086,7 +2086,7 @@ static void mesh_calc_modifiers(
(mti->requiredDataMask ? (mti->requiredDataMask ?
mti->requiredDataMask(ob, md) : 0)); mti->requiredDataMask(ob, md) : 0));
ndm = modwrap_applyModifier(md, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO); ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
ASSERT_IS_VALID_DM(ndm); ASSERT_IS_VALID_DM(ndm);
if (ndm) { if (ndm) {
@@ -2104,7 +2104,7 @@ static void mesh_calc_modifiers(
nextmask &= ~CD_MASK_CLOTH_ORCO; nextmask &= ~CD_MASK_CLOTH_ORCO;
DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX); DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX);
ndm = modwrap_applyModifier(md, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO); ndm = modwrap_applyModifier(md, eval_ctx, ob, clothorcodm, (app_flags & ~MOD_APPLY_USECACHE) | MOD_APPLY_ORCO);
ASSERT_IS_VALID_DM(ndm); ASSERT_IS_VALID_DM(ndm);
if (ndm) { if (ndm) {
@@ -2288,8 +2288,8 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *
} }
static void editbmesh_calc_modifiers( static void editbmesh_calc_modifiers(
Scene *scene, Object *ob, BMEditMesh *em, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
CustomDataMask dataMask, BMEditMesh *em, CustomDataMask dataMask,
/* return args */ /* return args */
DerivedMesh **r_cage, DerivedMesh **r_final) DerivedMesh **r_cage, DerivedMesh **r_final)
{ {
@@ -2376,9 +2376,9 @@ static void editbmesh_calc_modifiers(
} }
if (mti->deformVertsEM) if (mti->deformVertsEM)
modwrap_deformVertsEM(md, ob, em, dm, deformedVerts, numVerts); modwrap_deformVertsEM(md, eval_ctx, ob, em, dm, deformedVerts, numVerts);
else else
modwrap_deformVerts(md, ob, dm, deformedVerts, numVerts, 0); modwrap_deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
} }
else { else {
DerivedMesh *ndm; DerivedMesh *ndm;
@@ -2423,10 +2423,10 @@ static void editbmesh_calc_modifiers(
DM_set_only_copy(orcodm, mask | CD_MASK_ORIGINDEX); DM_set_only_copy(orcodm, mask | CD_MASK_ORIGINDEX);
if (mti->applyModifierEM) { if (mti->applyModifierEM) {
ndm = modwrap_applyModifierEM(md, ob, em, orcodm, MOD_APPLY_ORCO); ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, orcodm, MOD_APPLY_ORCO);
} }
else { else {
ndm = modwrap_applyModifier(md, ob, orcodm, MOD_APPLY_ORCO); ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, MOD_APPLY_ORCO);
} }
ASSERT_IS_VALID_DM(ndm); ASSERT_IS_VALID_DM(ndm);
@@ -2451,9 +2451,9 @@ static void editbmesh_calc_modifiers(
} }
if (mti->applyModifierEM) if (mti->applyModifierEM)
ndm = modwrap_applyModifierEM(md, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU); ndm = modwrap_applyModifierEM(md, eval_ctx, ob, em, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
else else
ndm = modwrap_applyModifier(md, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU); ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, MOD_APPLY_USECACHE | MOD_APPLY_ALLOW_GPU);
ASSERT_IS_VALID_DM(ndm); ASSERT_IS_VALID_DM(ndm);
if (ndm) { if (ndm) {
@@ -2618,7 +2618,7 @@ static bool calc_modifiers_skip_orco(Scene *scene,
#endif #endif
static void mesh_build_data( static void mesh_build_data(
Scene *scene, Object *ob, CustomDataMask dataMask, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask,
const bool build_shapekey_layers, const bool need_mapping) const bool build_shapekey_layers, const bool need_mapping)
{ {
BLI_assert(ob->type == OB_MESH); BLI_assert(ob->type == OB_MESH);
@@ -2633,7 +2633,7 @@ static void mesh_build_data(
#endif #endif
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers, eval_ctx, scene, ob, NULL, false, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
true, true,
&ob->derivedDeform, &ob->derivedFinal); &ob->derivedDeform, &ob->derivedFinal);
@@ -2648,13 +2648,13 @@ static void mesh_build_data(
/* create PBVH immediately (would be created on the fly too, /* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */ * but this avoids waiting on first stroke) */
BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, false, false); BKE_sculpt_update_mesh_elements(eval_ctx, scene, scene->toolsettings->sculpt, ob, false, false);
} }
BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS));
} }
static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask) static void editbmesh_build_data(struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
{ {
BKE_object_free_derived_caches(obedit); BKE_object_free_derived_caches(obedit);
BKE_object_sculpt_modifiers_changed(obedit); BKE_object_sculpt_modifiers_changed(obedit);
@@ -2668,7 +2668,7 @@ static void editbmesh_build_data(Scene *scene, Object *obedit, BMEditMesh *em, C
#endif #endif
editbmesh_calc_modifiers( editbmesh_calc_modifiers(
scene, obedit, em, dataMask, eval_ctx, scene, obedit, em, dataMask,
&em->derivedCage, &em->derivedFinal); &em->derivedCage, &em->derivedFinal);
DM_set_object_boundbox(obedit, em->derivedFinal); DM_set_object_boundbox(obedit, em->derivedFinal);
@@ -2721,23 +2721,23 @@ static CustomDataMask object_get_datamask(const Scene *scene, Object *ob, bool *
} }
void makeDerivedMesh( void makeDerivedMesh(
Scene *scene, Object *ob, BMEditMesh *em, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
CustomDataMask dataMask, const bool build_shapekey_layers) CustomDataMask dataMask, const bool build_shapekey_layers)
{ {
bool need_mapping; bool need_mapping;
dataMask |= object_get_datamask(scene, ob, &need_mapping); dataMask |= object_get_datamask(scene, ob, &need_mapping);
if (em) { if (em) {
editbmesh_build_data(scene, ob, em, dataMask); editbmesh_build_data(eval_ctx, scene, ob, em, dataMask);
} }
else { else {
mesh_build_data(scene, ob, dataMask, build_shapekey_layers, need_mapping); mesh_build_data(eval_ctx, scene, ob, dataMask, build_shapekey_layers, need_mapping);
} }
} }
/***/ /***/
DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dataMask) DerivedMesh *mesh_get_derived_final(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
{ {
/* if there's no derived mesh or the last data mask used doesn't include /* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh * the data we need, rebuild the derived mesh
@@ -2749,14 +2749,14 @@ DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dat
((dataMask & ob->lastDataMask) != dataMask) || ((dataMask & ob->lastDataMask) != dataMask) ||
(need_mapping != ob->lastNeedMapping)) (need_mapping != ob->lastNeedMapping))
{ {
mesh_build_data(scene, ob, dataMask, false, need_mapping); mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
} }
if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); } if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
return ob->derivedFinal; return ob->derivedFinal;
} }
DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask dataMask) DerivedMesh *mesh_get_derived_deform(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
{ {
/* if there's no derived mesh or the last data mask used doesn't include /* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh * the data we need, rebuild the derived mesh
@@ -2769,37 +2769,37 @@ DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask da
((dataMask & ob->lastDataMask) != dataMask) || ((dataMask & ob->lastDataMask) != dataMask) ||
(need_mapping != ob->lastNeedMapping)) (need_mapping != ob->lastNeedMapping))
{ {
mesh_build_data(scene, ob, dataMask, false, need_mapping); mesh_build_data(eval_ctx, scene, ob, dataMask, false, need_mapping);
} }
return ob->derivedDeform; return ob->derivedDeform;
} }
DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask dataMask) DerivedMesh *mesh_create_derived_render(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask)
{ {
DerivedMesh *final; DerivedMesh *final;
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false, eval_ctx, scene, ob, NULL, true, 1, false, dataMask, -1, false, false, false,
NULL, &final); NULL, &final);
return final; return final;
} }
DerivedMesh *mesh_create_derived_index_render(Scene *scene, Object *ob, CustomDataMask dataMask, int index) DerivedMesh *mesh_create_derived_index_render(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, CustomDataMask dataMask, int index)
{ {
DerivedMesh *final; DerivedMesh *final;
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, NULL, true, 1, false, dataMask, index, false, false, false, eval_ctx, scene, ob, NULL, true, 1, false, dataMask, index, false, false, false,
NULL, &final); NULL, &final);
return final; return final;
} }
DerivedMesh *mesh_create_derived_view( DerivedMesh *mesh_create_derived_view(
Scene *scene, Object *ob, struct EvaluationContext *eval_ctx, Scene *scene,
CustomDataMask dataMask) Object *ob, CustomDataMask dataMask)
{ {
DerivedMesh *final; DerivedMesh *final;
@@ -2810,7 +2810,7 @@ DerivedMesh *mesh_create_derived_view(
ob->transflag |= OB_NO_PSYS_UPDATE; ob->transflag |= OB_NO_PSYS_UPDATE;
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false, eval_ctx, scene, ob, NULL, false, 1, false, dataMask, -1, false, false, false,
NULL, &final); NULL, &final);
ob->transflag &= ~OB_NO_PSYS_UPDATE; ob->transflag &= ~OB_NO_PSYS_UPDATE;
@@ -2819,53 +2819,53 @@ DerivedMesh *mesh_create_derived_view(
} }
DerivedMesh *mesh_create_derived_no_deform( DerivedMesh *mesh_create_derived_no_deform(
Scene *scene, Object *ob, float (*vertCos)[3], struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
CustomDataMask dataMask) float (*vertCos)[3], CustomDataMask dataMask)
{ {
DerivedMesh *final; DerivedMesh *final;
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false, eval_ctx, scene, ob, vertCos, false, 0, false, dataMask, -1, false, false, false,
NULL, &final); NULL, &final);
return final; return final;
} }
DerivedMesh *mesh_create_derived_no_virtual( DerivedMesh *mesh_create_derived_no_virtual(
Scene *scene, Object *ob, float (*vertCos)[3], struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
CustomDataMask dataMask) float (*vertCos)[3], CustomDataMask dataMask)
{ {
DerivedMesh *final; DerivedMesh *final;
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false, eval_ctx, scene, ob, vertCos, false, -1, false, dataMask, -1, false, false, false,
NULL, &final); NULL, &final);
return final; return final;
} }
DerivedMesh *mesh_create_derived_physics( DerivedMesh *mesh_create_derived_physics(
Scene *scene, Object *ob, float (*vertCos)[3], struct EvaluationContext *eval_ctx, Scene *scene, Object *ob,
CustomDataMask dataMask) float (*vertCos)[3], CustomDataMask dataMask)
{ {
DerivedMesh *final; DerivedMesh *final;
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false, eval_ctx, scene, ob, vertCos, false, -1, true, dataMask, -1, false, false, false,
NULL, &final); NULL, &final);
return final; return final;
} }
DerivedMesh *mesh_create_derived_no_deform_render( DerivedMesh *mesh_create_derived_no_deform_render(
Scene *scene, Object *ob, struct EvaluationContext *eval_ctx, Scene *scene,
float (*vertCos)[3], Object *ob, float (*vertCos)[3],
CustomDataMask dataMask) CustomDataMask dataMask)
{ {
DerivedMesh *final; DerivedMesh *final;
mesh_calc_modifiers( mesh_calc_modifiers(
scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false, eval_ctx, scene, ob, vertCos, true, 0, false, dataMask, -1, false, false, false,
NULL, &final); NULL, &final);
return final; return final;
@@ -2874,7 +2874,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(
/***/ /***/
DerivedMesh *editbmesh_get_derived_cage_and_final( DerivedMesh *editbmesh_get_derived_cage_and_final(
Scene *scene, Object *obedit, BMEditMesh *em, struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em,
CustomDataMask dataMask, CustomDataMask dataMask,
/* return args */ /* return args */
DerivedMesh **r_final) DerivedMesh **r_final)
@@ -2887,7 +2887,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
if (!em->derivedCage || if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask) (em->lastDataMask & dataMask) != dataMask)
{ {
editbmesh_build_data(scene, obedit, em, dataMask); editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
} }
*r_final = em->derivedFinal; *r_final = em->derivedFinal;
@@ -2895,7 +2895,7 @@ DerivedMesh *editbmesh_get_derived_cage_and_final(
return em->derivedCage; return em->derivedCage;
} }
DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask) DerivedMesh *editbmesh_get_derived_cage(struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
{ {
/* if there's no derived mesh or the last data mask used doesn't include /* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh * the data we need, rebuild the derived mesh
@@ -2905,7 +2905,7 @@ DerivedMesh *editbmesh_get_derived_cage(Scene *scene, Object *obedit, BMEditMesh
if (!em->derivedCage || if (!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask) (em->lastDataMask & dataMask) != dataMask)
{ {
editbmesh_build_data(scene, obedit, em, dataMask); editbmesh_build_data(eval_ctx, scene, obedit, em, dataMask);
} }
return em->derivedCage; return em->derivedCage;

View File

@@ -43,6 +43,7 @@
#include "DNA_key_types.h" #include "DNA_key_types.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include "BKE_context.h"
#include "BKE_curve.h" #include "BKE_curve.h"
#include "BKE_global.h" #include "BKE_global.h"
#include "BKE_key.h" #include "BKE_key.h"
@@ -282,10 +283,11 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
*/ */
/* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */ /* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */
static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) static void motionpaths_calc_optimise_depsgraph(bContext *C, Scene *scene, ListBase *targets)
{ {
BaseLegacy *base, *baseNext; BaseLegacy *base, *baseNext;
MPathTarget *mpt; MPathTarget *mpt;
Main *bmain = CTX_data_main(C);
/* make sure our temp-tag isn't already in use */ /* make sure our temp-tag isn't already in use */
for (base = scene->base.first; base; base = base->next) for (base = scene->base.first; base; base = base->next)
@@ -309,7 +311,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
} }
/* "brew me a list that's sorted a bit faster now depsy" */ /* "brew me a list that's sorted a bit faster now depsy" */
DEG_scene_relations_rebuild(G.main, scene); DEG_scene_relations_rebuild(bmain, scene);
} }
/* update scene for current frame */ /* update scene for current frame */
@@ -373,7 +375,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
* - recalc: whether we need to * - recalc: whether we need to
*/ */
/* TODO: include reports pointer? */ /* TODO: include reports pointer? */
void animviz_calc_motionpaths(Scene *scene, ListBase *targets) void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
{ {
MPathTarget *mpt; MPathTarget *mpt;
int sfra, efra; int sfra, efra;
@@ -399,7 +401,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
/* optimize the depsgraph for faster updates */ /* optimize the depsgraph for faster updates */
/* TODO: whether this is used should depend on some setting for the level of optimizations used */ /* TODO: whether this is used should depend on some setting for the level of optimizations used */
motionpaths_calc_optimise_depsgraph(scene, targets); motionpaths_calc_optimise_depsgraph(C, scene, targets);
/* calculate path over requested range */ /* calculate path over requested range */
for (CFRA = sfra; CFRA <= efra; CFRA++) { for (CFRA = sfra; CFRA <= efra; CFRA++) {

View File

@@ -1445,13 +1445,13 @@ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], fl
copy_v3_v3(outloc, nLocMat[3]); copy_v3_v3(outloc, nLocMat[3]);
} }
void BKE_armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]) void BKE_armature_mat_pose_to_bone_ex(struct EvaluationContext *eval_ctx, Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
{ {
bPoseChannel work_pchan = *pchan; bPoseChannel work_pchan = *pchan;
/* recalculate pose matrix with only parent transformations, /* recalculate pose matrix with only parent transformations,
* bone loc/sca/rot is ignored, scene and frame are not used. */ * bone loc/sca/rot is ignored, scene and frame are not used. */
BKE_pose_where_is_bone(NULL, ob, &work_pchan, 0.0f, false); BKE_pose_where_is_bone(eval_ctx, NULL, ob, &work_pchan, 0.0f, false);
/* find the matrix, need to remove the bone transforms first so this is /* find the matrix, need to remove the bone transforms first so this is
* calculated as a matrix to set rather then a difference ontop of whats * calculated as a matrix to set rather then a difference ontop of whats
@@ -2178,7 +2178,7 @@ void BKE_pose_where_is_bone_tail(bPoseChannel *pchan)
/* pchan is validated, as having bone and parent pointer /* pchan is validated, as having bone and parent pointer
* 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers. * 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers.
*/ */
void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, bool do_extra) void BKE_pose_where_is_bone(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
{ {
/* This gives a chan_mat with actions (ipos) results. */ /* This gives a chan_mat with actions (ipos) results. */
if (do_extra) if (do_extra)
@@ -2217,7 +2217,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); cob = BKE_constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
/* Solve PoseChannel's Constraints */ /* Solve PoseChannel's Constraints */
BKE_constraints_solve(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */ BKE_constraints_solve(eval_ctx, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
/* cleanup after Constraint Solving /* cleanup after Constraint Solving
* - applies matrix back to pchan, and frees temporary struct used * - applies matrix back to pchan, and frees temporary struct used
@@ -2239,7 +2239,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float
/* This only reads anim data from channels, and writes to channels */ /* This only reads anim data from channels, and writes to channels */
/* This is the only function adding poses */ /* This is the only function adding poses */
void BKE_pose_where_is(Scene *scene, Object *ob) void BKE_pose_where_is(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{ {
bArmature *arm; bArmature *arm;
Bone *bone; Bone *bone;
@@ -2278,7 +2278,7 @@ void BKE_pose_where_is(Scene *scene, Object *ob)
} }
/* 2a. construct the IK tree (standard IK) */ /* 2a. construct the IK tree (standard IK) */
BIK_initialize_tree(scene, ob, ctime); BIK_initialize_tree(eval_ctx, scene, ob, ctime);
/* 2b. construct the Spline IK trees /* 2b. construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able * - this is not integrated as an IK plugin, since it should be able
@@ -2290,15 +2290,15 @@ void BKE_pose_where_is(Scene *scene, Object *ob)
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* 4a. if we find an IK root, we handle it separated */ /* 4a. if we find an IK root, we handle it separated */
if (pchan->flag & POSE_IKTREE) { if (pchan->flag & POSE_IKTREE) {
BIK_execute_tree(scene, ob, pchan, ctime); BIK_execute_tree(eval_ctx, scene, ob, pchan, ctime);
} }
/* 4b. if we find a Spline IK root, we handle it separated too */ /* 4b. if we find a Spline IK root, we handle it separated too */
else if (pchan->flag & POSE_IKSPLINE) { else if (pchan->flag & POSE_IKSPLINE) {
BKE_splineik_execute_tree(scene, ob, pchan, ctime); BKE_splineik_execute_tree(eval_ctx, scene, ob, pchan, ctime);
} }
/* 5. otherwise just call the normal solver */ /* 5. otherwise just call the normal solver */
else if (!(pchan->flag & POSE_DONE)) { else if (!(pchan->flag & POSE_DONE)) {
BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
} }
} }
/* 6. release the IK tree */ /* 6. release the IK tree */

View File

@@ -113,9 +113,11 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
* currently for paths to work it needs to go through the bevlist/displist system (ton) * currently for paths to work it needs to go through the bevlist/displist system (ton)
*/ */
/* TODO: Make sure this doesn't crash. */
#if 0
/* only happens on reload file, but violates depsgraph still... fix! */ /* only happens on reload file, but violates depsgraph still... fix! */
if (ELEM(NULL, ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) { if (ELEM(NULL, ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
BKE_displist_make_curveTypes(scene, ikData->tar, 0); BKE_displist_make_curveTypes(eval_ctx, scene, ikData->tar, 0);
/* path building may fail in EditMode after removing verts [#33268]*/ /* path building may fail in EditMode after removing verts [#33268]*/
if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) { if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
@@ -123,6 +125,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
return; return;
} }
} }
#endif
} }
/* find the root bone and the chain of bones from the root to the tip /* find the root bone and the chain of bones from the root to the tip
@@ -261,7 +264,7 @@ static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime))
/* ----------- */ /* ----------- */
/* Evaluate spline IK for a given bone */ /* Evaluate spline IK for a given bone */
static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan, static void splineik_evaluate_bone(struct EvaluationContext *eval_ctx, tSplineIK_Tree *tree, Scene *scene, Object *ob, bPoseChannel *pchan,
int index, float ctime) int index, float ctime)
{ {
bSplineIKConstraint *ikData = tree->ikData; bSplineIKConstraint *ikData = tree->ikData;
@@ -269,7 +272,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
float splineVec[3], scaleFac, radius = 1.0f; float splineVec[3], scaleFac, radius = 1.0f;
/* firstly, calculate the bone matrix the standard way, since this is needed for roll control */ /* firstly, calculate the bone matrix the standard way, since this is needed for roll control */
BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
copy_v3_v3(poseHead, pchan->pose_head); copy_v3_v3(poseHead, pchan->pose_head);
copy_v3_v3(poseTail, pchan->pose_tail); copy_v3_v3(poseTail, pchan->pose_tail);
@@ -511,7 +514,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
} }
/* Evaluate the chain starting from the nominated bone */ /* Evaluate the chain starting from the nominated bone */
static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime) static void splineik_execute_tree(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{ {
tSplineIK_Tree *tree; tSplineIK_Tree *tree;
@@ -525,7 +528,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_
*/ */
for (i = tree->chainlen - 1; i >= 0; i--) { for (i = tree->chainlen - 1; i >= 0; i--) {
bPoseChannel *pchan = tree->chain[i]; bPoseChannel *pchan = tree->chain[i];
splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime); splineik_evaluate_bone(eval_ctx, tree, scene, ob, pchan, i, ctime);
} }
/* free the tree info specific to SplineIK trees now */ /* free the tree info specific to SplineIK trees now */
@@ -544,14 +547,14 @@ void BKE_pose_splineik_init_tree(Scene *scene, Object *ob, float ctime)
splineik_init_tree(scene, ob, ctime); splineik_init_tree(scene, ob, ctime);
} }
void BKE_splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime) void BKE_splineik_execute_tree(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
{ {
splineik_execute_tree(scene, ob, pchan_root, ctime); splineik_execute_tree(eval_ctx, scene, ob, pchan_root, ctime);
} }
/* *************** Depsgraph evaluation callbacks ************ */ /* *************** Depsgraph evaluation callbacks ************ */
void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx), void BKE_pose_eval_init(struct EvaluationContext *eval_ctx,
Scene *scene, Scene *scene,
Object *ob, Object *ob,
bPose *pose) bPose *pose)
@@ -576,7 +579,7 @@ void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
} }
/* 2a. construct the IK tree (standard IK) */ /* 2a. construct the IK tree (standard IK) */
BIK_initialize_tree(scene, ob, ctime); BIK_initialize_tree(eval_ctx, scene, ob, ctime);
/* 2b. construct the Spline IK trees /* 2b. construct the Spline IK trees
* - this is not integrated as an IK plugin, since it should be able * - this is not integrated as an IK plugin, since it should be able
@@ -585,7 +588,7 @@ void BKE_pose_eval_init(struct EvaluationContext *UNUSED(eval_ctx),
BKE_pose_splineik_init_tree(scene, ob, ctime); BKE_pose_splineik_init_tree(scene, ob, ctime);
} }
void BKE_pose_eval_bone(struct EvaluationContext *UNUSED(eval_ctx), void BKE_pose_eval_bone(struct EvaluationContext *eval_ctx,
Scene *scene, Scene *scene,
Object *ob, Object *ob,
bPoseChannel *pchan) bPoseChannel *pchan)
@@ -613,14 +616,14 @@ void BKE_pose_eval_bone(struct EvaluationContext *UNUSED(eval_ctx),
if ((pchan->flag & POSE_DONE) == 0) { if ((pchan->flag & POSE_DONE) == 0) {
/* TODO(sergey): Use time source node for time. */ /* TODO(sergey): Use time source node for time. */
float ctime = BKE_scene_frame_get(scene); /* not accurate... */ float ctime = BKE_scene_frame_get(scene); /* not accurate... */
BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
} }
} }
} }
} }
} }
void BKE_pose_constraints_evaluate(struct EvaluationContext *UNUSED(eval_ctx), void BKE_pose_constraints_evaluate(struct EvaluationContext *eval_ctx,
Scene *scene, Scene *scene,
Object *ob, Object *ob,
bPoseChannel *pchan) bPoseChannel *pchan)
@@ -636,7 +639,7 @@ void BKE_pose_constraints_evaluate(struct EvaluationContext *UNUSED(eval_ctx),
else { else {
if ((pchan->flag & POSE_DONE) == 0) { if ((pchan->flag & POSE_DONE) == 0) {
float ctime = BKE_scene_frame_get(scene); /* not accurate... */ float ctime = BKE_scene_frame_get(scene); /* not accurate... */
BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1);
} }
} }
} }
@@ -652,24 +655,24 @@ void BKE_pose_bone_done(struct EvaluationContext *UNUSED(eval_ctx),
} }
} }
void BKE_pose_iktree_evaluate(struct EvaluationContext *UNUSED(eval_ctx), void BKE_pose_iktree_evaluate(struct EvaluationContext *eval_ctx,
Scene *scene, Scene *scene,
Object *ob, Object *ob,
bPoseChannel *rootchan) bPoseChannel *rootchan)
{ {
float ctime = BKE_scene_frame_get(scene); /* not accurate... */ float ctime = BKE_scene_frame_get(scene); /* not accurate... */
DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name); DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
BIK_execute_tree(scene, ob, rootchan, ctime); BIK_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
} }
void BKE_pose_splineik_evaluate(struct EvaluationContext *UNUSED(eval_ctx), void BKE_pose_splineik_evaluate(struct EvaluationContext *eval_ctx,
Scene *scene, Scene *scene,
Object *ob, Object *ob,
bPoseChannel *rootchan) bPoseChannel *rootchan)
{ {
float ctime = BKE_scene_frame_get(scene); /* not accurate... */ float ctime = BKE_scene_frame_get(scene); /* not accurate... */
DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name); DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
BKE_splineik_execute_tree(scene, ob, rootchan, ctime); BKE_splineik_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
} }
void BKE_pose_eval_flush(struct EvaluationContext *UNUSED(eval_ctx), void BKE_pose_eval_flush(struct EvaluationContext *UNUSED(eval_ctx),

View File

@@ -132,6 +132,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
if (eff == NULL && gabr->ob) { if (eff == NULL && gabr->ob) {
memset(&temp_eff, 0, sizeof(EffectorCache)); memset(&temp_eff, 0, sizeof(EffectorCache));
temp_eff.ob = gabr->ob; temp_eff.ob = gabr->ob;
temp_eff.eval_ctx = bbd->sim->eval_ctx;
temp_eff.scene = bbd->sim->scene; temp_eff.scene = bbd->sim->scene;
eff = &temp_eff; eff = &temp_eff;
get_effector_data(eff, &efd, &epoint, 0); get_effector_data(eff, &efd, &epoint, 0);

View File

@@ -345,7 +345,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
return 1; return 1;
} }
static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr) static int do_step_cloth(struct EvaluationContext *eval_ctx, Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
{ {
ClothVertex *verts = NULL; ClothVertex *verts = NULL;
Cloth *cloth; Cloth *cloth;
@@ -370,7 +370,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
mul_m4_v3(ob->obmat, verts->xconst); mul_m4_v3(ob->obmat, verts->xconst);
} }
effectors = pdInitEffectors(clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true); effectors = pdInitEffectors(eval_ctx, clmd->scene, ob, NULL, clmd->sim_parms->effector_weights, true);
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH ) if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH )
cloth_update_verts ( ob, clmd, result ); cloth_update_verts ( ob, clmd, result );
@@ -400,7 +400,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
/************************************************ /************************************************
* clothModifier_do - main simulation function * clothModifier_do - main simulation function
************************************************/ ************************************************/
void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3]) void clothModifier_do(ClothModifierData *clmd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3])
{ {
PointCache *cache; PointCache *cache;
PTCacheID pid; PTCacheID pid;
@@ -489,7 +489,7 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
/* do simulation */ /* do simulation */
BKE_ptcache_validate(cache, framenr); BKE_ptcache_validate(cache, framenr);
if (!do_step_cloth(ob, clmd, dm, framenr)) { if (!do_step_cloth(eval_ctx, ob, clmd, dm, framenr)) {
BKE_ptcache_invalidate(cache); BKE_ptcache_invalidate(cache);
} }
else else

View File

@@ -689,7 +689,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = {
/* This function should be used for the get_target_matrix member of all /* This function should be used for the get_target_matrix member of all
* constraints that are not picky about what happens to their target matrix. * constraints that are not picky about what happens to their target matrix.
*/ */
static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) static void default_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
{ {
if (VALID_CONS_TARGET(ct)) if (VALID_CONS_TARGET(ct))
constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->flag, con->headtail); constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->flag, con->headtail);
@@ -1155,7 +1155,7 @@ static void kinematic_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
} }
} }
static void kinematic_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) static void kinematic_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{ {
bKinematicConstraint *data = con->data; bKinematicConstraint *data = con->data;
@@ -1242,7 +1242,7 @@ static void followpath_flush_tars(bConstraint *con, ListBase *list, bool no_copy
} }
} }
static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) static void followpath_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{ {
bFollowPathConstraint *data = con->data; bFollowPathConstraint *data = con->data;
@@ -1259,7 +1259,7 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
#ifdef CYCLIC_DEPENDENCY_WORKAROUND #ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (ct->tar->curve_cache == NULL) { if (ct->tar->curve_cache == NULL) {
BKE_displist_make_curveTypes(cob->scene, ct->tar, false); BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
} }
#endif #endif
@@ -2024,7 +2024,7 @@ static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userd
} }
/* Whether this approach is maintained remains to be seen (aligorith) */ /* Whether this approach is maintained remains to be seen (aligorith) */
static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) static void pycon_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{ {
#ifdef WITH_PYTHON #ifdef WITH_PYTHON
bPythonConstraint *data = con->data; bPythonConstraint *data = con->data;
@@ -2035,7 +2035,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa
/* special exception for curves - depsgraph issues */ /* special exception for curves - depsgraph issues */
if (ct->tar->type == OB_CURVE) { if (ct->tar->type == OB_CURVE) {
if (ct->tar->curve_cache == NULL) { if (ct->tar->curve_cache == NULL) {
BKE_displist_make_curveTypes(cob->scene, ct->tar, false); BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
} }
} }
#endif #endif
@@ -2142,7 +2142,7 @@ static void actcon_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
} }
} }
static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) static void actcon_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{ {
bActionConstraint *data = con->data; bActionConstraint *data = con->data;
@@ -3131,12 +3131,12 @@ static void clampto_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
} }
} }
static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) static void clampto_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{ {
#ifdef CYCLIC_DEPENDENCY_WORKAROUND #ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (VALID_CONS_TARGET(ct)) { if (VALID_CONS_TARGET(ct)) {
if (ct->tar->curve_cache == NULL) { if (ct->tar->curve_cache == NULL) {
BKE_displist_make_curveTypes(cob->scene, ct->tar, false); BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
} }
} }
#endif #endif
@@ -3474,7 +3474,7 @@ static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, bool no_copy
} }
static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) static void shrinkwrap_get_tarmat(struct EvaluationContext *UNUSED(eval_ctx), bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{ {
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data; bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
@@ -3806,12 +3806,12 @@ static void splineik_flush_tars(bConstraint *con, ListBase *list, bool no_copy)
} }
} }
static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) static void splineik_get_tarmat(struct EvaluationContext *eval_ctx, bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
{ {
#ifdef CYCLIC_DEPENDENCY_WORKAROUND #ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (VALID_CONS_TARGET(ct)) { if (VALID_CONS_TARGET(ct)) {
if (ct->tar->curve_cache == NULL) { if (ct->tar->curve_cache == NULL) {
BKE_displist_make_curveTypes(cob->scene, ct->tar, false); BKE_displist_make_curveTypes(eval_ctx, cob->scene, ct->tar, false);
} }
} }
#endif #endif
@@ -4858,7 +4858,7 @@ bool BKE_constraints_proxylocked_owner(Object *ob, bPoseChannel *pchan)
* None of the actual calculations of the matrices should be done here! Also, this function is * None of the actual calculations of the matrices should be done here! Also, this function is
* not to be used by any new constraints, particularly any that have multiple targets. * not to be used by any new constraints, particularly any that have multiple targets.
*/ */
void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime) void BKE_constraint_target_matrix_get(struct EvaluationContext *eval_ctx, Scene *scene, bConstraint *con, int index, short ownertype, void *ownerdata, float mat[4][4], float ctime)
{ {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL}; ListBase targets = {NULL, NULL};
@@ -4909,7 +4909,7 @@ void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index,
if (ct) { if (ct) {
if (cti->get_target_matrix) if (cti->get_target_matrix)
cti->get_target_matrix(con, cob, ct, ctime); cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
copy_m4_m4(mat, ct->matrix); copy_m4_m4(mat, ct->matrix);
} }
@@ -4925,7 +4925,7 @@ void BKE_constraint_target_matrix_get(Scene *scene, bConstraint *con, int index,
} }
/* Get the list of targets required for solving a constraint */ /* Get the list of targets required for solving a constraint */
void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime) void BKE_constraint_targets_for_solving_get(struct EvaluationContext *eval_ctx, bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime)
{ {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
@@ -4943,7 +4943,7 @@ void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob
*/ */
if (cti->get_target_matrix) { if (cti->get_target_matrix) {
for (ct = targets->first; ct; ct = ct->next) for (ct = targets->first; ct; ct = ct->next)
cti->get_target_matrix(con, cob, ct, ctime); cti->get_target_matrix(eval_ctx, con, cob, ct, ctime);
} }
else { else {
for (ct = targets->first; ct; ct = ct->next) for (ct = targets->first; ct; ct = ct->next)
@@ -4960,7 +4960,7 @@ void BKE_constraint_targets_for_solving_get(bConstraint *con, bConstraintOb *cob
* BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and * BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
* after running this function, to sort out cob * after running this function, to sort out cob
*/ */
void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime) void BKE_constraints_solve(struct EvaluationContext *eval_ctx, ListBase *conlist, bConstraintOb *cob, float ctime)
{ {
bConstraint *con; bConstraint *con;
float oldmat[4][4]; float oldmat[4][4];
@@ -4995,7 +4995,7 @@ void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime)
BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace, false); BKE_constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace, false);
/* prepare targets for constraint solving */ /* prepare targets for constraint solving */
BKE_constraint_targets_for_solving_get(con, cob, &targets, ctime); BKE_constraint_targets_for_solving_get(eval_ctx, con, cob, &targets, ctime);
/* Solve the constraint and put result in cob->matrix */ /* Solve the constraint and put result in cob->matrix */
cti->evaluate_constraint(con, cob, &targets); cti->evaluate_constraint(con, cob, &targets);

View File

@@ -1229,3 +1229,11 @@ Depsgraph *CTX_data_depsgraph(const bContext *C)
SceneLayer *scene_layer = CTX_data_scene_layer(C); SceneLayer *scene_layer = CTX_data_scene_layer(C);
return BKE_scene_get_depsgraph(scene, scene_layer); return BKE_scene_get_depsgraph(scene, scene_layer);
} }
void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
{
BLI_assert(C);
*eval_ctx = *CTX_data_main(C)->eval_ctx;
eval_ctx->scene_layer = CTX_data_scene_layer(C);
}

View File

@@ -99,7 +99,7 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
} }
/* disable subsurf temporal, get mapped cos, and enable it */ /* disable subsurf temporal, get mapped cos, and enable it */
float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3] float (*BKE_crazyspace_get_mapped_editverts(struct EvaluationContext *eval_ctx, Scene *scene, Object *obedit))[3]
{ {
Mesh *me = obedit->data; Mesh *me = obedit->data;
DerivedMesh *dm; DerivedMesh *dm;
@@ -109,13 +109,13 @@ float (*BKE_crazyspace_get_mapped_editverts(Scene *scene, Object *obedit))[3]
/* disable subsurf temporal, get mapped cos, and enable it */ /* disable subsurf temporal, get mapped cos, and enable it */
if (modifiers_disable_subsurf_temporary(obedit)) { if (modifiers_disable_subsurf_temporary(obedit)) {
/* need to make new derivemesh */ /* need to make new derivemesh */
makeDerivedMesh(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false); makeDerivedMesh(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, false);
} }
/* now get the cage */ /* now get the cage */
vertexcos = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map"); vertexcos = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map");
dm = editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH); dm = editbmesh_get_derived_cage(eval_ctx, scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH);
mesh_get_mapped_verts_coords(dm, vertexcos, nverts); mesh_get_mapped_verts_coords(dm, vertexcos, nverts);
@@ -250,7 +250,7 @@ void BKE_crazyspace_set_quats_mesh(Mesh *me, float (*origcos)[3], float (*mapped
/** returns an array of deform matrices for crazyspace correction, and the /** returns an array of deform matrices for crazyspace correction, and the
* number of modifiers left */ * number of modifiers left */
int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob, BMEditMesh *em, int BKE_crazyspace_get_first_deform_matrices_editbmesh(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, BMEditMesh *em,
float (**deformmats)[3][3], float (**deformcos)[3]) float (**deformmats)[3][3], float (**deformcos)[3])
{ {
ModifierData *md; ModifierData *md;
@@ -290,7 +290,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob,
unit_m3(defmats[a]); unit_m3(defmats[a]);
} }
mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats, mti->deformMatricesEM(md, eval_ctx, ob, em, dm, deformedVerts, defmats,
numVerts); numVerts);
} }
else else
@@ -310,7 +310,7 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(Scene *scene, Object *ob,
return numleft; return numleft;
} }
int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]) int BKE_sculpt_get_first_deform_matrices(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{ {
ModifierData *md; ModifierData *md;
DerivedMesh *dm; DerivedMesh *dm;
@@ -346,7 +346,7 @@ int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**defo
unit_m3(defmats[a]); unit_m3(defmats[a]);
} }
if (mti->deformMatrices) mti->deformMatrices(md, ob, dm, deformedVerts, defmats, numVerts); if (mti->deformMatrices) mti->deformMatrices(md, eval_ctx, ob, dm, deformedVerts, defmats, numVerts);
else break; else break;
} }
} }
@@ -369,9 +369,9 @@ int BKE_sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**defo
return numleft; return numleft;
} }
void BKE_crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]) void BKE_crazyspace_build_sculpt(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
{ {
int totleft = BKE_sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos); int totleft = BKE_sculpt_get_first_deform_matrices(eval_ctx, scene, ob, deformmats, deformcos);
if (totleft) { if (totleft) {
/* there are deformation modifier which doesn't support deformation matrices /* there are deformation modifier which doesn't support deformation matrices
@@ -396,7 +396,7 @@ void BKE_crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[
if (mti->deformMatrices && !deformed) if (mti->deformMatrices && !deformed)
continue; continue;
mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0); mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, me->totvert, 0);
deformed = 1; deformed = 1;
} }
} }

View File

@@ -1625,7 +1625,7 @@ float *BKE_curve_surf_make_orco(Object *ob)
/* NOTE: This routine is tied to the order of vertex /* NOTE: This routine is tied to the order of vertex
* built by displist and as passed to the renderer. * built by displist and as passed to the renderer.
*/ */
float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts) float *BKE_curve_make_orco(EvaluationContext *eval_ctx, Scene *scene, Object *ob, int *r_numVerts)
{ {
Curve *cu = ob->data; Curve *cu = ob->data;
DispList *dl; DispList *dl;
@@ -1633,7 +1633,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
float *fp, *coord_array; float *fp, *coord_array;
ListBase disp = {NULL, NULL}; ListBase disp = {NULL, NULL};
BKE_displist_make_curveTypes_forOrco(scene, ob, &disp); BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
numVerts = 0; numVerts = 0;
for (dl = disp.first; dl; dl = dl->next) { for (dl = disp.first; dl; dl = dl->next) {
@@ -1724,7 +1724,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
/* ***************** BEVEL ****************** */ /* ***************** BEVEL ****************** */
void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, void BKE_curve_bevel_make(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *disp,
const bool for_render, const bool use_render_resolution) const bool for_render, const bool use_render_resolution)
{ {
DispList *dl, *dlnew; DispList *dl, *dlnew;
@@ -1749,7 +1749,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp,
facy = cu->bevobj->size[1]; facy = cu->bevobj->size[1];
if (for_render) { if (for_render) {
BKE_displist_make_curveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution); BKE_displist_make_curveTypes_forRender(eval_ctx, scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
dl = bevdisp.first; dl = bevdisp.first;
} }
else if (cu->bevobj->curve_cache) { else if (cu->bevobj->curve_cache) {

View File

@@ -1010,7 +1010,7 @@ static bool data_transfer_layersmapping_generate(
* to get (as much as possible) exact copy of source data layout. * to get (as much as possible) exact copy of source data layout.
*/ */
void BKE_object_data_transfer_layout( void BKE_object_data_transfer_layout(
Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]) const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX])
{ {
DerivedMesh *dm_src; DerivedMesh *dm_src;
@@ -1027,7 +1027,7 @@ void BKE_object_data_transfer_layout(
/* Get source DM.*/ /* Get source DM.*/
dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types); dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types);
dm_src = mesh_get_derived_final(scene, ob_src, dm_src_mask); dm_src = mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
if (!dm_src) { if (!dm_src) {
return; return;
} }
@@ -1085,9 +1085,9 @@ void BKE_object_data_transfer_layout(
} }
bool BKE_object_data_transfer_dm( bool BKE_object_data_transfer_dm(
Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst, const int data_types, bool use_create, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode,
SpaceTransform *space_transform, const bool auto_transform, const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
const float max_distance, const float ray_radius, const float islands_handling_precision, const float max_distance, const float ray_radius, const float islands_handling_precision,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX], const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX],
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup, const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
@@ -1149,7 +1149,7 @@ bool BKE_object_data_transfer_dm(
* Also, we need to make a local copy of dm_src, otherwise we may end with concurrent creation * Also, we need to make a local copy of dm_src, otherwise we may end with concurrent creation
* of data in it (multi-threaded evaluation of the modifier stack, see T46672). * of data in it (multi-threaded evaluation of the modifier stack, see T46672).
*/ */
dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(scene, ob_src, dm_src_mask); dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(eval_ctx, scene, ob_src, dm_src_mask);
if (!dm_src) { if (!dm_src) {
return changed; return changed;
} }
@@ -1457,16 +1457,16 @@ bool BKE_object_data_transfer_dm(
} }
bool BKE_object_data_transfer_mesh( bool BKE_object_data_transfer_mesh(
Scene *scene, Object *ob_src, Object *ob_dst, const int data_types, const bool use_create, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, Object *ob_dst, const int data_types,
const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, const bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode,
SpaceTransform *space_transform, const bool auto_transform, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform,
const float max_distance, const float ray_radius, const float islands_handling_precision, const float max_distance, const float ray_radius, const float islands_handling_precision,
const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX], const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX],
const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup, const int mix_mode, const float mix_factor, const char *vgroup_name, const bool invert_vgroup,
ReportList *reports) ReportList *reports)
{ {
return BKE_object_data_transfer_dm( return BKE_object_data_transfer_dm(
scene, ob_src, ob_dst, NULL, data_types, use_create, eval_ctx, scene, ob_src, ob_dst, NULL, data_types, use_create,
map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode, map_vert_mode, map_edge_mode, map_loop_mode, map_poly_mode,
space_transform, auto_transform, space_transform, auto_transform,
max_distance, ray_radius, islands_handling_precision, max_distance, ray_radius, islands_handling_precision,

View File

@@ -678,7 +678,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis
* - first point left, last point right * - first point left, last point right
* - based on subdivided points in original curve, not on points in taper curve (still) * - based on subdivided points in original curve, not on points in taper curve (still)
*/ */
static float displist_calc_taper(Scene *scene, Object *taperobj, float fac) static float displist_calc_taper(EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, float fac)
{ {
DispList *dl; DispList *dl;
@@ -687,7 +687,7 @@ static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
dl = taperobj->curve_cache ? taperobj->curve_cache->disp.first : NULL; dl = taperobj->curve_cache ? taperobj->curve_cache->disp.first : NULL;
if (dl == NULL) { if (dl == NULL) {
BKE_displist_make_curveTypes(scene, taperobj, 0); BKE_displist_make_curveTypes(eval_ctx, scene, taperobj, 0);
dl = taperobj->curve_cache->disp.first; dl = taperobj->curve_cache->disp.first;
} }
if (dl) { if (dl) {
@@ -718,11 +718,11 @@ static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
return 1.0; return 1.0;
} }
float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot) float BKE_displist_calc_taper(EvaluationContext *eval_ctx, Scene *scene, Object *taperobj, int cur, int tot)
{ {
float fac = ((float)cur) / (float)(tot - 1); float fac = ((float)cur) / (float)(tot - 1);
return displist_calc_taper(scene, taperobj, fac); return displist_calc_taper(eval_ctx, scene, taperobj, fac);
} }
void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object *ob) void BKE_displist_make_mball(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
@@ -798,7 +798,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob,
return pretessellatePoint; return pretessellatePoint;
} }
static void curve_calc_modifiers_pre(Scene *scene, Object *ob, ListBase *nurb, static void curve_calc_modifiers_pre(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
const bool for_render, const bool use_render_resolution) const bool for_render, const bool use_render_resolution)
{ {
VirtualModifierData virtualModifierData; VirtualModifierData virtualModifierData;
@@ -856,7 +856,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, ListBase *nurb,
deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts); deformedVerts = BKE_curve_nurbs_vertexCos_get(nurb, &numVerts);
} }
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, app_flag); mti->deformVerts(md, eval_ctx, ob, NULL, deformedVerts, numVerts, app_flag);
if (md == pretessellatePoint) if (md == pretessellatePoint)
break; break;
@@ -908,7 +908,7 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
} }
} }
static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb, static void curve_calc_modifiers_post(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *nurb,
ListBase *dispbase, DerivedMesh **r_dm_final, ListBase *dispbase, DerivedMesh **r_dm_final,
const bool for_render, const bool use_render_resolution) const bool for_render, const bool use_render_resolution)
{ {
@@ -964,14 +964,14 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
dm->getVertCos(dm, vertCos); dm->getVertCos(dm, vertCos);
} }
mti->deformVerts(md, ob, dm, vertCos, totvert, appf); mti->deformVerts(md, eval_ctx, ob, dm, vertCos, totvert, appf);
} }
else { else {
if (!vertCos) { if (!vertCos) {
vertCos = displist_get_allverts(dispbase, &totvert); vertCos = displist_get_allverts(dispbase, &totvert);
} }
mti->deformVerts(md, ob, NULL, vertCos, totvert, appf); mti->deformVerts(md, eval_ctx, ob, NULL, vertCos, totvert, appf);
} }
} }
else { else {
@@ -1013,7 +1013,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *nurb,
if (useCache) if (useCache)
appf |= MOD_APPLY_USECACHE; appf |= MOD_APPLY_USECACHE;
ndm = modwrap_applyModifier(md, ob, dm, appf); ndm = modwrap_applyModifier(md, eval_ctx, ob, dm, appf);
if (ndm) { if (ndm) {
/* Modifier returned a new derived mesh */ /* Modifier returned a new derived mesh */
@@ -1090,13 +1090,13 @@ static void displist_surf_indices(DispList *dl)
} }
} }
static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) static DerivedMesh *create_orco_dm(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{ {
DerivedMesh *dm; DerivedMesh *dm;
ListBase disp = {NULL, NULL}; ListBase disp = {NULL, NULL};
/* OrcoDM should be created from underformed disp lists */ /* OrcoDM should be created from underformed disp lists */
BKE_displist_make_curveTypes_forOrco(scene, ob, &disp); BKE_displist_make_curveTypes_forOrco(eval_ctx, scene, ob, &disp);
dm = CDDM_from_curve_displist(ob, &disp); dm = CDDM_from_curve_displist(ob, &disp);
BKE_displist_free(&disp); BKE_displist_free(&disp);
@@ -1134,7 +1134,7 @@ static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco); DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco);
} }
static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final, static void curve_calc_orcodm(EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
const bool for_render, const bool use_render_resolution) const bool for_render, const bool use_render_resolution)
{ {
/* this function represents logic of mesh's orcodm calculation /* this function represents logic of mesh's orcodm calculation
@@ -1172,7 +1172,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
* This means we can create ORCO DM in advance and assume it's * This means we can create ORCO DM in advance and assume it's
* never NULL. * never NULL.
*/ */
orcodm = create_orco_dm(scene, ob); orcodm = create_orco_dm(eval_ctx, scene, ob);
for (; md; md = md->next) { for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type); const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1184,7 +1184,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
if (mti->type != eModifierTypeType_Constructive) if (mti->type != eModifierTypeType_Constructive)
continue; continue;
ndm = modwrap_applyModifier(md, ob, orcodm, app_flag); ndm = modwrap_applyModifier(md, eval_ctx, ob, orcodm, app_flag);
if (ndm) { if (ndm) {
/* if the modifier returned a new dm, release the old one */ /* if the modifier returned a new dm, release the old one */
@@ -1201,7 +1201,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *dm_final,
orcodm->release(orcodm); orcodm->release(orcodm);
} }
void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase, void BKE_displist_make_surf(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
DerivedMesh **r_dm_final, DerivedMesh **r_dm_final,
const bool for_render, const bool for_orco, const bool use_render_resolution) const bool for_render, const bool for_orco, const bool use_render_resolution)
{ {
@@ -1220,7 +1220,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
} }
if (!for_orco) if (!for_orco)
curve_calc_modifiers_pre(scene, ob, &nubase, for_render, use_render_resolution); curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
for (nu = nubase.first; nu; nu = nu->next) { for (nu = nubase.first; nu; nu = nu->next) {
if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) { if ((for_render || nu->hide == 0) && BKE_nurb_check_valid_uv(nu)) {
@@ -1287,7 +1287,7 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
if (!for_orco) { if (!for_orco) {
BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase); BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final, curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final,
for_render, use_render_resolution); for_render, use_render_resolution);
} }
@@ -1513,7 +1513,7 @@ static void calc_bevfac_mapping(Curve *cu, BevList *bl, Nurb *nu,
} }
} }
static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, static void do_makeDispListCurveTypes(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
DerivedMesh **r_dm_final, DerivedMesh **r_dm_final,
const bool for_render, const bool for_orco, const bool use_render_resolution) const bool for_render, const bool for_orco, const bool use_render_resolution)
{ {
@@ -1523,7 +1523,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
if (ob->type == OB_SURF) { if (ob->type == OB_SURF) {
BKE_displist_make_surf(scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution); BKE_displist_make_surf(eval_ctx, scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
} }
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
ListBase dlbev; ListBase dlbev;
@@ -1548,12 +1548,12 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
} }
if (!for_orco) if (!for_orco)
curve_calc_modifiers_pre(scene, ob, &nubase, for_render, use_render_resolution); curve_calc_modifiers_pre(eval_ctx, scene, ob, &nubase, for_render, use_render_resolution);
BKE_curve_bevelList_make(ob, &nubase, for_render != false); BKE_curve_bevelList_make(ob, &nubase, for_render != false);
/* If curve has no bevel will return nothing */ /* If curve has no bevel will return nothing */
BKE_curve_bevel_make(scene, ob, &dlbev, for_render, use_render_resolution); BKE_curve_bevel_make(eval_ctx, scene, ob, &dlbev, for_render, use_render_resolution);
/* no bevel or extrude, and no width correction? */ /* no bevel or extrude, and no width correction? */
if (!dlbev.first && cu->width == 1.0f) { if (!dlbev.first && cu->width == 1.0f) {
@@ -1688,7 +1688,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
taper_fac -= (1.0f - lastblend) / len; taper_fac -= (1.0f - lastblend) / len;
} }
fac = displist_calc_taper(scene, cu->taperobj, taper_fac); fac = displist_calc_taper(eval_ctx, scene, cu->taperobj, taper_fac);
} }
if (bevp->split_tag) { if (bevp->split_tag) {
@@ -1750,7 +1750,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (!for_orco) { if (!for_orco) {
BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase); BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
curve_calc_modifiers_post(scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution); curve_calc_modifiers_post(eval_ctx, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
} }
if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) { if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
@@ -1761,7 +1761,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
} }
} }
void BKE_displist_make_curveTypes(Scene *scene, Object *ob, const bool for_orco) void BKE_displist_make_curveTypes(EvaluationContext *eval_ctx, Scene *scene, Object *ob, const bool for_orco)
{ {
ListBase *dispbase; ListBase *dispbase;
@@ -1779,12 +1779,12 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, const bool for_orco)
dispbase = &(ob->curve_cache->disp); dispbase = &(ob->curve_cache->disp);
do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0); do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
boundbox_displist_object(ob); boundbox_displist_object(ob);
} }
void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, void BKE_displist_make_curveTypes_forRender(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase,
DerivedMesh **r_dm_final, const bool for_orco, DerivedMesh **r_dm_final, const bool for_orco,
const bool use_render_resolution) const bool use_render_resolution)
{ {
@@ -1792,20 +1792,20 @@ void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve"); ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
} }
do_makeDispListCurveTypes(scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution); do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
} }
void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase) void BKE_displist_make_curveTypes_forOrco(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ListBase *dispbase)
{ {
if (ob->curve_cache == NULL) { if (ob->curve_cache == NULL) {
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve"); ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
} }
do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1, 1); do_makeDispListCurveTypes(eval_ctx, scene, ob, dispbase, NULL, 1, 1, 1);
} }
/* add Orco layer to the displist object which has got derived mesh and return orco */ /* add Orco layer to the displist object which has got derived mesh and return orco */
float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *dm_final, float *BKE_displist_make_orco(EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm_final,
const bool for_render, const bool for_render,
const bool use_render_resolution) const bool use_render_resolution)
{ {
@@ -1815,7 +1815,7 @@ float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *dm_final,
dm_final = ob->derivedFinal; dm_final = ob->derivedFinal;
if (!dm_final->getVertDataArray(dm_final, CD_ORCO)) { if (!dm_final->getVertDataArray(dm_final, CD_ORCO)) {
curve_calc_orcodm(scene, ob, dm_final, for_render, use_render_resolution); curve_calc_orcodm(eval_ctx, scene, ob, dm_final, for_render, use_render_resolution);
} }
orco = dm_final->getVertDataArray(dm_final, CD_ORCO); orco = dm_final->getVertDataArray(dm_final, CD_ORCO);

View File

@@ -74,6 +74,8 @@
#include "BKE_scene.h" #include "BKE_scene.h"
#include "BKE_texture.h" #include "BKE_texture.h"
#include "DEG_depsgraph.h"
/* for image output */ /* for image output */
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"
#include "IMB_imbuf.h" #include "IMB_imbuf.h"
@@ -1973,7 +1975,7 @@ static void canvas_copyDerivedMesh(DynamicPaintCanvasSettings *canvas, DerivedMe
/* /*
* Updates derived mesh copy and processes dynamic paint step / caches. * Updates derived mesh copy and processes dynamic paint step / caches.
*/ */
static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm) static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
{ {
if (pmd->canvas) { if (pmd->canvas) {
DynamicPaintCanvasSettings *canvas = pmd->canvas; DynamicPaintCanvasSettings *canvas = pmd->canvas;
@@ -2036,7 +2038,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
else if (can_simulate) { else if (can_simulate) {
/* calculate surface frame */ /* calculate surface frame */
canvas->flags |= MOD_DPAINT_BAKING; canvas->flags |= MOD_DPAINT_BAKING;
dynamicPaint_calculateFrame(surface, scene, sl, ob, current_frame); dynamicPaint_calculateFrame(surface, eval_ctx, scene, ob, current_frame);
canvas->flags &= ~MOD_DPAINT_BAKING; canvas->flags &= ~MOD_DPAINT_BAKING;
/* restore canvas derivedmesh if required */ /* restore canvas derivedmesh if required */
@@ -2055,7 +2057,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
} }
/* Modifier call. Processes dynamic paint modifier step. */ /* Modifier call. Processes dynamic paint modifier step. */
DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm) DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
{ {
if (pmd->canvas) { if (pmd->canvas) {
DerivedMesh *ret; DerivedMesh *ret;
@@ -2064,7 +2066,7 @@ DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scen
DM_ensure_looptri(dm); DM_ensure_looptri(dm);
/* Update canvas data for a new frame */ /* Update canvas data for a new frame */
dynamicPaint_frameUpdate(pmd, scene, sl, ob, dm); dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
/* Return output mesh */ /* Return output mesh */
ret = dynamicPaint_Modifier_apply(pmd, ob, dm); ret = dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -2076,7 +2078,7 @@ DerivedMesh *dynamicPaint_Modifier_do(DynamicPaintModifierData *pmd, Scene *scen
DM_ensure_looptri(dm); DM_ensure_looptri(dm);
/* Update canvas data for a new frame */ /* Update canvas data for a new frame */
dynamicPaint_frameUpdate(pmd, scene, sl, ob, dm); dynamicPaint_frameUpdate(pmd, eval_ctx, scene, ob, dm);
/* Return output mesh */ /* Return output mesh */
return dynamicPaint_Modifier_apply(pmd, ob, dm); return dynamicPaint_Modifier_apply(pmd, ob, dm);
@@ -3582,7 +3584,7 @@ static void dynamic_paint_brush_velocity_compute_cb(void *userdata, const int i)
} }
static void dynamicPaint_brushMeshCalculateVelocity( static void dynamicPaint_brushMeshCalculateVelocity(
Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale) struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintBrushSettings *brush, Vec3f **brushVel, float timescale)
{ {
float prev_obmat[4][4]; float prev_obmat[4][4];
DerivedMesh *dm_p, *dm_c; DerivedMesh *dm_p, *dm_c;
@@ -3604,7 +3606,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
scene->r.subframe = prev_sfra; scene->r.subframe = prev_sfra;
BKE_object_modifier_update_subframe( BKE_object_modifier_update_subframe(
scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
dm_p = CDDM_copy(brush->dm); dm_p = CDDM_copy(brush->dm);
numOfVerts_p = dm_p->getNumVerts(dm_p); numOfVerts_p = dm_p->getNumVerts(dm_p);
mvert_p = dm_p->getVertArray(dm_p); mvert_p = dm_p->getVertArray(dm_p);
@@ -3615,7 +3617,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
scene->r.subframe = cur_sfra; scene->r.subframe = cur_sfra;
BKE_object_modifier_update_subframe( BKE_object_modifier_update_subframe(
scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); eval_ctx, scene, ob, true, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
dm_c = brush->dm; dm_c = brush->dm;
numOfVerts_c = dm_c->getNumVerts(dm_c); numOfVerts_c = dm_c->getNumVerts(dm_c);
mvert_c = dm_p->getVertArray(dm_c); mvert_c = dm_p->getVertArray(dm_c);
@@ -3640,7 +3642,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(
} }
/* calculate velocity for object center point */ /* calculate velocity for object center point */
static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, Vec3f *brushVel, float timescale) static void dynamicPaint_brushObjectCalculateVelocity(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Vec3f *brushVel, float timescale)
{ {
float prev_obmat[4][4]; float prev_obmat[4][4];
float cur_loc[3] = {0.0f}, prev_loc[3] = {0.0f}; float cur_loc[3] = {0.0f}, prev_loc[3] = {0.0f};
@@ -3659,14 +3661,14 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob,
scene->r.cfra = prev_fra; scene->r.cfra = prev_fra;
scene->r.subframe = prev_sfra; scene->r.subframe = prev_sfra;
BKE_object_modifier_update_subframe( BKE_object_modifier_update_subframe(
scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
copy_m4_m4(prev_obmat, ob->obmat); copy_m4_m4(prev_obmat, ob->obmat);
/* current frame dm */ /* current frame dm */
scene->r.cfra = cur_fra; scene->r.cfra = cur_fra;
scene->r.subframe = cur_sfra; scene->r.subframe = cur_sfra;
BKE_object_modifier_update_subframe( BKE_object_modifier_update_subframe(
scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint); eval_ctx, scene, ob, false, SUBFRAME_RECURSION, BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
/* calculate speed */ /* calculate speed */
mul_m4_v3(prev_obmat, prev_loc); mul_m4_v3(prev_obmat, prev_loc);
@@ -4036,7 +4038,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(
} }
} }
static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, static int dynamicPaint_paintMesh(struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface,
DynamicPaintBrushSettings *brush, DynamicPaintBrushSettings *brush,
Object *brushOb, Object *brushOb,
BrushMaterials *bMats, BrushMaterials *bMats,
@@ -4052,7 +4054,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
const MLoop *mloop = NULL; const MLoop *mloop = NULL;
if (brush->flags & MOD_DPAINT_USES_VELOCITY) if (brush->flags & MOD_DPAINT_USES_VELOCITY)
dynamicPaint_brushMeshCalculateVelocity(scene, brushOb, brush, &brushVelocity, timescale); dynamicPaint_brushMeshCalculateVelocity(eval_ctx, scene, brushOb, brush, &brushVelocity, timescale);
if (!brush->dm) if (!brush->dm)
return 0; return 0;
@@ -4530,7 +4532,7 @@ static void dynamic_paint_paint_single_point_cb_ex(
} }
static int dynamicPaint_paintSinglePoint( static int dynamicPaint_paintSinglePoint(
DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush, struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, float *pointCoord, DynamicPaintBrushSettings *brush,
Object *brushOb, BrushMaterials *bMats, Scene *scene, float timescale) Object *brushOb, BrushMaterials *bMats, Scene *scene, float timescale)
{ {
PaintSurfaceData *sData = surface->data; PaintSurfaceData *sData = surface->data;
@@ -4538,7 +4540,7 @@ static int dynamicPaint_paintSinglePoint(
Vec3f brushVel; Vec3f brushVel;
if (brush->flags & MOD_DPAINT_USES_VELOCITY) if (brush->flags & MOD_DPAINT_USES_VELOCITY)
dynamicPaint_brushObjectCalculateVelocity(scene, brushOb, &brushVel, timescale); dynamicPaint_brushObjectCalculateVelocity(eval_ctx, scene, brushOb, &brushVel, timescale);
const MVert *mvert = brush->dm->getVertArray(brush->dm); const MVert *mvert = brush->dm->getVertArray(brush->dm);
@@ -4845,7 +4847,7 @@ static void dynamic_paint_prepare_effect_cb(void *userdata, const int index)
} }
static int dynamicPaint_prepareEffectStep( static int dynamicPaint_prepareEffectStep(
DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale) struct EvaluationContext *eval_ctx, DynamicPaintSurface *surface, Scene *scene, Object *ob, float **force, float timescale)
{ {
double average_force = 0.0f; double average_force = 0.0f;
float shrink_speed = 0.0f, spread_speed = 0.0f; float shrink_speed = 0.0f, spread_speed = 0.0f;
@@ -4856,7 +4858,7 @@ static int dynamicPaint_prepareEffectStep(
/* Init force data if required */ /* Init force data if required */
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) { if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
ListBase *effectors = pdInitEffectors(scene, ob, NULL, surface->effector_weights, true); ListBase *effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, surface->effector_weights, true);
/* allocate memory for force data (dir vector + strength) */ /* allocate memory for force data (dir vector + strength) */
*force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces"); *force = MEM_mallocN(sData->total_points * 4 * sizeof(float), "PaintEffectForces");
@@ -5758,7 +5760,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Sce
/* /*
* Do Dynamic Paint step. Paints scene brush objects of current state/frame to the surface. * Do Dynamic Paint step. Paints scene brush objects of current state/frame to the surface.
*/ */
static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe) static int dynamicPaint_doStep(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DynamicPaintSurface *surface, float timescale, float subframe)
{ {
PaintSurfaceData *sData = surface->data; PaintSurfaceData *sData = surface->data;
PaintBakeData *bData = sData->bData; PaintBakeData *bData = sData->bData;
@@ -5782,6 +5784,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
GroupObject *go = NULL; GroupObject *go = NULL;
Object *brushObj = NULL; Object *brushObj = NULL;
ModifierData *md = NULL; ModifierData *md = NULL;
SceneLayer *sl = eval_ctx->scene_layer;
/* backup current scene frame */ /* backup current scene frame */
int scene_frame = scene->r.cfra; int scene_frame = scene->r.cfra;
@@ -5836,7 +5839,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
/* update object data on this subframe */ /* update object data on this subframe */
if (subframe) { if (subframe) {
scene_setSubframe(scene, subframe); scene_setSubframe(scene, subframe);
BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION, BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
BKE_scene_frame_get(scene), eModifierType_DynamicPaint); BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
} }
/* Prepare materials if required */ /* Prepare materials if required */
@@ -5855,11 +5858,11 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
} }
/* Object center distance: */ /* Object center distance: */
if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) { if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) {
dynamicPaint_paintSinglePoint(surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale); dynamicPaint_paintSinglePoint(eval_ctx, surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
} }
/* Mesh volume/proximity: */ /* Mesh volume/proximity: */
else if (brushObj != ob) { else if (brushObj != ob) {
dynamicPaint_paintMesh(surface, brush, brushObj, &bMats, scene, timescale); dynamicPaint_paintMesh(eval_ctx, surface, brush, brushObj, &bMats, scene, timescale);
} }
/* free temp material data */ /* free temp material data */
@@ -5869,7 +5872,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
if (subframe) { if (subframe) {
scene->r.cfra = scene_frame; scene->r.cfra = scene_frame;
scene->r.subframe = scene_subframe; scene->r.subframe = scene_subframe;
BKE_object_modifier_update_subframe(scene, brushObj, true, SUBFRAME_RECURSION, BKE_object_modifier_update_subframe(eval_ctx, scene, brushObj, true, SUBFRAME_RECURSION,
BKE_scene_frame_get(scene), eModifierType_DynamicPaint); BKE_scene_frame_get(scene), eModifierType_DynamicPaint);
} }
@@ -5904,7 +5907,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
return setError(canvas, N_("Not enough free memory")); return setError(canvas, N_("Not enough free memory"));
/* Prepare effects and get number of required steps */ /* Prepare effects and get number of required steps */
steps = dynamicPaint_prepareEffectStep(surface, scene, ob, &force, timescale); steps = dynamicPaint_prepareEffectStep(eval_ctx, surface, scene, ob, &force, timescale);
for (s = 0; s < steps; s++) { for (s = 0; s < steps; s++) {
dynamicPaint_doEffectStep(surface, force, prevPoint, timescale, (float)steps); dynamicPaint_doEffectStep(surface, force, prevPoint, timescale, (float)steps);
} }
@@ -5928,7 +5931,7 @@ static int dynamicPaint_doStep(Scene *scene, SceneLayer *sl, Object *ob, Dynamic
/* /*
* Calculate a single frame and included subframes for surface * Calculate a single frame and included subframes for surface
*/ */
int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, SceneLayer *sl, Object *cObject, int frame) int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, struct EvaluationContext *eval_ctx, Scene *scene, Object *cObject, int frame)
{ {
float timescale = 1.0f; float timescale = 1.0f;
@@ -5937,7 +5940,7 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Scen
dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm); dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm);
/* update bake data */ /* update bake data */
dynamicPaint_generateBakeData(surface, sl, cObject); dynamicPaint_generateBakeData(surface, eval_ctx->scene_layer, cObject);
/* don't do substeps for first frame */ /* don't do substeps for first frame */
if (surface->substeps && (frame != surface->start_frame)) { if (surface->substeps && (frame != surface->start_frame)) {
@@ -5946,10 +5949,10 @@ int dynamicPaint_calculateFrame(DynamicPaintSurface *surface, Scene *scene, Scen
for (st = 1; st <= surface->substeps; st++) { for (st = 1; st <= surface->substeps; st++) {
float subframe = ((float) st) / (surface->substeps + 1); float subframe = ((float) st) / (surface->substeps + 1);
if (!dynamicPaint_doStep(scene, sl, cObject, surface, timescale, subframe)) if (!dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, subframe))
return 0; return 0;
} }
} }
return dynamicPaint_doStep(scene, sl, cObject, surface, timescale, 0.0f); return dynamicPaint_doStep(eval_ctx, scene, cObject, surface, timescale, 0.0f);
} }

View File

@@ -2183,14 +2183,14 @@ static void cage_mapped_verts_callback(
} }
} }
float (*BKE_editmesh_vertexCos_get(BMEditMesh *em, Scene *scene, int *r_numVerts))[3] float (*BKE_editmesh_vertexCos_get(struct EvaluationContext *eval_ctx, BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
{ {
DerivedMesh *cage, *final; DerivedMesh *cage, *final;
BLI_bitmap *visit_bitmap; BLI_bitmap *visit_bitmap;
struct CageUserData data; struct CageUserData data;
float (*cos_cage)[3]; float (*cos_cage)[3];
cage = editbmesh_get_derived_cage_and_final(scene, em->ob, em, CD_MASK_BAREMESH, &final); cage = editbmesh_get_derived_cage_and_final(eval_ctx, scene, em->ob, em, CD_MASK_BAREMESH, &final);
cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage"); cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
/* when initializing cage verts, we only want the first cage coordinate for each vertex, /* when initializing cage verts, we only want the first cage coordinate for each vertex,

View File

@@ -72,6 +72,7 @@
#include "BKE_scene.h" #include "BKE_scene.h"
#include "BKE_smoke.h" #include "BKE_smoke.h"
#include "DEG_depsgraph.h"
#include "RE_render_ext.h" #include "RE_render_ext.h"
#include "RE_shader_ext.h" #include "RE_shader_ext.h"
@@ -146,9 +147,10 @@ void free_partdeflect(PartDeflect *pd)
MEM_freeN(pd); MEM_freeN(pd);
} }
static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd) static EffectorCache *new_effector_cache(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
{ {
EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache"); EffectorCache *eff = MEM_callocN(sizeof(EffectorCache), "EffectorCache");
eff->eval_ctx = eval_ctx;
eff->scene = scene; eff->scene = scene;
eff->ob = ob; eff->ob = ob;
eff->psys = psys; eff->psys = psys;
@@ -156,7 +158,7 @@ static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSyste
eff->frame = -1; eff->frame = -1;
return eff; return eff;
} }
static void add_object_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation) static void add_object_to_effectors(ListBase **effectors, struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src, bool for_simulation)
{ {
EffectorCache *eff = NULL; EffectorCache *eff = NULL;
@@ -174,14 +176,14 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector
if (*effectors == NULL) if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list"); *effectors = MEM_callocN(sizeof(ListBase), "effectors list");
eff = new_effector_cache(scene, ob, NULL, ob->pd); eff = new_effector_cache(eval_ctx, scene, ob, NULL, ob->pd);
/* make sure imat is up to date */ /* make sure imat is up to date */
invert_m4_m4(ob->imat, ob->obmat); invert_m4_m4(ob->imat, ob->obmat);
BLI_addtail(*effectors, eff); BLI_addtail(*effectors, eff);
} }
static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation) static void add_particles_to_effectors(ListBase **effectors, struct EvaluationContext *eval_ctx, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src, bool for_simulation)
{ {
ParticleSettings *part= psys->part; ParticleSettings *part= psys->part;
@@ -195,39 +197,47 @@ static void add_particles_to_effectors(ListBase **effectors, Scene *scene, Effec
if (*effectors == NULL) if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list"); *effectors = MEM_callocN(sizeof(ListBase), "effectors list");
BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd)); BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd));
} }
if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) { if (part->pd2 && part->pd2->forcefield && (!for_simulation || weights->weight[part->pd2->forcefield] != 0.0f)) {
if (*effectors == NULL) if (*effectors == NULL)
*effectors = MEM_callocN(sizeof(ListBase), "effectors list"); *effectors = MEM_callocN(sizeof(ListBase), "effectors list");
BLI_addtail(*effectors, new_effector_cache(scene, ob, psys, part->pd2)); BLI_addtail(*effectors, new_effector_cache(eval_ctx, scene, ob, psys, part->pd2));
} }
} }
/* returns ListBase handle with objects taking part in the effecting */ /* returns ListBase handle with objects taking part in the effecting */
ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src, ListBase *pdInitEffectors(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob_src, ParticleSystem *psys_src,
EffectorWeights *weights, bool for_simulation) EffectorWeights *weights, bool for_simulation)
{ {
SceneLayer *sl = BKE_scene_layer_context_active_PLACEHOLDER(scene); /* Can't get sl from the calling modifiers yet */ SceneLayer *sl;
Base *base; Base *base;
unsigned int layer= ob_src->lay; unsigned int layer= ob_src->lay;
ListBase *effectors = NULL; ListBase *effectors = NULL;
/* eval_ctx is NULL during deg build */
if (eval_ctx) {
sl = eval_ctx->scene_layer;
}
else {
sl = BKE_scene_layer_context_active_PLACEHOLDER(scene);
}
if (weights->group) { if (weights->group) {
GroupObject *go; GroupObject *go;
for (go= weights->group->gobject.first; go; go= go->next) { for (go= weights->group->gobject.first; go; go= go->next) {
if ( (go->ob->lay & layer) ) { if ( (go->ob->lay & layer) ) {
if ( go->ob->pd && go->ob->pd->forcefield ) if ( go->ob->pd && go->ob->pd->forcefield )
add_object_to_effectors(&effectors, scene, weights, go->ob, ob_src, for_simulation); add_object_to_effectors(&effectors, eval_ctx, scene, weights, go->ob, ob_src, for_simulation);
if ( go->ob->particlesystem.first ) { if ( go->ob->particlesystem.first ) {
ParticleSystem *psys= go->ob->particlesystem.first; ParticleSystem *psys= go->ob->particlesystem.first;
for ( ; psys; psys=psys->next ) for ( ; psys; psys=psys->next )
add_particles_to_effectors(&effectors, scene, weights, go->ob, psys, psys_src, for_simulation); add_particles_to_effectors(&effectors, eval_ctx, scene, weights, go->ob, psys, psys_src, for_simulation);
} }
} }
} }
@@ -235,19 +245,19 @@ ListBase *pdInitEffectors(Scene *scene, Object *ob_src, ParticleSystem *psys_src
else { else {
for (base = FIRSTBASE_NEW; base; base = base->next) { for (base = FIRSTBASE_NEW; base; base = base->next) {
if ( base->object->pd && base->object->pd->forcefield ) if ( base->object->pd && base->object->pd->forcefield )
add_object_to_effectors(&effectors, scene, weights, base->object, ob_src, for_simulation); add_object_to_effectors(&effectors, eval_ctx, scene, weights, base->object, ob_src, for_simulation);
if ( base->object->particlesystem.first ) { if ( base->object->particlesystem.first ) {
ParticleSystem *psys= base->object->particlesystem.first; ParticleSystem *psys= base->object->particlesystem.first;
for ( ; psys; psys=psys->next ) for ( ; psys; psys=psys->next )
add_particles_to_effectors(&effectors, scene, weights, base->object, psys, psys_src, for_simulation); add_particles_to_effectors(&effectors, eval_ctx, scene, weights, base->object, psys, psys_src, for_simulation);
} }
} }
} }
if (for_simulation) if (for_simulation)
pdPrecalculateEffectors(effectors); pdPrecalculateEffectors(eval_ctx, effectors);
return effectors; return effectors;
} }
@@ -268,7 +278,7 @@ void pdEndEffectors(ListBase **effectors)
} }
} }
static void precalculate_effector(EffectorCache *eff) static void precalculate_effector(struct EvaluationContext *eval_ctx, EffectorCache *eff)
{ {
unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra); unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra);
if (!eff->pd->rng) if (!eff->pd->rng)
@@ -280,7 +290,7 @@ static void precalculate_effector(EffectorCache *eff)
Curve *cu= eff->ob->data; Curve *cu= eff->ob->data;
if (cu->flag & CU_PATH) { if (cu->flag & CU_PATH) {
if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL) if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
BKE_displist_make_curveTypes(eff->scene, eff->ob, 0); BKE_displist_make_curveTypes(eval_ctx, eff->scene, eff->ob, 0);
if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) { if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL); where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
@@ -301,19 +311,19 @@ static void precalculate_effector(EffectorCache *eff)
if (eff->ob) { if (eff->ob) {
float old_vel[3]; float old_vel[3];
BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f); BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra - 1.0f);
copy_v3_v3(old_vel, eff->ob->obmat[3]); copy_v3_v3(old_vel, eff->ob->obmat[3]);
BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra); BKE_object_where_is_calc_time(eval_ctx, eff->scene, eff->ob, cfra);
sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel); sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
} }
} }
void pdPrecalculateEffectors(ListBase *effectors) void pdPrecalculateEffectors(struct EvaluationContext *eval_ctx, ListBase *effectors)
{ {
if (effectors) { if (effectors) {
EffectorCache *eff = effectors->first; EffectorCache *eff = effectors->first;
for (; eff; eff=eff->next) for (; eff; eff=eff->next)
precalculate_effector(eff); precalculate_effector(eval_ctx, eff);
} }
} }
@@ -612,6 +622,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
} }
else { else {
ParticleSimulationData sim= {NULL}; ParticleSimulationData sim= {NULL};
sim.eval_ctx = eff->eval_ctx;
sim.scene= eff->scene; sim.scene= eff->scene;
sim.ob= eff->ob; sim.ob= eff->ob;
sim.psys= eff->psys; sim.psys= eff->psys;

View File

@@ -65,7 +65,7 @@
// file handling // file handling
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
void initElbeemMesh(struct Scene *scene, struct Object *ob, void initElbeemMesh(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob,
int *numVertices, float **vertices, int *numVertices, float **vertices,
int *numTriangles, int **triangles, int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex) int useGlobalCoords, int modifierIndex)
@@ -78,7 +78,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
float *verts; float *verts;
int *tris; int *tris;
dm = mesh_create_derived_index_render(scene, ob, CD_MASK_BAREMESH, modifierIndex); dm = mesh_create_derived_index_render(eval_ctx, scene, ob, CD_MASK_BAREMESH, modifierIndex);
DM_ensure_looptri(dm); DM_ensure_looptri(dm);

View File

@@ -596,7 +596,7 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di
/* co: local coord, result local too */ /* co: local coord, result local too */
/* returns quaternion for rotation, using cd->no_rot_axis */ /* returns quaternion for rotation, using cd->no_rot_axis */
/* axis is using another define!!! */ /* axis is using another define!!! */
static bool calc_curve_deform(Scene *scene, Object *par, float co[3], static bool calc_curve_deform(struct EvaluationContext *eval_ctx, Scene *scene, Object *par, float co[3],
const short axis, CurveDeform *cd, float r_quat[4]) const short axis, CurveDeform *cd, float r_quat[4])
{ {
Curve *cu = par->data; Curve *cu = par->data;
@@ -607,7 +607,7 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
/* to be sure, mostly after file load, also cyclic dependencies */ /* to be sure, mostly after file load, also cyclic dependencies */
#ifdef CYCLIC_DEPENDENCY_WORKAROUND #ifdef CYCLIC_DEPENDENCY_WORKAROUND
if (par->curve_cache == NULL) { if (par->curve_cache == NULL) {
BKE_displist_make_curveTypes(scene, par, false); BKE_displist_make_curveTypes(eval_ctx, scene, par, false);
} }
#endif #endif
@@ -700,7 +700,7 @@ static bool calc_curve_deform(Scene *scene, Object *par, float co[3],
} }
void curve_deform_verts( void curve_deform_verts(
Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], struct EvaluationContext *eval_ctx, Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3],
int numVerts, const char *vgroup, short defaxis) int numVerts, const char *vgroup, short defaxis)
{ {
Curve *cu; Curve *cu;
@@ -759,7 +759,7 @@ void curve_deform_verts(
if (weight > 0.0f) { if (weight > 0.0f) {
mul_m4_v3(cd.curvespace, vertexCos[a]); mul_m4_v3(cd.curvespace, vertexCos[a]);
copy_v3_v3(vec, vertexCos[a]); copy_v3_v3(vec, vertexCos[a]);
calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); calc_curve_deform(eval_ctx, scene, cuOb, vec, defaxis, &cd, NULL);
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
mul_m4_v3(cd.objectspace, vertexCos[a]); mul_m4_v3(cd.objectspace, vertexCos[a]);
} }
@@ -782,7 +782,7 @@ void curve_deform_verts(
if (weight > 0.0f) { if (weight > 0.0f) {
/* already in 'cd.curvespace', prev for loop */ /* already in 'cd.curvespace', prev for loop */
copy_v3_v3(vec, vertexCos[a]); copy_v3_v3(vec, vertexCos[a]);
calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); calc_curve_deform(eval_ctx, scene, cuOb, vec, defaxis, &cd, NULL);
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
mul_m4_v3(cd.objectspace, vertexCos[a]); mul_m4_v3(cd.objectspace, vertexCos[a]);
} }
@@ -793,7 +793,7 @@ void curve_deform_verts(
if (cu->flag & CU_DEFORM_BOUNDS_OFF) { if (cu->flag & CU_DEFORM_BOUNDS_OFF) {
for (a = 0; a < numVerts; a++) { for (a = 0; a < numVerts; a++) {
mul_m4_v3(cd.curvespace, vertexCos[a]); mul_m4_v3(cd.curvespace, vertexCos[a]);
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]); mul_m4_v3(cd.objectspace, vertexCos[a]);
} }
} }
@@ -808,7 +808,7 @@ void curve_deform_verts(
for (a = 0; a < numVerts; a++) { for (a = 0; a < numVerts; a++) {
/* already in 'cd.curvespace', prev for loop */ /* already in 'cd.curvespace', prev for loop */
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); calc_curve_deform(eval_ctx, scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
mul_m4_v3(cd.objectspace, vertexCos[a]); mul_m4_v3(cd.objectspace, vertexCos[a]);
} }
} }
@@ -818,7 +818,7 @@ void curve_deform_verts(
/* input vec and orco = local coord in armature space */ /* input vec and orco = local coord in armature space */
/* orco is original not-animated or deformed reference point */ /* orco is original not-animated or deformed reference point */
/* result written in vec and mat */ /* result written in vec and mat */
void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, void curve_deform_vector(struct EvaluationContext *eval_ctx, Scene *scene, Object *cuOb, Object *target,
float orco[3], float vec[3], float mat[3][3], int no_rot_axis) float orco[3], float vec[3], float mat[3][3], int no_rot_axis)
{ {
CurveDeform cd; CurveDeform cd;
@@ -837,7 +837,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
mul_m4_v3(cd.curvespace, vec); mul_m4_v3(cd.curvespace, vec);
if (calc_curve_deform(scene, cuOb, vec, target->trackflag, &cd, quat)) { if (calc_curve_deform(eval_ctx, scene, cuOb, vec, target->trackflag, &cd, quat)) {
float qmat[3][3]; float qmat[3][3];
quat_to_mat3(qmat, quat); quat_to_mat3(qmat, quat);
@@ -1027,7 +1027,7 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3])
} }
} }
void BKE_lattice_modifiers_calc(Scene *scene, Object *ob) void BKE_lattice_modifiers_calc(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{ {
Lattice *lt = ob->data; Lattice *lt = ob->data;
VirtualModifierData virtualModifierData; VirtualModifierData virtualModifierData;
@@ -1054,7 +1054,7 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
if (mti->type != eModifierTypeType_OnlyDeform) continue; if (mti->type != eModifierTypeType_OnlyDeform) continue;
if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts);
mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0); mti->deformVerts(md, eval_ctx, ob, NULL, vertexCos, numVerts, 0);
} }
/* always displist to make this work like derivedmesh */ /* always displist to make this work like derivedmesh */

View File

@@ -1628,10 +1628,10 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
} }
} }
void BKE_mesh_to_curve(Scene *scene, Object *ob) void BKE_mesh_to_curve(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{ {
/* make new mesh data from the original copy */ /* make new mesh data from the original copy */
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_MESH);
ListBase nurblist = {NULL, NULL}; ListBase nurblist = {NULL, NULL};
bool needsFree = false; bool needsFree = false;
@@ -2466,7 +2466,7 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
/* settings: 1 - preview, 2 - render */ /* settings: 1 - preview, 2 - render */
Mesh *BKE_mesh_new_from_object( Mesh *BKE_mesh_new_from_object(
Main *bmain, Scene *sce, Object *ob, EvaluationContext *eval_ctx, Main *bmain, Scene *sce, Object *ob,
int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) int apply_modifiers, int settings, int calc_tessface, int calc_undeformed)
{ {
Mesh *tmpmesh; Mesh *tmpmesh;
@@ -2518,7 +2518,7 @@ Mesh *BKE_mesh_new_from_object(
copycu->editnurb = tmpcu->editnurb; copycu->editnurb = tmpcu->editnurb;
/* get updated display list, and convert to a mesh */ /* get updated display list, and convert to a mesh */
BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, false, render); BKE_displist_make_curveTypes_forRender(eval_ctx, sce, tmpobj, &dispbase, &derivedFinal, false, render);
copycu->editfont = NULL; copycu->editfont = NULL;
copycu->editnurb = NULL; copycu->editnurb = NULL;
@@ -2569,13 +2569,7 @@ Mesh *BKE_mesh_new_from_object(
if (render) { if (render) {
ListBase disp = {NULL, NULL}; ListBase disp = {NULL, NULL};
/* TODO(sergey): This is gonna to work for until EvaluationContext BKE_displist_make_mball_forRender(eval_ctx, sce, ob, &disp);
* only contains for_render flag. As soon as CoW is
* implemented, this is to be rethinked.
*/
EvaluationContext eval_ctx;
DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER);
BKE_displist_make_mball_forRender(&eval_ctx, sce, ob, &disp);
BKE_mesh_from_metaball(&disp, tmpmesh); BKE_mesh_from_metaball(&disp, tmpmesh);
BKE_displist_free(&disp); BKE_displist_free(&disp);
} }
@@ -2614,9 +2608,9 @@ Mesh *BKE_mesh_new_from_object(
/* Write the display mesh into the dummy mesh */ /* Write the display mesh into the dummy mesh */
if (render) if (render)
dm = mesh_create_derived_render(sce, ob, mask); dm = mesh_create_derived_render(eval_ctx, sce, ob, mask);
else else
dm = mesh_create_derived_view(sce, ob, mask); dm = mesh_create_derived_view(eval_ctx, sce, ob, mask);
tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2); tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2);
DM_to_mesh(dm, tmpmesh, ob, mask, true); DM_to_mesh(dm, tmpmesh, ob, mask, true);

View File

@@ -732,8 +732,8 @@ void modifier_path_init(char *path, int path_maxlen, const char *name)
/* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */ /* wrapper around ModifierTypeInfo.applyModifier that ensures valid normals */
struct DerivedMesh *modwrap_applyModifier( struct DerivedMesh *modwrap_applyModifier(
ModifierData *md, Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx,
struct DerivedMesh *dm, Object *ob, struct DerivedMesh *dm,
ModifierApplyFlag flag) ModifierApplyFlag flag)
{ {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type); const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -742,12 +742,12 @@ struct DerivedMesh *modwrap_applyModifier(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) { if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm); DM_ensure_normals(dm);
} }
return mti->applyModifier(md, ob, dm, flag); return mti->applyModifier(md, eval_ctx, ob, dm, flag);
} }
struct DerivedMesh *modwrap_applyModifierEM( struct DerivedMesh *modwrap_applyModifierEM(
ModifierData *md, Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx,
struct BMEditMesh *em, Object *ob, struct BMEditMesh *em,
DerivedMesh *dm, DerivedMesh *dm,
ModifierApplyFlag flag) ModifierApplyFlag flag)
{ {
@@ -757,12 +757,12 @@ struct DerivedMesh *modwrap_applyModifierEM(
if (mti->dependsOnNormals && mti->dependsOnNormals(md)) { if (mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm); DM_ensure_normals(dm);
} }
return mti->applyModifierEM(md, ob, em, dm, flag); return mti->applyModifierEM(md, eval_ctx, ob, em, dm, flag);
} }
void modwrap_deformVerts( void modwrap_deformVerts(
ModifierData *md, Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx,
DerivedMesh *dm, Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts, float (*vertexCos)[3], int numVerts,
ModifierApplyFlag flag) ModifierApplyFlag flag)
{ {
@@ -772,11 +772,11 @@ void modwrap_deformVerts(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm); DM_ensure_normals(dm);
} }
mti->deformVerts(md, ob, dm, vertexCos, numVerts, flag); mti->deformVerts(md, eval_ctx, ob, dm, vertexCos, numVerts, flag);
} }
void modwrap_deformVertsEM( void modwrap_deformVertsEM(
ModifierData *md, Object *ob, ModifierData *md, struct EvaluationContext *eval_ctx, Object *ob,
struct BMEditMesh *em, DerivedMesh *dm, struct BMEditMesh *em, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts) float (*vertexCos)[3], int numVerts)
{ {
@@ -786,6 +786,6 @@ void modwrap_deformVertsEM(
if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) { if (dm && mti->dependsOnNormals && mti->dependsOnNormals(md)) {
DM_ensure_normals(dm); DM_ensure_normals(dm);
} }
mti->deformVertsEM(md, ob, em, dm, vertexCos, numVerts); mti->deformVertsEM(md, eval_ctx, ob, em, dm, vertexCos, numVerts);
} }
/* end modifier callback wrappers */ /* end modifier callback wrappers */

View File

@@ -276,14 +276,14 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level)
return mdisps; return mdisps;
} }
DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob) DerivedMesh *get_multires_dm(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *ob)
{ {
ModifierData *md = (ModifierData *)mmd; ModifierData *md = (ModifierData *)mmd;
const ModifierTypeInfo *mti = modifierType_getInfo(md->type); const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); DerivedMesh *tdm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
DerivedMesh *dm; DerivedMesh *dm;
dm = mti->applyModifier(md, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY); dm = mti->applyModifier(md, eval_ctx, ob, tdm, MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY);
if (dm == tdm) { if (dm == tdm) {
dm = CDDM_copy(tdm); dm = CDDM_copy(tdm);
} }
@@ -397,10 +397,10 @@ void multires_force_render_update(Object *ob)
multires_force_update(ob); multires_force_update(ob);
} }
int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd, int multiresModifier_reshapeFromDM(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
Object *ob, DerivedMesh *srcdm) Object *ob, DerivedMesh *srcdm)
{ {
DerivedMesh *mrdm = get_multires_dm(scene, mmd, ob); DerivedMesh *mrdm = get_multires_dm(eval_ctx, scene, mmd, ob);
if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) { if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) {
multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm)); multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm));
@@ -419,13 +419,13 @@ int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd,
} }
/* Returns 1 on success, 0 if the src's totvert doesn't match */ /* Returns 1 on success, 0 if the src's totvert doesn't match */
int multiresModifier_reshape(Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src) int multiresModifier_reshape(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd, Object *dst, Object *src)
{ {
DerivedMesh *srcdm = mesh_get_derived_final(scene, src, CD_MASK_BAREMESH); DerivedMesh *srcdm = mesh_get_derived_final(eval_ctx, scene, src, CD_MASK_BAREMESH);
return multiresModifier_reshapeFromDM(scene, mmd, dst, srcdm); return multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, dst, srcdm);
} }
int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mmd, int multiresModifier_reshapeFromDeformMod(struct EvaluationContext *eval_ctx, Scene *scene, MultiresModifierData *mmd,
Object *ob, ModifierData *md) Object *ob, ModifierData *md)
{ {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type); const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -437,12 +437,12 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
return 0; return 0;
/* Create DerivedMesh for deformation modifier */ /* Create DerivedMesh for deformation modifier */
dm = get_multires_dm(scene, mmd, ob); dm = get_multires_dm(eval_ctx, scene, mmd, ob);
numVerts = dm->getNumVerts(dm); numVerts = dm->getNumVerts(dm);
deformedVerts = MEM_mallocN(sizeof(float[3]) * numVerts, "multiresReshape_deformVerts"); deformedVerts = MEM_mallocN(sizeof(float[3]) * numVerts, "multiresReshape_deformVerts");
dm->getVertCos(dm, deformedVerts); dm->getVertCos(dm, deformedVerts);
mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0); mti->deformVerts(md, eval_ctx, ob, dm, deformedVerts, numVerts, 0);
ndm = CDDM_copy(dm); ndm = CDDM_copy(dm);
CDDM_apply_vert_coords(ndm, deformedVerts); CDDM_apply_vert_coords(ndm, deformedVerts);
@@ -451,7 +451,7 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm
dm->release(dm); dm->release(dm);
/* Reshaping */ /* Reshaping */
result = multiresModifier_reshapeFromDM(scene, mmd, ob, ndm); result = multiresModifier_reshapeFromDM(eval_ctx, scene, mmd, ob, ndm);
/* Cleanup */ /* Cleanup */
ndm->release(ndm); ndm->release(ndm);
@@ -2174,7 +2174,7 @@ static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst)
} }
} }
static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) static void multires_apply_smat(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float smat[3][3])
{ {
DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL; DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL;
CCGElem **gridData, **subGridData; CCGElem **gridData, **subGridData;
@@ -2199,10 +2199,10 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
high_mmd.lvl = high_mmd.totlvl; high_mmd.lvl = high_mmd.totlvl;
/* unscaled multires with applied displacement */ /* unscaled multires with applied displacement */
subdm = get_multires_dm(scene, &high_mmd, ob); subdm = get_multires_dm(eval_ctx, scene, &high_mmd, ob);
/* prepare scaled CDDM to create ccgDN */ /* prepare scaled CDDM to create ccgDN */
cddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); cddm = mesh_get_derived_deform(eval_ctx, scene, ob, CD_MASK_BAREMESH);
totvert = cddm->getNumVerts(cddm); totvert = cddm->getNumVerts(cddm);
vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos"); vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos");
@@ -2276,17 +2276,17 @@ int multires_mdisp_corners(MDisps *s)
return 0; return 0;
} }
void multiresModifier_scale_disp(Scene *scene, Object *ob) void multiresModifier_scale_disp(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{ {
float smat[3][3]; float smat[3][3];
/* object's scale matrix */ /* object's scale matrix */
BKE_object_scale_to_mat3(ob, smat); BKE_object_scale_to_mat3(ob, smat);
multires_apply_smat(scene, ob, smat); multires_apply_smat(eval_ctx, scene, ob, smat);
} }
void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) void multiresModifier_prepare_join(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *to_ob)
{ {
float smat[3][3], tmat[3][3], mat[3][3]; float smat[3][3], tmat[3][3], mat[3][3];
multires_sync_levels(scene, to_ob, ob); multires_sync_levels(scene, to_ob, ob);
@@ -2297,7 +2297,7 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob)
BKE_object_scale_to_mat3(ob, smat); BKE_object_scale_to_mat3(ob, smat);
mul_m3_m3m3(mat, smat, tmat); mul_m3_m3m3(mat, smat, tmat);
multires_apply_smat(scene, ob, mat); multires_apply_smat(eval_ctx, scene, ob, mat);
} }
/* update multires data after topology changing */ /* update multires data after topology changing */

View File

@@ -1709,13 +1709,16 @@ static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
Curve *cu = par->data; Curve *cu = par->data;
float vec[4], dir[3], quat[4], radius, ctime; float vec[4], dir[3], quat[4], radius, ctime;
/* TODO: Make sure this doesn't crash. */
#if 0
/* only happens on reload file, but violates depsgraph still... fix! */ /* only happens on reload file, but violates depsgraph still... fix! */
if (par->curve_cache == NULL) { if (par->curve_cache == NULL) {
if (scene == NULL) { if (scene == NULL) {
return false; return false;
} }
BKE_displist_make_curveTypes(scene, par, 0); BKE_displist_make_curveTypes(eval_ctx, scene, par, 0);
} }
#endif
if (par->curve_cache->path == NULL) { if (par->curve_cache->path == NULL) {
return false; return false;
@@ -2096,7 +2099,7 @@ static bool where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat
} }
/* note, scene is the active scene while actual_scene is the scene the object resides in */ /* note, scene is the active scene while actual_scene is the scene the object resides in */
void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime, void BKE_object_where_is_calc_time_ex(EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime,
RigidBodyWorld *rbw, float r_originmat[3][3]) RigidBodyWorld *rbw, float r_originmat[3][3])
{ {
if (ob == NULL) return; if (ob == NULL) return;
@@ -2132,7 +2135,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
bConstraintOb *cob; bConstraintOb *cob;
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
BKE_constraints_solve(&ob->constraints, cob, ctime); BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob); BKE_constraints_clear_evalob(cob);
} }
@@ -2141,9 +2144,9 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
else ob->transflag &= ~OB_NEG_SCALE; else ob->transflag &= ~OB_NEG_SCALE;
} }
void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) void BKE_object_where_is_calc_time(EvaluationContext *eval_ctx, Scene *scene, Object *ob, float ctime)
{ {
BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL, NULL); BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, ctime, NULL, NULL);
} }
/* get object transformation matrix without recalculating dependencies and /* get object transformation matrix without recalculating dependencies and
@@ -2168,17 +2171,17 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
} }
} }
void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3]) void BKE_object_where_is_calc_ex(EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
{ {
BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat); BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
} }
void BKE_object_where_is_calc(Scene *scene, Object *ob) void BKE_object_where_is_calc(EvaluationContext *eval_ctx, Scene *scene, Object *ob)
{ {
BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL, NULL); BKE_object_where_is_calc_time_ex(eval_ctx, scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
} }
/* for calculation of the inverse parent transform, only used for editor */ /* for calculation of the inverse parent transform, only used for editor */
void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob) void BKE_object_workob_calc_parent(EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *workob)
{ {
BKE_object_workob_clear(workob); BKE_object_workob_clear(workob);
@@ -2200,7 +2203,7 @@ void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob)
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
BKE_object_where_is_calc(scene, workob); BKE_object_where_is_calc(eval_ctx, scene, workob);
} }
/* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */ /* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */
@@ -2679,7 +2682,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
copy_m4_m4(ob->obmat, ob->proxy_from->obmat); copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
} }
else else
BKE_object_where_is_calc_ex(scene, rbw, ob, NULL); BKE_object_where_is_calc_ex(eval_ctx, scene, rbw, ob, NULL);
} }
if (ob->recalc & OB_RECALC_DATA) { if (ob->recalc & OB_RECALC_DATA) {
@@ -3625,7 +3628,7 @@ static void object_cacheIgnoreClear(Object *ob, int state)
/* Note: this function should eventually be replaced by depsgraph functionality. /* Note: this function should eventually be replaced by depsgraph functionality.
* Avoid calling this in new code unless there is a very good reason for it! * Avoid calling this in new code unless there is a very good reason for it!
*/ */
bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_mesh, bool BKE_object_modifier_update_subframe(EvaluationContext *eval_ctx, Scene *scene, Object *ob, bool update_mesh,
int parent_recursion, float frame, int parent_recursion, float frame,
int type) int type)
{ {
@@ -3650,8 +3653,8 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
if (parent_recursion) { if (parent_recursion) {
int recursion = parent_recursion - 1; int recursion = parent_recursion - 1;
bool no_update = false; bool no_update = false;
if (ob->parent) no_update |= BKE_object_modifier_update_subframe(scene, ob->parent, 0, recursion, frame, type); if (ob->parent) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->parent, 0, recursion, frame, type);
if (ob->track) no_update |= BKE_object_modifier_update_subframe(scene, ob->track, 0, recursion, frame, type); if (ob->track) no_update |= BKE_object_modifier_update_subframe(eval_ctx, scene, ob->track, 0, recursion, frame, type);
/* skip subframe if object is parented /* skip subframe if object is parented
* to vertex of a dynamic paint canvas */ * to vertex of a dynamic paint canvas */
@@ -3668,7 +3671,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
cti->get_constraint_targets(con, &targets); cti->get_constraint_targets(con, &targets);
for (ct = targets.first; ct; ct = ct->next) { for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar) if (ct->tar)
BKE_object_modifier_update_subframe(scene, ct->tar, 0, recursion, frame, type); BKE_object_modifier_update_subframe(eval_ctx, scene, ct->tar, 0, recursion, frame, type);
} }
/* free temp targets */ /* free temp targets */
if (cti->flush_constraint_targets) if (cti->flush_constraint_targets)
@@ -3688,7 +3691,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
object_cacheIgnoreClear(ob, 0); object_cacheIgnoreClear(ob, 0);
} }
else else
BKE_object_where_is_calc_time(scene, ob, frame); BKE_object_where_is_calc_time(eval_ctx, scene, ob, frame);
/* for curve following objects, parented curve has to be updated too */ /* for curve following objects, parented curve has to be updated too */
if (ob->type == OB_CURVE) { if (ob->type == OB_CURVE) {
@@ -3699,7 +3702,7 @@ bool BKE_object_modifier_update_subframe(Scene *scene, Object *ob, bool update_m
if (ob->type == OB_ARMATURE) { if (ob->type == OB_ARMATURE) {
bArmature *arm = ob->data; bArmature *arm = ob->data;
BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM); BKE_animsys_evaluate_animdata(scene, &arm->id, arm->adt, frame, ADT_RECALC_ANIM);
BKE_pose_where_is(scene, ob); BKE_pose_where_is(eval_ctx, scene, ob);
} }
return false; return false;

View File

@@ -397,7 +397,7 @@ static void make_duplis_frames(const DupliContext *ctx)
* However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine! * However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine!
*/ */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
make_dupli(ctx, ob, ob->obmat, scene->r.cfra, false, false); make_dupli(ctx, ob, ob->obmat, scene->r.cfra, false, false);
} }
@@ -411,7 +411,7 @@ static void make_duplis_frames(const DupliContext *ctx)
scene->r.cfra = cfrao; scene->r.cfra = cfrao;
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, (float)scene->r.cfra);
/* but, to make sure unkeyed object transforms are still sane, /* but, to make sure unkeyed object transforms are still sane,
* let's copy object's original data back over * let's copy object's original data back over
@@ -546,13 +546,13 @@ static void make_duplis_verts(const DupliContext *ctx)
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO : CD_MASK_BAREMESH); CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO : CD_MASK_BAREMESH);
if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) { if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
vdd.dm = mesh_create_derived_render(scene, parent, dm_mask); vdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
} }
else if (em) { else if (em) {
vdd.dm = editbmesh_get_derived_cage(scene, parent, em, dm_mask); vdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
} }
else { else {
vdd.dm = mesh_get_derived_final(scene, parent, dm_mask); vdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
} }
vdd.edit_btmesh = me->edit_btmesh; vdd.edit_btmesh = me->edit_btmesh;
@@ -814,13 +814,13 @@ static void make_duplis_faces(const DupliContext *ctx)
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO | CD_MASK_MLOOPUV : CD_MASK_BAREMESH); CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO | CD_MASK_MLOOPUV : CD_MASK_BAREMESH);
if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) { if (ctx->eval_ctx->mode == DAG_EVAL_RENDER) {
fdd.dm = mesh_create_derived_render(scene, parent, dm_mask); fdd.dm = mesh_create_derived_render(ctx->eval_ctx, scene, parent, dm_mask);
} }
else if (em) { else if (em) {
fdd.dm = editbmesh_get_derived_cage(scene, parent, em, dm_mask); fdd.dm = editbmesh_get_derived_cage(ctx->eval_ctx, scene, parent, em, dm_mask);
} }
else { else {
fdd.dm = mesh_get_derived_final(scene, parent, dm_mask); fdd.dm = mesh_get_derived_final(ctx->eval_ctx, scene, parent, dm_mask);
} }
if (use_texcoords) { if (use_texcoords) {
@@ -898,6 +898,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
ParticleSimulationData sim = {NULL}; ParticleSimulationData sim = {NULL};
sim.eval_ctx = ctx->eval_ctx;
sim.scene = scene; sim.scene = scene;
sim.ob = par; sim.ob = par;
sim.psys = psys; sim.psys = psys;
@@ -1079,7 +1080,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
} }
else { else {
/* to give ipos in object correct offset */ /* to give ipos in object correct offset */
BKE_object_where_is_calc_time(scene, ob, ctime - pa_time); BKE_object_where_is_calc_time(ctx->eval_ctx, scene, ob, ctime - pa_time);
copy_v3_v3(vec, obmat[3]); copy_v3_v3(vec, obmat[3]);
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
@@ -1271,7 +1272,7 @@ int count_duplilist(Object *ob)
return 1; return 1;
} }
DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist) DupliApplyData *duplilist_apply(EvaluationContext *eval_ctx, Object *ob, Scene *scene, ListBase *duplilist)
{ {
DupliApplyData *apply_data = NULL; DupliApplyData *apply_data = NULL;
int num_objects = BLI_listbase_count(duplilist); int num_objects = BLI_listbase_count(duplilist);
@@ -1287,7 +1288,7 @@ DupliApplyData *duplilist_apply(Object *ob, Scene *scene, ListBase *duplilist)
for (dob = duplilist->first, i = 0; dob; dob = dob->next, ++i) { for (dob = duplilist->first, i = 0; dob; dob = dob->next, ++i) {
/* make sure derivedmesh is calculated once, before drawing */ /* make sure derivedmesh is calculated once, before drawing */
if (scene && !(dob->ob->transflag & OB_DUPLICALCDERIVED) && dob->ob->type == OB_MESH) { if (scene && !(dob->ob->transflag & OB_DUPLICALCDERIVED) && dob->ob->type == OB_MESH) {
mesh_get_derived_final(scene, dob->ob, scene->customdata_mask); mesh_get_derived_final(eval_ctx, scene, dob->ob, scene->customdata_mask);
dob->ob->transflag |= OB_DUPLICALCDERIVED; dob->ob->transflag |= OB_DUPLICALCDERIVED;
} }
} }

View File

@@ -113,7 +113,7 @@ void BKE_object_eval_parent(EvaluationContext *UNUSED(eval_ctx),
} }
} }
void BKE_object_eval_constraints(EvaluationContext *UNUSED(eval_ctx), void BKE_object_eval_constraints(EvaluationContext *eval_ctx,
Scene *scene, Scene *scene,
Object *ob) Object *ob)
{ {
@@ -132,7 +132,7 @@ void BKE_object_eval_constraints(EvaluationContext *UNUSED(eval_ctx),
* *
*/ */
cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
BKE_constraints_solve(&ob->constraints, cob, ctime); BKE_constraints_solve(eval_ctx, &ob->constraints, cob, ctime);
BKE_constraints_clear_evalob(cob); BKE_constraints_clear_evalob(cob);
} }
@@ -184,10 +184,10 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
} }
#endif #endif
if (em) { if (em) {
makeDerivedMesh(scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */ makeDerivedMesh(eval_ctx, scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */
} }
else { else {
makeDerivedMesh(scene, ob, NULL, data_mask, false); makeDerivedMesh(eval_ctx, scene, ob, NULL, data_mask, false);
} }
break; break;
} }
@@ -199,7 +199,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
} }
} }
else { else {
BKE_pose_where_is(scene, ob); BKE_pose_where_is(eval_ctx, scene, ob);
} }
break; break;
@@ -210,11 +210,11 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
case OB_CURVE: case OB_CURVE:
case OB_SURF: case OB_SURF:
case OB_FONT: case OB_FONT:
BKE_displist_make_curveTypes(scene, ob, 0); BKE_displist_make_curveTypes(eval_ctx, scene, ob, 0);
break; break;
case OB_LATTICE: case OB_LATTICE:
BKE_lattice_modifiers_calc(scene, ob); BKE_lattice_modifiers_calc(eval_ctx, scene, ob);
break; break;
case OB_EMPTY: case OB_EMPTY:
@@ -267,7 +267,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
ob->transflag |= OB_DUPLIPARTS; ob->transflag |= OB_DUPLIPARTS;
} }
particle_system_update(scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER)); particle_system_update(eval_ctx, scene, ob, psys, (eval_ctx->mode == DAG_EVAL_RENDER));
psys = psys->next; psys = psys->next;
} }
else if (psys->flag & PSYS_DELETE) { else if (psys->flag & PSYS_DELETE) {
@@ -285,7 +285,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
* the derivedmesh must be created before init_render_mesh, * the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */ * since object_duplilist does dupliparticles before that */
CustomDataMask data_mask = CD_MASK_BAREMESH | CD_MASK_MFACE | CD_MASK_MTFACE | CD_MASK_MCOL; CustomDataMask data_mask = CD_MASK_BAREMESH | CD_MASK_MFACE | CD_MASK_MTFACE | CD_MASK_MCOL;
dm = mesh_create_derived_render(scene, ob, data_mask); dm = mesh_create_derived_render(eval_ctx, scene, ob, data_mask);
dm->release(dm); dm->release(dm);
for (psys = ob->particlesystem.first; psys; psys = psys->next) for (psys = ob->particlesystem.first; psys; psys = psys->next)

View File

@@ -823,7 +823,7 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
/** /**
* \param need_mask So the DerivedMesh thats returned has mask data * \param need_mask So the DerivedMesh thats returned has mask data
*/ */
void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, void BKE_sculpt_update_mesh_elements(EvaluationContext *eval_ctx, Scene *scene, Sculpt *sd, Object *ob,
bool need_pmap, bool need_mask) bool need_pmap, bool need_mask)
{ {
DerivedMesh *dm; DerivedMesh *dm;
@@ -860,7 +860,7 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL; ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL;
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH);
if (mmd) { if (mmd) {
ss->multires = mmd; ss->multires = mmd;
@@ -893,7 +893,7 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL); ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
BKE_crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos); BKE_crazyspace_build_sculpt(eval_ctx, scene, ob, &ss->deform_imats, &ss->deform_cos);
BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos); BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
for (a = 0; a < me->totvert; ++a) { for (a = 0; a < me->totvert; ++a) {

View File

@@ -1845,7 +1845,7 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
} }
} }
int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, int index, float time) int do_guides(EvaluationContext *eval_ctx, ParticleSettings *part, ListBase *effectors, ParticleKey *state, int index, float time)
{ {
CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL; CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve : NULL;
CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL; CurveMapping *roughcurve = (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) ? part->roughcurve : NULL;
@@ -1908,7 +1908,7 @@ int do_guides(ParticleSettings *part, ListBase *effectors, ParticleKey *state, i
/* curve taper */ /* curve taper */
if (cu->taperobj) if (cu->taperobj)
mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100)); mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eval_ctx, eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100));
else { /* curve size*/ else { /* curve size*/
if (cu->flag & CU_PATH_RADIUS) { if (cu->flag & CU_PATH_RADIUS) {
@@ -2709,7 +2709,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) { if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) {
for (k = 0, ca = cache[p]; k <= segments; k++, ca++) for (k = 0, ca = cache[p]; k <= segments; k++, ca++)
/* ca is safe to cast, since only co and vel are used */ /* ca is safe to cast, since only co and vel are used */
do_guides(sim->psys->part, sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)segments); do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)segments);
} }
/* lattices have to be calculated separately to avoid mixups between effector calculations */ /* lattices have to be calculated separately to avoid mixups between effector calculations */
@@ -2757,7 +2757,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re
if (vg_length) if (vg_length)
MEM_freeN(vg_length); MEM_freeN(vg_length);
} }
void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cfra, const bool use_render_params) void psys_cache_edit_paths(EvaluationContext *eval_ctx, Scene *scene, Object *ob, PTCacheEdit *edit, float cfra, const bool use_render_params)
{ {
ParticleCacheKey *ca, **cache = edit->pathcache; ParticleCacheKey *ca, **cache = edit->pathcache;
ParticleEditSettings *pset = &scene->toolsettings->particle; ParticleEditSettings *pset = &scene->toolsettings->particle;
@@ -2948,6 +2948,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
if (psys) { if (psys) {
ParticleSimulationData sim = {0}; ParticleSimulationData sim = {0};
sim.eval_ctx = eval_ctx;
sim.scene = scene; sim.scene = scene;
sim.ob = ob; sim.ob = ob;
sim.psys = psys; sim.psys = psys;
@@ -3779,7 +3780,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
mul_mat3_m4_v3(hairmat, state->vel); mul_mat3_m4_v3(hairmat, state->vel);
if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE) == 0) { if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE) == 0) {
do_guides(sim->psys->part, sim->psys->effectors, state, p, state->time); do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, state, p, state->time);
/* TODO: proper velocity handling */ /* TODO: proper velocity handling */
} }
@@ -4306,9 +4307,10 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
madd_v3_v3fl(center, yvec, bb->offset[1]); madd_v3_v3fl(center, yvec, bb->offset[1]);
} }
void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) void psys_apply_hair_lattice(EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys)
{ {
ParticleSimulationData sim = {0}; ParticleSimulationData sim = {0};
sim.eval_ctx = eval_ctx;
sim.scene = scene; sim.scene = scene;
sim.ob = ob; sim.ob = ob;
sim.psys = psys; sim.psys = psys;

View File

@@ -702,7 +702,7 @@ void do_child_modifiers(ParticleThreadContext *ctx, ParticleSimulationData *sim,
if (part->flag & PART_CHILD_EFFECT) if (part->flag & PART_CHILD_EFFECT)
/* state is safe to cast, since only co and vel are used */ /* state is safe to cast, since only co and vel are used */
guided = do_guides(sim->psys->part, sim->psys->effectors, (ParticleKey *)state, cpa->parent, t); guided = do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, (ParticleKey *)state, cpa->parent, t);
if (guided == 0) { if (guided == 0) {
float orco_offset[3]; float orco_offset[3];

View File

@@ -980,14 +980,14 @@ void psys_get_birth_coords(ParticleSimulationData *sim, ParticleData *pa, Partic
} }
/* recursively evaluate emitter parent anim at cfra */ /* recursively evaluate emitter parent anim at cfra */
static void evaluate_emitter_anim(Scene *scene, Object *ob, float cfra) static void evaluate_emitter_anim(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float cfra)
{ {
if (ob->parent) if (ob->parent)
evaluate_emitter_anim(scene, ob->parent, cfra); evaluate_emitter_anim(eval_ctx, scene, ob->parent, cfra);
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
BKE_object_where_is_calc_time(scene, ob, cfra); BKE_object_where_is_calc_time(eval_ctx, scene, ob, cfra);
} }
/* sets particle to the emitter surface with initial velocity & rotation */ /* sets particle to the emitter surface with initial velocity & rotation */
@@ -1001,7 +1001,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* get precise emitter matrix if particle is born */ /* get precise emitter matrix if particle is born */
if (part->type != PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { if (part->type != PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
evaluate_emitter_anim(sim->scene, sim->ob, pa->time); evaluate_emitter_anim(sim->eval_ctx, sim->scene, sim->ob, pa->time);
psys->flag |= PSYS_OB_ANIM_RESTORE; psys->flag |= PSYS_OB_ANIM_RESTORE;
} }
@@ -1133,7 +1133,8 @@ static void set_keyed_keys(ParticleSimulationData *sim)
int totpart = psys->totpart, k, totkeys = psys->totkeyed; int totpart = psys->totpart, k, totkeys = psys->totkeyed;
int keyed_flag = 0; int keyed_flag = 0;
ksim.scene= sim->scene; ksim.eval_ctx = sim->eval_ctx;
ksim.scene = sim->scene;
/* no proper targets so let's clear and bail out */ /* no proper targets so let's clear and bail out */
if (psys->totkeyed==0) { if (psys->totkeyed==0) {
@@ -1294,7 +1295,7 @@ void psys_update_particle_tree(ParticleSystem *psys, float cfra)
static void psys_update_effectors(ParticleSimulationData *sim) static void psys_update_effectors(ParticleSimulationData *sim)
{ {
pdEndEffectors(&sim->psys->effectors); pdEndEffectors(&sim->psys->effectors);
sim->psys->effectors = pdInitEffectors(sim->scene, sim->ob, sim->psys, sim->psys->effectors = pdInitEffectors(sim->eval_ctx, sim->scene, sim->ob, sim->psys,
sim->psys->part->effector_weights, true); sim->psys->part->effector_weights, true);
precalc_guides(sim, sim->psys->effectors); precalc_guides(sim, sim->psys->effectors);
} }
@@ -2115,7 +2116,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
tkey.time=pa->state.time; tkey.time=pa->state.time;
if (part->type != PART_HAIR) { if (part->type != PART_HAIR) {
if (do_guides(sim->psys->part, sim->psys->effectors, &tkey, p, time)) { if (do_guides(sim->eval_ctx, sim->psys->part, sim->psys->effectors, &tkey, p, time)) {
copy_v3_v3(pa->state.co,tkey.co); copy_v3_v3(pa->state.co,tkey.co);
/* guides don't produce valid velocity */ /* guides don't produce valid velocity */
sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co); sub_v3_v3v3(pa->state.vel, tkey.co, pa->prev_state.co);
@@ -3191,7 +3192,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
psys->hair_out_dm = CDDM_copy(psys->hair_in_dm); psys->hair_out_dm = CDDM_copy(psys->hair_in_dm);
psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts); psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts);
clothModifier_do(psys->clmd, sim->scene, sim->ob, psys->hair_in_dm, deformedVerts); clothModifier_do(psys->clmd, sim->eval_ctx, sim->scene, sim->ob, psys->hair_in_dm, deformedVerts);
CDDM_apply_vert_coords(psys->hair_out_dm, deformedVerts); CDDM_apply_vert_coords(psys->hair_out_dm, deformedVerts);
@@ -4151,7 +4152,7 @@ static int hair_needs_recalc(ParticleSystem *psys)
/* main particle update call, checks that things are ok on the large scale and /* 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 */ * 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(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, ParticleSystem *psys, const bool use_render_params)
{ {
ParticleSimulationData sim= {0}; ParticleSimulationData sim= {0};
ParticleSettings *part = psys->part; ParticleSettings *part = psys->part;
@@ -4165,10 +4166,11 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys, cons
cfra= BKE_scene_frame_get(scene); cfra= BKE_scene_frame_get(scene);
sim.scene= scene; sim.eval_ctx = eval_ctx;
sim.ob= ob; sim.scene = scene;
sim.psys= psys; sim.ob = ob;
sim.psmd= psys_get_modifier(ob, psys); sim.psys = psys;
sim.psmd = psys_get_modifier(ob, psys);
/* system was already updated from modifier stack */ /* system was already updated from modifier stack */
if (sim.psmd->flag & eParticleSystemFlag_psys_updated) { if (sim.psmd->flag & eParticleSystemFlag_psys_updated) {
@@ -4311,7 +4313,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys, cons
/* make sure emitter is left at correct time (particle emission can change this) */ /* make sure emitter is left at correct time (particle emission can change this) */
if (psys->flag & PSYS_OB_ANIM_RESTORE) { if (psys->flag & PSYS_OB_ANIM_RESTORE) {
evaluate_emitter_anim(scene, ob, cfra); evaluate_emitter_anim(eval_ctx, scene, ob, cfra);
psys->flag &= ~PSYS_OB_ANIM_RESTORE; psys->flag &= ~PSYS_OB_ANIM_RESTORE;
} }

View File

@@ -1226,7 +1226,7 @@ static void rigidbody_update_sim_world(Scene *scene, RigidBodyWorld *rbw)
rigidbody_update_ob_array(rbw); rigidbody_update_ob_array(rbw);
} }
static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo) static void rigidbody_update_sim_ob(struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, Object *ob, RigidBodyOb *rbo)
{ {
float loc[3]; float loc[3];
float rot[4]; float rot[4];
@@ -1274,7 +1274,7 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o
ListBase *effectors; ListBase *effectors;
/* get effectors present in the group specified by effector_weights */ /* get effectors present in the group specified by effector_weights */
effectors = pdInitEffectors(scene, ob, NULL, effector_weights, true); effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, effector_weights, true);
if (effectors) { if (effectors) {
float eff_force[3] = {0.0f, 0.0f, 0.0f}; float eff_force[3] = {0.0f, 0.0f, 0.0f};
float eff_loc[3], eff_vel[3]; float eff_loc[3], eff_vel[3];
@@ -1315,7 +1315,7 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o
* *
* \param rebuild Rebuild entire simulation * \param rebuild Rebuild entire simulation
*/ */
static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool rebuild) static void rigidbody_update_simulation(struct EvaluationContext *eval_ctx, Scene *scene, RigidBodyWorld *rbw, bool rebuild)
{ {
GroupObject *go; GroupObject *go;
@@ -1352,7 +1352,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
/* validate that we've got valid object set up here... */ /* validate that we've got valid object set up here... */
RigidBodyOb *rbo = ob->rigidbody_object; RigidBodyOb *rbo = ob->rigidbody_object;
/* update transformation matrix of the object so we don't get a frame of lag for simple animations */ /* update transformation matrix of the object so we don't get a frame of lag for simple animations */
BKE_object_where_is_calc(scene, ob); BKE_object_where_is_calc(eval_ctx, scene, ob);
if (rbo == NULL) { if (rbo == NULL) {
/* Since this object is included in the sim group but doesn't have /* Since this object is included in the sim group but doesn't have
@@ -1386,7 +1386,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
} }
/* update simulation object... */ /* update simulation object... */
rigidbody_update_sim_ob(scene, rbw, ob, rbo); rigidbody_update_sim_ob(eval_ctx, scene, rbw, ob, rbo);
} }
} }
@@ -1400,7 +1400,7 @@ static void rigidbody_update_simulation(Scene *scene, RigidBodyWorld *rbw, bool
/* validate that we've got valid object set up here... */ /* validate that we've got valid object set up here... */
RigidBodyCon *rbc = ob->rigidbody_constraint; RigidBodyCon *rbc = ob->rigidbody_constraint;
/* update transformation matrix of the object so we don't get a frame of lag for simple animations */ /* update transformation matrix of the object so we don't get a frame of lag for simple animations */
BKE_object_where_is_calc(scene, ob); BKE_object_where_is_calc(eval_ctx, scene, ob);
if (rbc == NULL) { if (rbc == NULL) {
/* Since this object is included in the group but doesn't have /* Since this object is included in the group but doesn't have
@@ -1559,7 +1559,7 @@ void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw)
/* Rebuild rigid body world */ /* Rebuild rigid body world */
/* NOTE: this needs to be called before frame update to work correctly */ /* NOTE: this needs to be called before frame update to work correctly */
void BKE_rigidbody_rebuild_world(Scene *scene, float ctime) void BKE_rigidbody_rebuild_world(struct EvaluationContext *eval_ctx, Scene *scene, float ctime)
{ {
RigidBodyWorld *rbw = scene->rigidbody_world; RigidBodyWorld *rbw = scene->rigidbody_world;
PointCache *cache; PointCache *cache;
@@ -1578,7 +1578,7 @@ void BKE_rigidbody_rebuild_world(Scene *scene, float ctime)
if (ctime == startframe + 1 && rbw->ltime == startframe) { if (ctime == startframe + 1 && rbw->ltime == startframe) {
if (cache->flag & PTCACHE_OUTDATED) { if (cache->flag & PTCACHE_OUTDATED) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
rigidbody_update_simulation(scene, rbw, true); rigidbody_update_simulation(eval_ctx, scene, rbw, true);
BKE_ptcache_validate(cache, (int)ctime); BKE_ptcache_validate(cache, (int)ctime);
cache->last_exact = 0; cache->last_exact = 0;
cache->flag &= ~PTCACHE_REDO_NEEDED; cache->flag &= ~PTCACHE_REDO_NEEDED;
@@ -1587,7 +1587,7 @@ void BKE_rigidbody_rebuild_world(Scene *scene, float ctime)
} }
/* Run RigidBody simulation for the specified physics world */ /* Run RigidBody simulation for the specified physics world */
void BKE_rigidbody_do_simulation(Scene *scene, float ctime) void BKE_rigidbody_do_simulation(struct EvaluationContext *eval_ctx, Scene *scene, float ctime)
{ {
float timestep; float timestep;
RigidBodyWorld *rbw = scene->rigidbody_world; RigidBodyWorld *rbw = scene->rigidbody_world;
@@ -1631,7 +1631,7 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime)
} }
/* update and validate simulation */ /* update and validate simulation */
rigidbody_update_simulation(scene, rbw, false); rigidbody_update_simulation(eval_ctx, scene, rbw, false);
/* calculate how much time elapsed since last step in seconds */ /* calculate how much time elapsed since last step in seconds */
timestep = 1.0f / (float)FPS * (ctime - rbw->ltime) * rbw->time_scale; timestep = 1.0f / (float)FPS * (ctime - rbw->ltime) * rbw->time_scale;
@@ -1687,7 +1687,7 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) {}
/* -------------------- */ /* -------------------- */
/* Depsgraph evaluation */ /* Depsgraph evaluation */
void BKE_rigidbody_rebuild_sim(struct EvaluationContext *UNUSED(eval_ctx), void BKE_rigidbody_rebuild_sim(struct EvaluationContext *eval_ctx,
Scene *scene) Scene *scene)
{ {
float ctime = BKE_scene_frame_get(scene); float ctime = BKE_scene_frame_get(scene);
@@ -1698,11 +1698,11 @@ void BKE_rigidbody_rebuild_sim(struct EvaluationContext *UNUSED(eval_ctx),
/* rebuild sim data (i.e. after resetting to start of timeline) */ /* rebuild sim data (i.e. after resetting to start of timeline) */
if (BKE_scene_check_rigidbody_active(scene)) { if (BKE_scene_check_rigidbody_active(scene)) {
BKE_rigidbody_rebuild_world(scene, ctime); BKE_rigidbody_rebuild_world(eval_ctx, scene, ctime);
} }
} }
void BKE_rigidbody_eval_simulation(struct EvaluationContext *UNUSED(eval_ctx), void BKE_rigidbody_eval_simulation(struct EvaluationContext *eval_ctx,
Scene *scene) Scene *scene)
{ {
float ctime = BKE_scene_frame_get(scene); float ctime = BKE_scene_frame_get(scene);
@@ -1713,7 +1713,7 @@ void BKE_rigidbody_eval_simulation(struct EvaluationContext *UNUSED(eval_ctx),
/* evaluate rigidbody sim */ /* evaluate rigidbody sim */
if (BKE_scene_check_rigidbody_active(scene)) { if (BKE_scene_check_rigidbody_active(scene)) {
BKE_rigidbody_do_simulation(scene, ctime); BKE_rigidbody_do_simulation(eval_ctx, scene, ctime);
} }
} }

View File

@@ -3306,7 +3306,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene); BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene);
ibuf = sequencer_view3d_cb( ibuf = sequencer_view3d_cb(
/* set for OpenGL render (NULL when scrubbing) */ /* set for OpenGL render (NULL when scrubbing) */
scene, BKE_scene_layer_from_scene_get(scene), camera, width, height, IB_rect, context->eval_ctx, scene, BKE_scene_layer_from_scene_get(scene), camera, width, height, IB_rect,
context->scene->r.seq_prev_type, context->scene->r.seq_prev_type,
(context->scene->r.seq_flag & R_SEQ_SOLID_TEX) != 0, (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) != 0,
use_gpencil, use_background, scene->r.alphamode, use_gpencil, use_background, scene->r.alphamode,

View File

@@ -83,6 +83,8 @@
#include "BKE_smoke.h" #include "BKE_smoke.h"
#include "BKE_texture.h" #include "BKE_texture.h"
#include "DEG_depsgraph.h"
#include "RE_shader_ext.h" #include "RE_shader_ext.h"
#include "GPU_glew.h" #include "GPU_glew.h"
@@ -2071,7 +2073,7 @@ BLI_INLINE void apply_inflow_fields(SmokeFlowSettings *sfs, float emission_value
} }
} }
static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt) static void update_flowsfluids(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float dt)
{ {
Object **flowobjs = NULL; Object **flowobjs = NULL;
EmissionMap *emaps = NULL; EmissionMap *emaps = NULL;
@@ -2178,7 +2180,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
else { /* MOD_SMOKE_FLOW_SOURCE_MESH */ else { /* MOD_SMOKE_FLOW_SOURCE_MESH */
/* update flow object frame */ /* update flow object frame */
BLI_mutex_lock(&object_update_lock); BLI_mutex_lock(&object_update_lock);
BKE_object_modifier_update_subframe(scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke); BKE_object_modifier_update_subframe(eval_ctx, scene, collob, true, 5, BKE_scene_frame_get(scene), eModifierType_Smoke);
BLI_mutex_unlock(&object_update_lock); BLI_mutex_unlock(&object_update_lock);
/* apply flow */ /* apply flow */
@@ -2487,12 +2489,12 @@ static void update_effectors_task_cb(void *userdata, const int x)
} }
} }
static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt)) static void update_effectors(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeDomainSettings *sds, float UNUSED(dt))
{ {
ListBase *effectors; ListBase *effectors;
/* make sure smoke flow influence is 0.0f */ /* make sure smoke flow influence is 0.0f */
sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f; sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f;
effectors = pdInitEffectors(scene, ob, NULL, sds->effector_weights, true); effectors = pdInitEffectors(eval_ctx, scene, ob, NULL, sds->effector_weights, true);
if (effectors) { if (effectors) {
// precalculate wind forces // precalculate wind forces
@@ -2516,7 +2518,7 @@ static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings *sds,
pdEndEffectors(&effectors); pdEndEffectors(&effectors);
} }
static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps) static void step(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *domain_dm, float fps)
{ {
SmokeDomainSettings *sds = smd->domain; SmokeDomainSettings *sds = smd->domain;
/* stability values copied from wturbulence.cpp */ /* stability values copied from wturbulence.cpp */
@@ -2586,11 +2588,11 @@ static void step(Scene *scene, Object *ob, SmokeModifierData *smd, DerivedMesh *
for (substep = 0; substep < totalSubsteps; substep++) for (substep = 0; substep < totalSubsteps; substep++)
{ {
// calc animated obstacle velocities // calc animated obstacle velocities
update_flowsfluids(scene, ob, sds, dtSubdiv); update_flowsfluids(eval_ctx, scene, ob, sds, dtSubdiv);
update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps); update_obstacles(scene, ob, sds, dtSubdiv, substep, totalSubsteps);
if (sds->total_cells > 1) { if (sds->total_cells > 1) {
update_effectors(scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt update_effectors(eval_ctx, scene, ob, sds, dtSubdiv); // DG TODO? problem --> uses forces instead of velocity, need to check how they need to be changed with variable dt
smoke_step(sds->fluid, gravity, dtSubdiv); smoke_step(sds->fluid, gravity, dtSubdiv);
} }
} }
@@ -2683,7 +2685,7 @@ static DerivedMesh *createDomainGeometry(SmokeDomainSettings *sds, Object *ob)
return result; return result;
} }
static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm) static void smokeModifier_process(SmokeModifierData *smd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
{ {
if ((smd->type & MOD_SMOKE_TYPE_FLOW)) if ((smd->type & MOD_SMOKE_TYPE_FLOW))
{ {
@@ -2806,11 +2808,11 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLay
} }
step(scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base); step(eval_ctx, scene, ob, smd, dm, scene->r.frs_sec / scene->r.frs_sec_base);
} }
// create shadows before writing cache so they get stored // create shadows before writing cache so they get stored
smoke_calc_transparency(sds, sl); smoke_calc_transparency(sds, eval_ctx->scene_layer);
if (sds->wt && sds->total_cells > 1) { if (sds->wt && sds->total_cells > 1) {
smoke_turbulence_step(sds->wt, sds->fluid); smoke_turbulence_step(sds->wt, sds->fluid);
@@ -2827,13 +2829,13 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, SceneLay
} }
} }
struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, SceneLayer *sl, Object *ob, DerivedMesh *dm) struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, DerivedMesh *dm)
{ {
/* lock so preview render does not read smoke data while it gets modified */ /* lock so preview render does not read smoke data while it gets modified */
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE); BLI_rw_mutex_lock(smd->domain->fluid_mutex, THREAD_LOCK_WRITE);
smokeModifier_process(smd, scene, sl, ob, dm); smokeModifier_process(smd, eval_ctx, scene, ob, dm);
if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain)
BLI_rw_mutex_unlock(smd->domain->fluid_mutex); BLI_rw_mutex_unlock(smd->domain->fluid_mutex);

View File

@@ -81,6 +81,8 @@ variables on the UI for now
#include "BKE_mesh.h" #include "BKE_mesh.h"
#include "BKE_scene.h" #include "BKE_scene.h"
#include "DEG_depsgraph.h"
#include "PIL_time.h" #include "PIL_time.h"
/* callbacks for errors and interrupts and some goo */ /* callbacks for errors and interrupts and some goo */
@@ -1544,12 +1546,12 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
} }
static void scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow) static void scan_for_ext_spring_forces(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float timenow)
{ {
SoftBody *sb = ob->soft; SoftBody *sb = ob->soft;
ListBase *do_effector = NULL; ListBase *do_effector = NULL;
do_effector = pdInitEffectors(scene, ob, NULL, sb->effector_weights, true); do_effector = pdInitEffectors(eval_ctx, scene, ob, NULL, sb->effector_weights, true);
_scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector); _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector);
pdEndEffectors(&do_effector); pdEndEffectors(&do_effector);
} }
@@ -1561,7 +1563,7 @@ static void *exec_scan_for_ext_spring_forces(void *data)
return NULL; return NULL;
} }
static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void))) static void sb_sfesf_threads_run(struct EvaluationContext *eval_ctx, Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void)))
{ {
ListBase *do_effector = NULL; ListBase *do_effector = NULL;
ListBase threads; ListBase threads;
@@ -1569,7 +1571,7 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,
int i, totthread, left, dec; int i, totthread, left, dec;
int lowsprings =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */ int lowsprings =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
do_effector= pdInitEffectors(scene, ob, NULL, ob->soft->effector_weights, true); do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, ob->soft->effector_weights, true);
/* figure the number of threads while preventing pretty pointless threading overhead */ /* figure the number of threads while preventing pretty pointless threading overhead */
totthread= BKE_scene_num_threads(scene); totthread= BKE_scene_num_threads(scene);
@@ -2233,7 +2235,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
MEM_freeN(sb_threads); MEM_freeN(sb_threads);
} }
static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, float forcetime, float timenow) static void softbody_calc_forcesEx(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float forcetime, float timenow)
{ {
/* rule we never alter free variables :bp->vec bp->pos in here ! /* rule we never alter free variables :bp->vec bp->pos in here !
* this will ruin adaptive stepsize AKA heun! (BM) * this will ruin adaptive stepsize AKA heun! (BM)
@@ -2249,7 +2251,7 @@ static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, flo
/* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */ /* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */
/* check conditions for various options */ /* check conditions for various options */
do_deflector= query_external_colliders(sl, sb->collision_group); do_deflector= query_external_colliders(eval_ctx->scene_layer, sb->collision_group);
/* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */ /* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2258,10 +2260,10 @@ static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, flo
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
if (do_springcollision || do_aero) if (do_springcollision || do_aero)
sb_sfesf_threads_run(scene, ob, timenow, sb->totspring, NULL); sb_sfesf_threads_run(eval_ctx, scene, ob, timenow, sb->totspring, NULL);
/* after spring scan because it uses Effoctors too */ /* after spring scan because it uses Effoctors too */
do_effector= pdInitEffectors(scene, ob, NULL, sb->effector_weights, true); do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, sb->effector_weights, true);
if (do_deflector) { if (do_deflector) {
float defforce[3]; float defforce[3];
@@ -2278,11 +2280,11 @@ static void softbody_calc_forcesEx(Scene *scene, SceneLayer *sl, Object *ob, flo
} }
static void softbody_calc_forces(Scene *scene, SceneLayer *sl, Object *ob, float forcetime, float timenow) static void softbody_calc_forces(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float forcetime, float timenow)
{ {
/* redirection to the new threaded Version */ /* redirection to the new threaded Version */
if (!(G.debug_value & 0x10)) { // 16 if (!(G.debug_value & 0x10)) { // 16
softbody_calc_forcesEx(scene, sl, ob, forcetime, timenow); softbody_calc_forcesEx(eval_ctx, scene, ob, forcetime, timenow);
return; return;
} }
else { else {
@@ -2313,7 +2315,7 @@ static void softbody_calc_forces(Scene *scene, SceneLayer *sl, Object *ob, float
} }
/* check conditions for various options */ /* check conditions for various options */
do_deflector= query_external_colliders(sl, sb->collision_group); do_deflector= query_external_colliders(eval_ctx->scene_layer, sb->collision_group);
do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2321,9 +2323,9 @@ static void softbody_calc_forces(Scene *scene, SceneLayer *sl, Object *ob, float
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
if (do_springcollision || do_aero) scan_for_ext_spring_forces(scene, ob, timenow); if (do_springcollision || do_aero) scan_for_ext_spring_forces(eval_ctx, scene, ob, timenow);
/* after spring scan because it uses Effoctors too */ /* after spring scan because it uses Effoctors too */
do_effector= pdInitEffectors(scene, ob, NULL, ob->soft->effector_weights, true); do_effector= pdInitEffectors(eval_ctx, scene, ob, NULL, ob->soft->effector_weights, true);
if (do_deflector) { if (do_deflector) {
float defforce[3]; float defforce[3];
@@ -3510,7 +3512,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
} }
} }
static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb, float dtime) static void softbody_step(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SoftBody *sb, float dtime)
{ {
/* the simulator */ /* the simulator */
float forcetime; float forcetime;
@@ -3524,11 +3526,11 @@ static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb
*/ */
if (dtime < 0 || dtime > 10.5f) return; if (dtime < 0 || dtime > 10.5f) return;
ccd_update_deflector_hash(sl, sb->collision_group, ob, sb->scratch->colliderhash); ccd_update_deflector_hash(eval_ctx->scene_layer, sb->collision_group, ob, sb->scratch->colliderhash);
if (sb->scratch->needstobuildcollider) { if (sb->scratch->needstobuildcollider) {
if (query_external_colliders(sl, sb->collision_group)) { if (query_external_colliders(eval_ctx->scene_layer, sb->collision_group)) {
ccd_build_deflector_hash(sl, sb->collision_group, ob, sb->scratch->colliderhash); ccd_build_deflector_hash(eval_ctx->scene_layer, sb->collision_group, ob, sb->scratch->colliderhash);
} }
sb->scratch->needstobuildcollider=0; sb->scratch->needstobuildcollider=0;
} }
@@ -3558,12 +3560,12 @@ static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb
sb->scratch->flag &= ~SBF_DOFUZZY; sb->scratch->flag &= ~SBF_DOFUZZY;
/* do predictive euler step */ /* do predictive euler step */
softbody_calc_forces(scene, sl, ob, forcetime, timedone/dtime); softbody_calc_forces(eval_ctx, scene, ob, forcetime, timedone/dtime);
softbody_apply_forces(ob, forcetime, 1, NULL, mid_flags); softbody_apply_forces(ob, forcetime, 1, NULL, mid_flags);
/* crop new slope values to do averaged slope step */ /* crop new slope values to do averaged slope step */
softbody_calc_forces(scene, sl, ob, forcetime, timedone/dtime); softbody_calc_forces(eval_ctx, scene, ob, forcetime, timedone/dtime);
softbody_apply_forces(ob, forcetime, 2, &err, mid_flags); softbody_apply_forces(ob, forcetime, 2, &err, mid_flags);
softbody_apply_goalsnap(ob); softbody_apply_goalsnap(ob);
@@ -3644,7 +3646,7 @@ static void softbody_step(Scene *scene, SceneLayer *sl, Object *ob, SoftBody *sb
} }
/* simulates one step. framenr is in frames */ /* simulates one step. framenr is in frames */
void sbObjectStep(Scene *scene, SceneLayer *sl, Object *ob, float cfra, float (*vertexCos)[3], int numVerts) void sbObjectStep(struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
{ {
SoftBody *sb= ob->soft; SoftBody *sb= ob->soft;
PointCache *cache; PointCache *cache;
@@ -3759,7 +3761,7 @@ void sbObjectStep(Scene *scene, SceneLayer *sl, Object *ob, float cfra, float (*
dtime = framedelta*timescale; dtime = framedelta*timescale;
/* do simulation */ /* do simulation */
softbody_step(scene, sl, ob, sb, dtime); softbody_step(eval_ctx, scene, ob, sb, dtime);
softbody_to_object(ob, vertexCos, numVerts, 0); softbody_to_object(ob, vertexCos, numVerts, 0);

View File

@@ -62,8 +62,8 @@ ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSett
} }
// write bone nodes // write bone nodes
void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce, void ArmatureExporter::add_armature_bones(EvaluationContext *eval_ctx, Object *ob_arm,
SceneExporter *se, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects) std::list<Object *>& child_objects)
{ {
// write bone nodes // write bone nodes
@@ -77,7 +77,7 @@ void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
for (Bone *bone = (Bone *)armature->bonebase.first; bone; bone = bone->next) { for (Bone *bone = (Bone *)armature->bonebase.first; bone; bone = bone->next) {
// start from root bones // start from root bones
if (!bone->parent) if (!bone->parent)
add_bone_node(bone, ob_arm, sce, se, child_objects); add_bone_node(eval_ctx, bone, ob_arm, sce, se, child_objects);
} }
if (!is_edited) { if (!is_edited) {
@@ -157,7 +157,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
#endif #endif
// parent_mat is armature-space // parent_mat is armature-space
void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, void ArmatureExporter::add_bone_node(EvaluationContext *eval_ctx, Bone *bone, Object *ob_arm, Scene *sce,
SceneExporter *se, SceneExporter *se,
std::list<Object *>& child_objects) std::list<Object *>& child_objects)
{ {
@@ -231,7 +231,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
mul_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv); mul_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv);
} }
se->writeNodes(*i, sce); se->writeNodes(eval_ctx, *i, sce);
copy_m4_m4((*i)->parentinv, backup_parinv); copy_m4_m4((*i)->parentinv, backup_parinv);
child_objects.erase(i++); child_objects.erase(i++);
@@ -240,13 +240,13 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
} }
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects); add_bone_node(eval_ctx, child, ob_arm, sce, se, child_objects);
} }
node.end(); node.end();
} }
else { else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) { for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects); add_bone_node(eval_ctx, child, ob_arm, sce, se, child_objects);
} }
} }
} }

View File

@@ -60,7 +60,7 @@ public:
ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings); ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
// write bone nodes // write bone nodes
void add_armature_bones(Object *ob_arm, Scene *sce, SceneExporter *se, void add_armature_bones(struct EvaluationContext *eval_ctx, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects); std::list<Object *>& child_objects);
bool add_instance_controller(Object *ob); bool add_instance_controller(Object *ob);
@@ -85,7 +85,7 @@ private:
// Scene, SceneExporter and the list of child_objects // Scene, SceneExporter and the list of child_objects
// are required for writing bone parented objects // are required for writing bone parented objects
void add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se, void add_bone_node(struct EvaluationContext *eval_ctx, Bone *bone, Object *ob_arm, Scene *sce, SceneExporter *se,
std::list<Object *>& child_objects); std::list<Object *>& child_objects);
void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node); void add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node);

View File

@@ -179,7 +179,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
// COLLADA allows this through multiple <channel>s in <animation>. // COLLADA allows this through multiple <channel>s in <animation>.
// For this to work, we need to know objects that use a certain action. // For this to work, we need to know objects that use a certain action.
int DocumentExporter::exportCurrentScene(Scene *sce) int DocumentExporter::exportCurrentScene(EvaluationContext *eval_ctx, Scene *sce)
{ {
PointerRNA sceneptr, unit_settings; PointerRNA sceneptr, unit_settings;
PropertyRNA *system; /* unused , *scale; */ PropertyRNA *system; /* unused , *scale; */
@@ -316,7 +316,7 @@ int DocumentExporter::exportCurrentScene(Scene *sce)
se.setExportTransformationType(this->export_settings->export_transformation_type); se.setExportTransformationType(this->export_settings->export_transformation_type);
} }
se.exportScene(sce); se.exportScene(eval_ctx, sce);
// <scene> // <scene>
std::string scene_name(translate_id(id_name(sce))); std::string scene_name(translate_id(id_name(sce)));

View File

@@ -39,7 +39,7 @@ class DocumentExporter
{ {
public: public:
DocumentExporter(const ExportSettings *export_settings); DocumentExporter(const ExportSettings *export_settings);
int exportCurrentScene(Scene *sce); int exportCurrentScene(struct EvaluationContext *eval_ctx, Scene *sce);
void exportScenes(const char *filename); void exportScenes(const char *filename);
private: private:
const ExportSettings *export_settings; const ExportSettings *export_settings;

View File

@@ -43,17 +43,17 @@ void SceneExporter::setExportTransformationType(BC_export_transformation_type tr
this->transformation_type = transformation_type; this->transformation_type = transformation_type;
} }
void SceneExporter::exportScene(Scene *sce) void SceneExporter::exportScene(EvaluationContext *eval_ctx, Scene *sce)
{ {
// <library_visual_scenes> <visual_scene> // <library_visual_scenes> <visual_scene>
std::string id_naming = id_name(sce); std::string id_naming = id_name(sce);
openVisualScene(translate_id(id_naming), id_naming); openVisualScene(translate_id(id_naming), id_naming);
exportHierarchy(sce); exportHierarchy(eval_ctx, sce);
closeVisualScene(); closeVisualScene();
closeLibrary(); closeLibrary();
} }
void SceneExporter::exportHierarchy(Scene *sce) void SceneExporter::exportHierarchy(EvaluationContext *eval_ctx, Scene *sce)
{ {
LinkNode *node; LinkNode *node;
std::vector<Object *> base_objects; std::vector<Object *> base_objects;
@@ -85,13 +85,13 @@ void SceneExporter::exportHierarchy(Scene *sce)
Object *ob = base_objects[index]; Object *ob = base_objects[index];
if (bc_is_marked(ob)) { if (bc_is_marked(ob)) {
bc_remove_mark(ob); bc_remove_mark(ob);
writeNodes(ob, sce); writeNodes(eval_ctx, ob, sce);
} }
} }
} }
void SceneExporter::writeNodes(Object *ob, Scene *sce) void SceneExporter::writeNodes(EvaluationContext *eval_ctx, Object *ob, Scene *sce)
{ {
// Add associated armature first if available // Add associated armature first if available
bool armature_exported = false; bool armature_exported = false;
@@ -100,7 +100,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm); armature_exported = bc_is_in_Export_set(this->export_settings->export_set, ob_arm);
if (armature_exported && bc_is_marked(ob_arm)) { if (armature_exported && bc_is_marked(ob_arm)) {
bc_remove_mark(ob_arm); bc_remove_mark(ob_arm);
writeNodes(ob_arm, sce); writeNodes(eval_ctx, ob_arm, sce);
armature_exported = true; armature_exported = true;
} }
} }
@@ -159,7 +159,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
// <instance_controller> // <instance_controller>
else if (ob->type == OB_ARMATURE) { else if (ob->type == OB_ARMATURE) {
arm_exporter->add_armature_bones(ob, sce, this, child_objects); arm_exporter->add_armature_bones(eval_ctx, ob, sce, this, child_objects);
} }
// <instance_camera> // <instance_camera>
@@ -237,7 +237,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) { for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
if (bc_is_marked(*i)) { if (bc_is_marked(*i)) {
bc_remove_mark(*i); bc_remove_mark(*i);
writeNodes(*i, sce); writeNodes(*i, eval_ctx, sce);
} }
} }

View File

@@ -96,15 +96,15 @@ class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter,
{ {
public: public:
SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings); SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
void exportScene(Scene *sce); void exportScene(struct EvaluationContext *eval_ctx, Scene *sce);
void setExportTransformationType(BC_export_transformation_type transformation_type); void setExportTransformationType(BC_export_transformation_type transformation_type);
private: private:
BC_export_transformation_type transformation_type; BC_export_transformation_type transformation_type;
// required for writeNodes() for bone-parented objects // required for writeNodes() for bone-parented objects
friend class ArmatureExporter; friend class ArmatureExporter;
void exportHierarchy(Scene *sce); void exportHierarchy(struct EvaluationContext *eval_ctx, Scene *sce);
void writeNodes(Object *ob, Scene *sce); void writeNodes(struct EvaluationContext *eval_ctx, Object *ob, Scene *sce);
ArmatureExporter *arm_exporter; ArmatureExporter *arm_exporter;
const ExportSettings *export_settings; const ExportSettings *export_settings;

View File

@@ -226,6 +226,9 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
{ {
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
EvaluationContext eval_ctx;
CTX_data_eval_ctx(C, &eval_ctx);
ModifierData *md = ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Armature); ModifierData *md = ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Armature);
ArmatureModifierData *amd = (ArmatureModifierData *)md; ArmatureModifierData *amd = (ArmatureModifierData *)md;
@@ -247,7 +250,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
#endif #endif
copy_m4_m4(ob->obmat, bind_shape_matrix); copy_m4_m4(ob->obmat, bind_shape_matrix);
BKE_object_apply_mat4(ob, ob->obmat, 0, 0); BKE_object_apply_mat4(&eval_ctx, ob, ob->obmat, 0, 0);
amd->deformflag = ARM_DEF_VGROUP; amd->deformflag = ARM_DEF_VGROUP;

Some files were not shown because too many files have changed in this diff Show More