Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-01-04 17:14:06 +0300
committerTon Roosendaal <ton@blender.org>2009-01-04 17:14:06 +0300
commitf7cb86df3a9ceccc4d649e42735732a608169157 (patch)
tree558a9ba43708a2213b1afa8f46d79f5daa140bc6 /source/blender/blenkernel
parent74f9e98c828c17910405092785633373d4ae88e8 (diff)
2.5
Think global, act local! The old favorite G.scene gone! Man... that took almost 2 days. Also removed G.curscreen and G.edbo. Not everything could get solved; here's some notes. - modifiers now store current scene in ModifierData. This is not meant for permanent, but it can probably stick there until we cleaned the anim system and depsgraph to cope better with timing issues. - Game engine G.scene should become an argument for staring it. Didn't solve this yet. - Texture nodes should get scene cfra, but the current implementation is too tightly wrapped to do it easily.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h27
-rw-r--r--source/blender/blenkernel/BKE_action.h9
-rw-r--r--source/blender/blenkernel/BKE_armature.h3
-rw-r--r--source/blender/blenkernel/BKE_cloth.h6
-rw-r--r--source/blender/blenkernel/BKE_collision.h3
-rw-r--r--source/blender/blenkernel/BKE_constraint.h4
-rw-r--r--source/blender/blenkernel/BKE_curve.h5
-rw-r--r--source/blender/blenkernel/BKE_displist.h15
-rw-r--r--source/blender/blenkernel/BKE_effect.h12
-rw-r--r--source/blender/blenkernel/BKE_exotic.h11
-rw-r--r--source/blender/blenkernel/BKE_fluidsim.h4
-rw-r--r--source/blender/blenkernel/BKE_font.h3
-rw-r--r--source/blender/blenkernel/BKE_global.h19
-rw-r--r--source/blender/blenkernel/BKE_group.h3
-rw-r--r--source/blender/blenkernel/BKE_image.h17
-rw-r--r--source/blender/blenkernel/BKE_ipo.h19
-rw-r--r--source/blender/blenkernel/BKE_key.h3
-rw-r--r--source/blender/blenkernel/BKE_lattice.h9
-rw-r--r--source/blender/blenkernel/BKE_material.h2
-rw-r--r--source/blender/blenkernel/BKE_mball.h7
-rw-r--r--source/blender/blenkernel/BKE_modifier.h3
-rw-r--r--source/blender/blenkernel/BKE_multires.h4
-rw-r--r--source/blender/blenkernel/BKE_node.h4
-rw-r--r--source/blender/blenkernel/BKE_object.h27
-rw-r--r--source/blender/blenkernel/BKE_particle.h29
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h5
-rw-r--r--source/blender/blenkernel/BKE_scene.h2
-rw-r--r--source/blender/blenkernel/BKE_shrinkwrap.h34
-rw-r--r--source/blender/blenkernel/BKE_softbody.h5
-rw-r--r--source/blender/blenkernel/BKE_text.h2
-rw-r--r--source/blender/blenkernel/BKE_texture.h3
-rw-r--r--source/blender/blenkernel/BKE_writeavi.h2
-rw-r--r--source/blender/blenkernel/BKE_writeffmpeg.h2
-rw-r--r--source/blender/blenkernel/BKE_writeframeserver.h2
-rw-r--r--source/blender/blenkernel/intern/BME_conversions.c4
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c74
-rw-r--r--source/blender/blenkernel/intern/action.c40
-rw-r--r--source/blender/blenkernel/intern/anim.c89
-rw-r--r--source/blender/blenkernel/intern/armature.c20
-rw-r--r--source/blender/blenkernel/intern/blender.c6
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c7
-rw-r--r--source/blender/blenkernel/intern/cloth.c7
-rw-r--r--source/blender/blenkernel/intern/collision.c8
-rw-r--r--source/blender/blenkernel/intern/constraint.c15
-rw-r--r--source/blender/blenkernel/intern/curve.c27
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c42
-rw-r--r--source/blender/blenkernel/intern/displist.c70
-rw-r--r--source/blender/blenkernel/intern/effect.c31
-rw-r--r--source/blender/blenkernel/intern/exotic.c193
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c10
-rw-r--r--source/blender/blenkernel/intern/font.c4
-rw-r--r--source/blender/blenkernel/intern/group.c12
-rw-r--r--source/blender/blenkernel/intern/image.c132
-rw-r--r--source/blender/blenkernel/intern/implicit.c12
-rw-r--r--source/blender/blenkernel/intern/ipo.c80
-rw-r--r--source/blender/blenkernel/intern/key.c38
-rw-r--r--source/blender/blenkernel/intern/lattice.c20
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/material.c10
-rw-r--r--source/blender/blenkernel/intern/mball.c16
-rw-r--r--source/blender/blenkernel/intern/mesh.c14
-rw-r--r--source/blender/blenkernel/intern/modifier.c106
-rw-r--r--source/blender/blenkernel/intern/multires-firstlevel.c12
-rw-r--r--source/blender/blenkernel/intern/multires.c19
-rw-r--r--source/blender/blenkernel/intern/node.c4
-rw-r--r--source/blender/blenkernel/intern/object.c106
-rw-r--r--source/blender/blenkernel/intern/particle.c68
-rw-r--r--source/blender/blenkernel/intern/particle_system.c178
-rw-r--r--source/blender/blenkernel/intern/pointcache.c10
-rw-r--r--source/blender/blenkernel/intern/scene.c34
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c151
-rw-r--r--source/blender/blenkernel/intern/softbody.c149
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c2
-rw-r--r--source/blender/blenkernel/intern/text.c6
-rw-r--r--source/blender/blenkernel/intern/texture.c6
-rw-r--r--source/blender/blenkernel/intern/writeavi.c2
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c102
-rw-r--r--source/blender/blenkernel/intern/writeframeserver.c12
78 files changed, 1124 insertions, 1131 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index dc932af6518..60d7c09c7a3 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -50,6 +50,7 @@ struct MEdge;
struct MFace;
struct MTFace;
struct Object;
+struct Scene;
struct Mesh;
struct EditMesh;
struct ModifierData;
@@ -418,36 +419,38 @@ void vDM_ColorBand_store(struct ColorBand *coba);
/* Simple function to get me->totvert amount of vertices/normals,
correctly deformed and subsurfered. Needed especially when vertexgroups are involved.
In use now by vertex/weigt paint and particles */
-float *mesh_get_mapped_verts_nors(struct Object *ob);
+float *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob);
/* */
-DerivedMesh *mesh_get_derived_final(struct Object *ob,
+DerivedMesh *mesh_get_derived_final(struct Scene *scene, struct Object *ob,
CustomDataMask dataMask);
-DerivedMesh *mesh_get_derived_deform(struct Object *ob,
+DerivedMesh *mesh_get_derived_deform(struct Scene *scene, struct Object *ob,
CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_for_modifier(struct Object *ob, struct ModifierData *md);
+DerivedMesh *mesh_create_derived_for_modifier(struct Scene *scene, struct Object *ob, struct ModifierData *md);
-DerivedMesh *mesh_create_derived_render(struct Object *ob,
+DerivedMesh *mesh_create_derived_render(struct Scene *scene, struct Object *ob,
CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_index_render(struct Object *ob, CustomDataMask dataMask, int index);
+DerivedMesh *mesh_create_derived_index_render(struct Scene *scene, struct Object *ob, CustomDataMask dataMask, int index);
/* same as above but wont use render settings */
-DerivedMesh *mesh_create_derived_view(struct Object *ob,
+DerivedMesh *mesh_create_derived_view(struct Scene *scene, struct Object *ob,
CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_no_deform(struct Object *ob,
+DerivedMesh *mesh_create_derived_no_deform(struct Scene *scene, struct Object *ob,
float (*vertCos)[3],
CustomDataMask dataMask);
-DerivedMesh *mesh_create_derived_no_deform_render(struct Object *ob,
+DerivedMesh *mesh_create_derived_no_deform_render(struct Scene *scene, struct Object *ob,
float (*vertCos)[3],
CustomDataMask dataMask);
DerivedMesh *editmesh_get_derived_base(struct Object *, struct EditMesh *em);
-DerivedMesh *editmesh_get_derived_cage(struct Object *, struct EditMesh *em, CustomDataMask dataMask);
-DerivedMesh *editmesh_get_derived_cage_and_final(struct Object *, struct EditMesh *em, DerivedMesh **final_r,
+DerivedMesh *editmesh_get_derived_cage(struct Scene *scene, struct Object *,
+ struct EditMesh *em, CustomDataMask dataMask);
+DerivedMesh *editmesh_get_derived_cage_and_final(struct Scene *scene, struct Object *,
+ struct EditMesh *em, DerivedMesh **final_r,
CustomDataMask dataMask);
-void makeDerivedMesh(struct Object *ob, struct EditMesh *em, CustomDataMask dataMask);
+void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct EditMesh *em, CustomDataMask dataMask);
/* returns an array of deform matrices for crazyspace correction, and the
number of modifiers left */
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h
index 574d4154e86..11e2b828436 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -44,6 +44,7 @@ struct bActionChannel;
struct bPose;
struct bPoseChannel;
struct Object;
+struct Scene;
struct ID;
/* Kernel prototypes */
@@ -80,11 +81,9 @@ void free_action(struct bAction * id);
void make_local_action(struct bAction *act);
/* only for armatures, doing pose actions only too */
-void do_all_pose_actions(struct Object *);
+void do_all_pose_actions(struct Scene *scene, struct Object *);
/* only for objects, doing only 1 channel */
-void do_all_object_actions(struct Object *);
-/* only for Mesh, Curve, Surface, Lattice, doing only Shape channel */
-void do_all_shape_actions(struct Object *);
+void do_all_object_actions(struct Scene *scene, struct Object *);
/**
@@ -134,7 +133,7 @@ void extract_pose_from_action(struct bPose *pose, struct bAction *act, float cti
/**
* Get the effects of the given action using a workob
*/
-void what_does_obaction(struct Object *ob, struct Object *workob, struct bAction *act, float cframe);
+void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bAction *act, float cframe);
/**
* Iterate through the action channels of the action
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 62061238131..6faa6ad5301 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -37,6 +37,7 @@ struct bArmature;
struct bPose;
struct bPoseChannel;
struct bConstraint;
+struct Scene;
struct Object;
struct MDeformVert;
struct Mesh;
@@ -87,7 +88,7 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl
void where_is_armature (struct bArmature *arm);
void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone);
void armature_rebuild_pose(struct Object *ob, struct bArmature *arm);
-void where_is_pose (struct Object *ob);
+void where_is_pose (struct Scene *scene, struct Object *ob);
/* get_objectspace_bone_matrix has to be removed still */
void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed);
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index f3c13d3d820..791cf40f8a0 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -50,7 +50,7 @@
#include "BKE_collision.h"
struct Object;
-
+struct Scene;
struct MFace;
struct DerivedMesh;
struct ClothModifierData;
@@ -208,7 +208,7 @@ typedef enum
////////////////////////////////////////////////
// needed for implicit.c
-int cloth_bvh_objcollision ( Object *ob, ClothModifierData * clmd, float step, float dt );
+int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, float dt );
////////////////////////////////////////////////
@@ -236,7 +236,7 @@ void clmdSetInterruptCallBack ( int ( *f ) ( void ) );
void cloth_free_modifier_extern ( ClothModifierData *clmd );
void cloth_free_modifier ( Object *ob, ClothModifierData *clmd );
void cloth_init ( ClothModifierData *clmd );
-DerivedMesh *clothModifier_do ( ClothModifierData *clmd,Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc );
+DerivedMesh *clothModifier_do ( ClothModifierData *clmd, struct Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc );
void cloth_update_normals ( ClothVertex *verts, int nVerts, MFace *face, int totface );
diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h
index c483148e4de..2518c1d6939 100644
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@ -50,6 +50,7 @@
#include "BLI_kdopbvh.h"
struct Object;
+struct Scene;
struct Cloth;
struct MFace;
struct DerivedMesh;
@@ -138,7 +139,7 @@ void interpolateOnTriangle ( float to[3], float v1[3], float v2[3], float v3[3],
/////////////////////////////////////////////////
// used in effect.c
/////////////////////////////////////////////////
-CollisionModifierData **get_collisionobjects(Object *self, int *numcollobj);
+CollisionModifierData **get_collisionobjects(struct Scene *scene, Object *self, int *numcollobj);
/////////////////////////////////////////////////
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 2f92fadd5ee..8fe71673a98 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -34,6 +34,7 @@ struct bConstraint;
struct bConstraintTarget;
struct ListBase;
struct Object;
+struct Scene;
struct bConstraintChannel;
struct bPoseChannel;
@@ -41,6 +42,7 @@ struct bPoseChannel;
/* special struct for use in constraint evaluation */
typedef struct bConstraintOb {
+ struct Scene *scene; /* for system time, part of deglobalization, code nicer later with local time (ton) */
struct Object *ob; /* if pchan, then armature that it comes from, otherwise constraint owner */
struct bPoseChannel *pchan; /* pose channel that owns the constraints being evaluated */
@@ -128,7 +130,7 @@ void free_constraint_channels(struct ListBase *chanbase);
/* Constraint Evaluation function prototypes */
-struct bConstraintOb *constraints_make_evalob(struct Object *ob, void *subdata, short datatype);
+struct bConstraintOb *constraints_make_evalob(struct Scene *scene, struct Object *ob, void *subdata, short datatype);
void constraints_clear_evalob(struct bConstraintOb *cob);
void constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, float mat[][4], short from, short to);
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 25d6d78c4aa..49e39f287f5 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -34,6 +34,7 @@
struct Curve;
struct ListBase;
struct Object;
+struct Scene;
struct Nurb;
struct ListBase;
struct BezTriple;
@@ -68,9 +69,9 @@ void makeknots( struct Nurb *nu, short uv, short type);
void makeNurbfaces(struct Nurb *nu, float *coord_array, int rowstride);
void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu);
void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
-float *make_orco_curve( struct Object *ob);
+float *make_orco_curve(struct Scene *scene, struct Object *ob);
float *make_orco_surf( struct Object *ob);
-void makebevelcurve( struct Object *ob, struct ListBase *disp);
+void makebevelcurve(struct Scene *scene, struct Object *ob, struct ListBase *disp);
void makeBevelList( struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index 64a451f3b19..c3555c9dd8a 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -54,6 +54,7 @@
/* prototypes */
struct Base;
+struct Scene;
struct Object;
struct Curve;
struct ListBase;
@@ -86,20 +87,20 @@ extern void count_displist(struct ListBase *lb, int *totvert, int *totface);
extern void freedisplist(struct ListBase *lb);
extern int displist_has_faces(struct ListBase *lb);
-extern void makeDispListSurf(struct Object *ob, struct ListBase *dispbase, int forRender);
-extern void makeDispListCurveTypes(struct Object *ob, int forOrco);
-extern void makeDispListMBall(struct Object *ob);
-extern void shadeDispList(struct Base *base);
-extern void shadeMeshMCol(struct Object *ob, struct Mesh *me);
+extern void makeDispListSurf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, int forRender);
+extern void makeDispListCurveTypes(struct Scene *scene, struct Object *ob, int forOrco);
+extern void makeDispListMBall(struct Scene *scene, struct Object *ob);
+extern void shadeDispList(struct Scene *scene, struct Base *base);
+extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me);
int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4);
void imagestodisplist(void);
-void reshadeall_displist(void);
+void reshadeall_displist(struct Scene *scene);
void filldisplist(struct ListBase *dispbase, struct ListBase *to);
void fastshade_free_render(void);
-float calc_taper(struct Object *taperobj, int cur, int tot);
+float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot);
#endif
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 6475f7a71ac..fd065978800 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -33,6 +33,8 @@
#include "DNA_object_types.h"
+struct Object;
+struct Scene;
struct Effect;
struct ListBase;
struct Particle;
@@ -61,12 +63,16 @@ void deselectall_eff(struct Object *ob);
#define PE_WIND_AS_SPEED 0x00000001
struct PartEff *give_parteff(struct Object *ob);
-struct ListBase *pdInitEffectors(struct Object *obsrc, struct Group *group);
+struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *obsrc, struct Group *group);
void pdEndEffectors(struct ListBase *lb);
-void pdDoEffectors(struct ListBase *lb, float *opco, float *force, float *speed, float cur_time, float loc_time, unsigned int flags);
+void pdDoEffectors(struct Scene *scene, struct ListBase *lb, float *opco, float *force,
+ float *speed, float cur_time, float loc_time, unsigned int flags);
/* required for particle_system.c */
-void do_physical_effector(Object *ob, float *opco, short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor, float charge, float pa_size);
+void do_physical_effector(struct Scene *scene, struct Object *ob, float *opco, short type, float force_val, float distance,
+ float falloff, float size, float damp, float *eff_velocity, float *vec_to_part,
+ float *velocity, float *field, int planar, struct RNG *rng, float noise_factor,
+ float charge, float pa_size);
float effector_falloff(struct PartDeflect *pd, float *eff_velocity, float *vec_to_part);
diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h
index 3814518a9e7..11dc1f41109 100644
--- a/source/blender/blenkernel/BKE_exotic.h
+++ b/source/blender/blenkernel/BKE_exotic.h
@@ -32,6 +32,7 @@
#define BKE_EXOTIC_H
struct Mesh;
+struct Scene;
void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a);
unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c
@@ -42,12 +43,12 @@ unsigned int *mcol_to_vcol(struct Mesh *me); // used in py_main.c
* @retval 1 The file was read succesfully.
* @attention Used in filesel.c
*/
-int BKE_read_exotic(char *name);
+int BKE_read_exotic(struct Scene *scene, char *name);
-void write_dxf(char *str);
-void write_vrml(char *str);
-void write_videoscape(char *str);
-void write_stl(char *str);
+void write_dxf(struct Scene *scene, char *str);
+void write_vrml(struct Scene *scene, char *str);
+void write_videoscape(struct Scene *scene, char *str);
+void write_stl(struct Scene *scene, char *str);
#endif
diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h
index 4aac5eafa00..93358fcf7e8 100644
--- a/source/blender/blenkernel/BKE_fluidsim.h
+++ b/source/blender/blenkernel/BKE_fluidsim.h
@@ -37,7 +37,7 @@
/* old interface */
FluidsimSettings *fluidsimSettingsNew(Object *srcob);
-void initElbeemMesh(Object *ob, int *numVertices, float **vertices, int *numTriangles, int **triangles, int useGlobalCoords, int modifierIndex);
+void initElbeemMesh(Scene *scene, Object *ob, int *numVertices, float **vertices, int *numTriangles, int **triangles, int useGlobalCoords, int modifierIndex);
/* new fluid-modifier interface */
@@ -46,7 +46,7 @@ void fluidsim_free(FluidsimModifierData *fluidmd);
DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams);
void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename);
-DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc);
+DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc);
// get bounding box of mesh
void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index caeddf60638..3445e5b1ce2 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -38,6 +38,7 @@ extern "C" {
#include <wchar.h>
struct VFont;
+struct Scene;
struct Object;
struct Curve;
struct objfnt;
@@ -63,7 +64,7 @@ void free_ttfont(void);
struct VFont *load_vfont(char *name);
struct TmpFont *vfont_find_tmpfont(struct VFont *vfont);
-struct chartrans *text_to_curve(struct Object *ob, int mode);
+struct chartrans *text_to_curve(struct Scene *scene, struct Object *ob, int mode);
int style_to_sel(int style, int toggle);
int mat_to_sel(void);
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index ea0c021652a..99ce091621e 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -42,21 +42,7 @@ extern "C" {
#endif
/* forwards */
-struct View3D;
-struct View2D;
-struct SpaceIpo;
-struct SpaceButs;
-struct SpaceImage;
-struct SpaceOops;
-struct SpaceText;
-struct SpaceSound;
-struct SpaceAction;
-struct SpaceNla;
struct Main;
-struct Scene;
-struct bScreen;
-struct ScrArea;
-struct ARegion;
struct Object;
struct bSoundListener;
struct BMF_Font;
@@ -66,8 +52,6 @@ typedef struct Global {
/* active pointers */
struct Main *main;
- struct Scene *scene; /* denk aan file.c */
- struct bScreen *curscreen;
char editModeTitleExtra[64];
/* fonts, allocated global data */
@@ -103,9 +87,6 @@ typedef struct Global {
/* Frank's variables */
int save_over;
- /* Reevan's __NLA variables */
- struct ListBase edbo; /* Armature Editmode bones */
-
/* Rob's variables (keep here for WM recode) */
int have_quicktime;
int ui_international;
diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h
index 764bdf5d910..35084aabadf 100644
--- a/source/blender/blenkernel/BKE_group.h
+++ b/source/blender/blenkernel/BKE_group.h
@@ -35,6 +35,7 @@ struct Group;
struct GroupObject;
struct Object;
struct bAction;
+struct Scene;
void free_group_object(struct GroupObject *go);
void free_group(struct Group *group);
@@ -47,7 +48,7 @@ int object_in_group(struct Object *ob, struct Group *group);
int group_is_animated(struct Object *parent, struct Group *group);
void group_tag_recalc(struct Group *group);
-void group_handle_recalc_and_update(struct Object *parent, struct Group *group);
+void group_handle_recalc_and_update(struct Scene *scene, struct Object *parent, struct Group *group);
struct Object *group_get_member_with_action(struct Group *group, struct bAction *act);
void group_relink_nla_objects(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 8dac282eedf..b0cf58d8216 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -39,15 +39,16 @@ struct Image;
struct ImBuf;
struct Tex;
struct anim;
+struct Scene;
/* call from library */
void free_image(struct Image *me);
-void BKE_stamp_info(struct ImBuf *ibuf);
-void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int channels);
-int BKE_write_ibuf(struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality);
-void BKE_makepicstring(char *string, char *base, int frame, int imtype);
-void BKE_add_image_extension(char *string, int imtype);
+void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf);
+void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels);
+int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, char *name, int imtype, int subimtype, int quality);
+void BKE_makepicstring(struct Scene *scene, char *string, char *base, int frame, int imtype);
+void BKE_add_image_extension(struct Scene *scene, char *string, int imtype);
int BKE_ftype_to_imtype(int ftype);
int BKE_imtype_to_ftype(int imtype);
int BKE_imtype_is_movie(int imtype);
@@ -107,8 +108,8 @@ struct RenderResult;
/* always call to make signals work */
struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser);
-/* returns existing Image when filename/type is same */
-struct Image *BKE_add_image_file(const char *name);
+/* returns existing Image when filename/type is same (frame optional) */
+struct Image *BKE_add_image_file(const char *name, int frame);
/* adds image, adds ibuf, generates color or pattern */
struct Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]);
@@ -132,7 +133,7 @@ void BKE_image_user_new_image(struct Image *ima, struct ImageUser *iuser);
struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser);
/* for multilayer images as well as for render-viewer */
-struct RenderResult *BKE_image_get_renderresult(struct Image *ima);
+struct RenderResult *BKE_image_get_renderresult(struct Scene *scene, struct Image *ima);
/* goes over all textures that use images */
void BKE_image_free_all_textures(void);
diff --git a/source/blender/blenkernel/BKE_ipo.h b/source/blender/blenkernel/BKE_ipo.h
index f0c530808a7..21e80708113 100644
--- a/source/blender/blenkernel/BKE_ipo.h
+++ b/source/blender/blenkernel/BKE_ipo.h
@@ -45,6 +45,7 @@ struct Ipo;
struct IpoCurve;
struct MTex;
struct Material;
+struct Scene;
struct Object;
struct Sequence;
struct ListBase;
@@ -56,16 +57,16 @@ struct rctf;
/* ------------ Time Management ------------ */
-float frame_to_float(int cfra);
+float frame_to_float(struct Scene *scene, int cfra);
/* ------------ IPO Management ---------- */
void free_ipo_curve(struct IpoCurve *icu);
void free_ipo(struct Ipo *ipo);
-void ipo_default_v2d_cur(int blocktype, struct rctf *cur);
+void ipo_default_v2d_cur(struct Scene *scene, int blocktype, struct rctf *cur);
-struct Ipo *add_ipo(char *name, int idcode);
+struct Ipo *add_ipo(struct Scene *scene, char *name, int idcode);
struct Ipo *copy_ipo(struct Ipo *ipo);
void ipo_idnew(struct Ipo *ipo);
@@ -126,14 +127,14 @@ void set_icu_vars(struct IpoCurve *icu);
void execute_ipo(struct ID *id, struct Ipo *ipo);
void execute_action_ipo(struct bActionChannel *achan, struct bPoseChannel *pchan);
-void do_ipo_nocalc(struct Ipo *ipo);
-void do_ipo(struct Ipo *ipo);
-void do_mat_ipo(struct Material *ma);
-void do_ob_ipo(struct Object *ob);
-void do_seq_ipo(struct Sequence *seq, int cfra);
+void do_ipo_nocalc(struct Scene *scene, struct Ipo *ipo);
+void do_ipo(struct Scene *scene, struct Ipo *ipo);
+void do_mat_ipo(struct Scene *scene, struct Material *ma);
+void do_ob_ipo(struct Scene *scene, struct Object *ob);
+void do_seq_ipo(struct Scene *scene, struct Sequence *seq, int cfra);
void do_ob_ipodrivers(struct Object *ob, struct Ipo *ipo, float ctime);
-void do_all_data_ipos(void);
+void do_all_data_ipos(struct Scene *scene);
short calc_ipo_spec(struct Ipo *ipo, int adrcode, float *ctime);
void clear_delta_obipo(struct Ipo *ipo);
diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h
index 0557120a3aa..e2f9dff6226 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -37,6 +37,7 @@ struct ID;
struct ListBase;
struct Curve;
struct Object;
+struct Scene;
struct Lattice;
struct Mesh;
@@ -57,7 +58,7 @@ void set_afgeleide_four_ipo(float d, float *data, int type);
/* only exported to curve.c! */
void cp_cu_key(struct Curve *cu, struct KeyBlock *kb, int start, int end);
-int do_ob_key(struct Object *ob);
+int do_ob_key(struct Scene *scene, struct Object *ob);
struct Key *ob_get_key(struct Object *ob);
struct KeyBlock *ob_get_keyblock(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index dc7c9dcd5e5..181c0cec45a 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -33,6 +33,7 @@
struct Lattice;
struct Object;
+struct Scene;
struct DerivedMesh;
struct BPoint;
struct MDeformVert;
@@ -51,10 +52,11 @@ void calc_latt_deform(float *co, float weight);
void end_latt_deform(void);
int object_deform_mball(struct Object *ob);
void outside_lattice(struct Lattice *lt);
-void curve_deform_verts(struct Object *cuOb, struct Object *target,
+
+void curve_deform_verts(struct Scene *scene, struct Object *cuOb, struct Object *target,
struct DerivedMesh *dm, float (*vertexCos)[3],
int numVerts, char *vgroup, short defaxis);
-void curve_deform_vector(struct Object *cuOb, struct Object *target,
+void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object *target,
float *orco, float *vec, float mat[][3], int no_rot_axis);
void lattice_deform_verts(struct Object *laOb, struct Object *target,
@@ -64,9 +66,10 @@ void armature_deform_verts(struct Object *armOb, struct Object *target,
struct DerivedMesh *dm, float (*vertexCos)[3],
float (*defMats)[3][3], int numVerts, int deformflag,
float (*prevCos)[3], const char *defgrp_name);
+
float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3];
void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]);
-void lattice_calc_modifiers(struct Object *ob);
+void lattice_calc_modifiers(struct Scene *scene, struct Object *ob);
struct MDeformVert* lattice_get_deform_verts(struct Object *lattice);
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index efb64fbf0a3..38a1d9b13b7 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -65,7 +65,7 @@ void end_render_materials(void);
int material_in_material(struct Material *parmat, struct Material *mat);
void automatname(struct Material *);
-void delete_material_index(void);
+void delete_material_index(struct Object *ob);
void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col);
diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h
index 0dfc8ae6b28..ba78aa0682d 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -33,6 +33,7 @@
struct MetaBall;
struct Object;
+struct Scene;
struct MetaElem;
typedef struct point { /* a three-dimensional point */
@@ -154,7 +155,7 @@ void subdivide_metaball_octal_node(octal_node *node, float size_x, float size_y,
void free_metaball_octal_node(octal_node *node);
void init_metaball_octal_tree(int depth);
void polygonize(PROCESS *mbproc, struct MetaBall *mb);
-float init_meta(struct Object *ob);
+float init_meta(struct Scene *scene, struct Object *ob);
void unlink_mball(struct MetaBall *mb);
void free_mball(struct MetaBall *mb);
@@ -163,9 +164,9 @@ struct MetaBall *copy_mball(struct MetaBall *mb);
void make_local_mball(struct MetaBall *mb);
void tex_space_mball(struct Object *ob);
float *make_orco_mball(struct Object *ob);
-struct Object *find_basis_mball( struct Object *ob);
+struct Object *find_basis_mball(struct Scene *scene, struct Object *ob);
int is_basis_mball(struct Object *ob);
-void metaball_polygonize(struct Object *ob);
+void metaball_polygonize(struct Scene *scene, struct Object *ob);
void calc_mballco(struct MetaElem *ml, float *vec);
float densfunc(struct MetaElem *ball, float x, float y, float z);
float metaball(float x, float y, float z);
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index a41716ed1ff..d486a5dc665 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -38,6 +38,7 @@ struct DerivedMesh;
struct DagForest;
struct DagNode;
struct Object;
+struct Scene;
struct ListBase;
struct LinkNode;
struct bArmature;
@@ -226,7 +227,7 @@ typedef struct ModifierTypeInfo {
*
* This function is optional.
*/
- void (*updateDepgraph)(struct ModifierData *md, struct DagForest *forest,
+ void (*updateDepgraph)(struct ModifierData *md, struct DagForest *forest, struct Scene *scene,
struct Object *ob, struct DagNode *obNode);
/* Should return true if the modifier needs to be recalculated on time
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index df565ddc7fe..64221897680 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -50,8 +50,8 @@ struct Multires *multires_copy(struct Multires *orig);
void multires_create(struct Object *ob, struct Mesh *me);
/* CustomData */
-void multires_delete_layer(struct Mesh *me, struct CustomData *cd, const int type, int n);
-void multires_add_layer(struct Mesh *me, struct CustomData *cd, const int type, const int n);
+void multires_delete_layer(struct Object *ob, struct CustomData *cd, const int type, int n);
+void multires_add_layer(struct Object *ob, struct CustomData *cd, const int type, const int n);
void multires_del_lower_customdata(struct Multires *mr, struct MultiresLevel *cr_lvl);
void multires_to_mcol(struct MultiresColFace *f, MCol mcol[4]);
/* After adding or removing vcolor layers, run this */
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 1c5b6b124b2..669ee11926b 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -376,7 +376,7 @@ struct CompBuf;
void ntreeCompositTagRender(struct Scene *sce);
int ntreeCompositTagAnimated(struct bNodeTree *ntree);
void ntreeCompositTagGenerators(struct bNodeTree *ntree);
-void ntreeCompositForceHidden(struct bNodeTree *ntree);
+void ntreeCompositForceHidden(struct bNodeTree *ntree, struct Scene *scene);
void free_compbuf(struct CompBuf *cbuf); /* internal...*/
@@ -413,7 +413,7 @@ extern struct ListBase node_all_textures;
/* API */
int ntreeTexTagAnimated(struct bNodeTree *ntree);
void ntreeTexUpdatePreviews( struct bNodeTree* nodetree );
-void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, char do_preview, short thread, struct Tex *tex, short which_output);
+void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra);
void ntreeTexCheckCyclics(struct bNodeTree *ntree);
void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node);
char* ntreeTexOutputMenu(struct bNodeTree *ntree);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 6d46aad5296..38eee2e4db1 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -36,6 +36,7 @@ extern "C" {
#endif
struct Base;
+struct Scene;
struct Object;
struct Camera;
struct BoundBox;
@@ -46,10 +47,10 @@ struct Group;
struct bAction;
void clear_workob(struct Object *workob);
-void what_does_parent(struct Object *ob, struct Object *workob);
+void what_does_parent(struct Scene *scene, struct Object *ob, struct Object *workob);
-void copy_baseflags(void);
-void copy_objectflags(void);
+void copy_baseflags(struct Scene *scene);
+void copy_objectflags(struct Scene *scene);
struct SoftBody *copy_softbody(struct SoftBody *sb);
struct BulletSoftBody *copy_bulletsoftbody(struct BulletSoftBody *sb);
void copy_object_particlesystems(struct Object *obn, struct Object *ob);
@@ -57,7 +58,7 @@ void copy_object_softbody(struct Object *obn, struct Object *ob);
void object_free_particlesystems(struct Object *ob);
void object_free_softbody(struct Object *ob);
void object_free_bulletsoftbody(struct Object *ob);
-void update_base_layer(struct Object *ob);
+void update_base_layer(struct Scene *scene, struct Object *ob);
void free_object(struct Object *ob);
void object_free_display(struct Object *ob);
@@ -65,7 +66,7 @@ void object_free_modifiers(struct Object *ob);
void object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
-void unlink_object(struct Object *ob);
+void unlink_object(struct Scene *scene, struct Object *ob);
int exist_object(struct Object *obtest);
void *add_camera(char *name);
struct Camera *copy_camera(struct Camera *cam);
@@ -79,8 +80,8 @@ void free_lamp(struct Lamp *la);
void *add_wave(void);
struct Object *add_only_object(int type, char *name);
-struct Object *add_object(int type);
-void base_init_from_view3d(struct Base *base, struct View3D *v3d);
+struct Object *add_object(struct Scene *scene, int type);
+void base_init_from_view3d(struct Base *base, struct View3D *v3d, struct Scene *scene);
struct Object *copy_object(struct Object *ob);
void expand_local_object(struct Object *ob);
@@ -89,7 +90,7 @@ void set_mblur_offs(float blur);
void set_field_offs(float field);
void disable_speed_curve(int val);
-float bsystem_time(struct Object *ob, float cfra, float ofs);
+float bsystem_time(struct Scene *scene, struct Object *ob, float cfra, float ofs);
void object_scale_to_mat3(struct Object *ob, float mat[][3]);
void object_rot_to_mat3(struct Object *ob, float mat[][3]);
void object_to_mat3(struct Object *ob, float mat[][3]);
@@ -102,20 +103,20 @@ int during_script(void);
void disable_where_scriptlink(short on);
int during_scriptlink(void);
-void where_is_object_time(struct Object *ob, float ctime);
-void where_is_object(struct Object *ob);
-void where_is_object_simul(struct Object *ob);
+void where_is_object_time(struct Scene *scene, struct Object *ob, float ctime);
+void where_is_object(struct Scene *scene, struct Object *ob);
+void where_is_object_simul(struct Scene *scene, struct Object *ob);
struct BoundBox *unit_boundbox(void);
void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]);
struct BoundBox *object_get_boundbox(struct Object *ob);
void object_boundbox_flag(struct Object *ob, int flag, int set);
void minmax_object(struct Object *ob, float *min, float *max);
-void minmax_object_duplis(struct Object *ob, float *min, float *max);
+void minmax_object_duplis(struct Scene *scene, struct Object *ob, float *min, float *max);
void solve_tracking (struct Object *ob, float targetmat[][4]);
int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]);
-void object_handle_update(struct Object *ob);
+void object_handle_update(struct Scene *scene, struct Object *ob);
float give_timeoffset(struct Object *ob);
int give_obdata_texspace(struct Object *ob, int **texflag, float **loc, float **size, float **rot);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index caba63ef8ce..40120e2b61a 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -44,6 +44,7 @@ struct HairKey;
struct Main;
struct Group;
struct Object;
+struct Scene;
struct DerivedMesh;
struct ModifierData;
struct MTFace;
@@ -201,11 +202,11 @@ short psys_get_current_num(struct Object *ob);
struct ParticleData *psys_get_selected_particle(struct ParticleSystem *psys, int *index);
struct ParticleKey *psys_get_selected_key(struct ParticleSystem *psys, int pa_index, int *key_index);
void psys_change_act(void *ob_v, void *act_v);
-struct Object *psys_get_lattice(struct Object *ob, struct ParticleSystem *psys);
+struct Object *psys_get_lattice(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
void psys_disable_all(struct Object *ob);
void psys_enable_all(struct Object *ob);
int psys_ob_has_hair(struct Object *ob);
-int psys_in_edit_mode(struct ParticleSystem *psys);
+int psys_in_edit_mode(struct Scene *scene, struct ParticleSystem *psys);
int psys_check_enabled(struct Object *ob, struct ParticleSystem *psys);
void psys_free_settings(struct ParticleSettings *part);
@@ -231,30 +232,30 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P
struct ParticleSettings *psys_new_settings(char *name, struct Main *main);
struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part);
-void psys_flush_settings(struct ParticleSettings *part, int event, int hair_recalc);
+void psys_flush_settings(struct Scene *scene, struct ParticleSettings *part, int event, int hair_recalc);
void make_local_particlesettings(struct ParticleSettings *part);
-struct LinkNode *psys_using_settings(struct ParticleSettings *part, int flush_update);
+struct LinkNode *psys_using_settings(struct Scene *scene, struct ParticleSettings *part, int flush_update);
void psys_changed_type(struct ParticleSystem *psys);
void psys_reset(struct ParticleSystem *psys, int mode);
void psys_find_parents(struct Object *ob, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys);
-void psys_cache_paths(struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate);
-void psys_cache_child_paths(struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate);
+void psys_cache_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate);
+void psys_cache_child_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate);
int do_guide(struct ParticleKey *state, int pa_num, float time, struct ListBase *lb);
float psys_get_size(struct Object *ob, struct Material *ma, struct ParticleSystemModifierData *psmd, struct IpoCurve *icu_size, struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleData *pa, float *vg_size);
float psys_get_timestep(struct ParticleSettings *part);
float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra);
float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time);
-void psys_get_particle_on_path(struct Object *ob, struct ParticleSystem *psys, int pa_num, struct ParticleKey *state, int vel);
-int psys_get_particle_state(struct Object *ob, struct ParticleSystem *psys, int p, struct ParticleKey *state, int always);
+void psys_get_particle_on_path(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, int pa_num, struct ParticleKey *state, int vel);
+int psys_get_particle_state(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, int p, struct ParticleKey *state, int always);
void psys_get_dupli_texture(struct Object *ob, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, float *uv, float *orco);
void psys_get_dupli_path_transform(struct Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[][4], float *scale);
-ParticleThread *psys_threads_create(struct Object *ob, struct ParticleSystem *psys);
-int psys_threads_init_distribution(ParticleThread *threads, struct DerivedMesh *dm, int from);
-int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate);
+ParticleThread *psys_threads_create(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
+int psys_threads_init_distribution(ParticleThread *threads, struct Scene *scene, struct DerivedMesh *dm, int from);
+int psys_threads_init_path(ParticleThread *threads, struct Scene *scene, float cfra, int editupdate);
void psys_threads_free(ParticleThread *threads);
void psys_thread_distribute_particle(ParticleThread *thread, struct ParticleData *pa, struct ChildParticle *cpa, int p);
@@ -264,10 +265,10 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
int psys_count_keyed_targets(struct Object *ob, struct ParticleSystem *psys);
void psys_get_reactor_target(struct Object *ob, struct ParticleSystem *psys, struct Object **target_ob, struct ParticleSystem **target_psys);
-void psys_init_effectors(struct Object *obsrc, struct Group *group, struct ParticleSystem *psys);
+void psys_init_effectors(struct Scene *scene, struct Object *obsrc, struct Group *group, struct ParticleSystem *psys);
void psys_end_effectors(struct ParticleSystem *psys);
-void particle_system_update(struct Object *ob, struct ParticleSystem *psys);
+void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* ----------- functions needed only inside particlesystem ------------ */
/* particle.c */
@@ -288,7 +289,7 @@ float psys_particle_value_from_verts(struct DerivedMesh *dm, short from, struct
float psys_interpolate_value_from_verts(struct DerivedMesh *dm, short from, int index, float *fw, float *values);
void psys_get_from_key(struct ParticleKey *key, float *loc, float *vel, float *rot, float *time);
-int psys_intersect_dm(struct Object *ob, struct DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_uv, float *face_minmax, float *pa_minmax, float radius, float *ipoint);
+int psys_intersect_dm(struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_uv, float *face_minmax, float *pa_minmax, float radius, float *ipoint);
void psys_particle_on_dm(struct DerivedMesh *dm, int from, int index, int index_dmcache, float *fw, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor);
/* particle_system.c */
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 5bc467465a8..cce085f3077 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -58,6 +58,7 @@
/* Structs */
struct Object;
+struct Scene *scene;
struct SoftBody;
struct ParticleSystem;
struct ClothModifierData;
@@ -93,7 +94,7 @@ void BKE_ptcache_remove(void);
void BKE_ptcache_id_clear(PTCacheID *id, int mode, int cfra);
int BKE_ptcache_id_exist(PTCacheID *id, int cfra);
int BKE_ptcache_id_reset(PTCacheID *id, int mode);
-void BKE_ptcache_id_time(PTCacheID *pid, float cfra, int *startframe, int *endframe, float *timescale);
+void BKE_ptcache_id_time(PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale);
int BKE_ptcache_object_reset(struct Object *ob, int mode);
/* File reading/writing */
@@ -103,7 +104,7 @@ int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot);
int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot);
/* Continue physics */
-void BKE_ptcache_set_continue_physics(int enable);
+void BKE_ptcache_set_continue_physics(struct Scene *scene, int enable);
int BKE_ptcache_get_continue_physics(void);
/* Point Cache */
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 4f951129842..2c58c5d6d8c 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -54,7 +54,7 @@ struct Base *object_in_scene(struct Object *ob, struct Scene *sce);
void set_scene_bg(struct Scene *sce);
void set_scene_name(char *name);
-int next_object(int val, struct Base **base, struct Object **ob);
+int next_object(struct Scene *scene, int val, struct Base **base, struct Object **ob);
struct Object *scene_find_camera(struct Scene *sc);
struct Base *scene_add_base(struct Scene *sce, struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h
index eed22ff9d8e..103b78f0d6e 100644
--- a/source/blender/blenkernel/BKE_shrinkwrap.h
+++ b/source/blender/blenkernel/BKE_shrinkwrap.h
@@ -30,12 +30,11 @@
#define BKE_SHRINKWRAP_H
/* mesh util */
+
//TODO: move this somewhere else
#include "BKE_customdata.h"
struct DerivedMesh;
struct Object;
-struct DerivedMesh *object_get_derived_final(struct Object *ob, CustomDataMask dataMask);
-
/* SpaceTransform stuff */
/*
@@ -60,7 +59,7 @@ struct DerivedMesh *object_get_derived_final(struct Object *ob, CustomDataMask d
* space_transform_invert_normal(&data, &no);
*
*/
-struct Object;
+
typedef struct SpaceTransform
{
@@ -69,14 +68,11 @@ typedef struct SpaceTransform
} SpaceTransform;
-void space_transform_from_matrixs(SpaceTransform *data, float local[][4], float target[][4]);
-#define space_transform_setup(data, local, target) space_transform_from_matrixs(data, (local)->obmat, (target)->obmat)
-
-void space_transform_apply (const SpaceTransform *data, float *co);
-void space_transform_invert(const SpaceTransform *data, float *co);
+void space_transform_from_matrixs(struct SpaceTransform *data, float local[4][4], float target[4][4]);
+void space_transform_apply(const struct SpaceTransform *data, float *co);
+void space_transform_invert(const struct SpaceTransform *data, float *co);
-void space_transform_apply_normal (const SpaceTransform *data, float *no);
-void space_transform_invert_normal(const SpaceTransform *data, float *no);
+#define space_transform_setup(data, local, target) space_transform_from_matrixs(data, (local)->obmat, (target)->obmat)
/* Shrinkwrap stuff */
#include "BKE_bvhutils.h"
@@ -94,6 +90,7 @@ void space_transform_invert_normal(const SpaceTransform *data, float *no);
*/
struct Object;
+struct Scene;
struct DerivedMesh;
struct ShrinkwrapModifierData;
struct MDeformVert;
@@ -120,22 +117,7 @@ typedef struct ShrinkwrapCalcData
} ShrinkwrapCalcData;
-void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *data);
-void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *data);
-void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *data);
-
-void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts);
-
-/*
- * This function casts a ray in the given BVHTree.. but it takes into consideration the space_transform, that is:
- *
- * if transf was configured with "space_transform_setup( &transf, ob1, ob2 )"
- * then the input (vert, dir, BVHTreeRayHit) must be defined in ob1 coordinates space
- * and the BVHTree must be built in ob2 coordinate space.
- *
- * Thus it provides an easy way to cast the same ray across several trees (where each tree was built on its own coords space)
- */
-int normal_projection_project_vertex(char options, const float *vert, const float *dir, const SpaceTransform *transf, BVHTree *tree, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata);
+void shrinkwrapModifier_deform(struct ShrinkwrapModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts);
/*
* NULL initializers to local data
diff --git a/source/blender/blenkernel/BKE_softbody.h b/source/blender/blenkernel/BKE_softbody.h
index 1756734813b..05a9bfb0ca9 100644
--- a/source/blender/blenkernel/BKE_softbody.h
+++ b/source/blender/blenkernel/BKE_softbody.h
@@ -32,6 +32,7 @@
#define BKE_SOFTBODY_H
struct Object;
+struct Scene;
struct SoftBody;
typedef struct BodyPoint {
@@ -47,7 +48,7 @@ typedef struct BodyPoint {
} BodyPoint;
/* allocates and initializes general main data */
-extern struct SoftBody *sbNew(void);
+extern struct SoftBody *sbNew(struct Scene *scene);
/* frees internal data and softbody itself */
extern void sbFree(struct SoftBody *sb);
@@ -56,7 +57,7 @@ extern void sbFree(struct SoftBody *sb);
extern void sbFreeSimulation(struct SoftBody *sb);
/* do one simul step, reading and writing vertex locs from given array */
-extern void sbObjectStep(struct Object *ob, float framnr, float (*vertexCos)[3], int numVerts);
+extern void sbObjectStep(struct Scene *scene, struct Object *ob, float framnr, float (*vertexCos)[3], int numVerts);
/* makes totally fresh start situation, resets time */
extern void sbObjectToSoftbody(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index 002c804f17f..856abf74011 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -44,7 +44,7 @@ void txt_set_undostate (int u);
int txt_get_undostate (void);
struct Text* add_empty_text (char *name);
int reopen_text (struct Text *text);
-struct Text* add_text (char *file);
+struct Text* add_text (char *file, const char *relpath);
struct Text* copy_text (struct Text *ta);
void txt_free_cut_buffer (void);
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index cfcae3c44bc..a1600ce5473 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -31,6 +31,7 @@
#ifndef BKE_TEXTURE_H
#define BKE_TEXTURE_H
+struct Scene;
struct Tex;
struct MTex;
struct PluginTex;
@@ -63,7 +64,7 @@ struct Tex *copy_texture(struct Tex *tex);
void make_local_texture(struct Tex *tex);
void autotexname(struct Tex *tex);
struct Tex *give_current_texture(struct Object *ob, int act);
-struct Tex *give_current_world_texture(void);
+struct Tex *give_current_world_texture(struct Scene *scene);
struct TexMapping *add_mapping(void);
void init_mapping(struct TexMapping *texmap);
diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h
index 83b9b57b3bc..e8294069908 100644
--- a/source/blender/blenkernel/BKE_writeavi.h
+++ b/source/blender/blenkernel/BKE_writeavi.h
@@ -46,7 +46,7 @@ typedef struct bMovieHandle {
void (*start_movie)(struct RenderData *rd, int rectx, int recty);
void (*append_movie)(int frame, int *pixels, int rectx, int recty);
void (*end_movie)(void);
- int (*get_next_frame)(void); /* can be null */
+ int (*get_next_frame)(struct RenderData *rd); /* optional */
} bMovieHandle;
bMovieHandle *BKE_get_movie_handle(int imtype);
diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h
index 02f7ba6f860..dba3944a58d 100644
--- a/source/blender/blenkernel/BKE_writeffmpeg.h
+++ b/source/blender/blenkernel/BKE_writeffmpeg.h
@@ -57,7 +57,7 @@ struct RenderData;
extern void start_ffmpeg(struct RenderData *rd, int rectx, int recty);
extern void end_ffmpeg(void);
-extern void append_ffmpeg(int frame, int *pixels, int rectx, int recty);
+extern void append_ffmpeg(struct RenderData *rd, int frame, int *pixels, int rectx, int recty);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h
index 4774906a2fa..097a7e2f9b0 100644
--- a/source/blender/blenkernel/BKE_writeframeserver.h
+++ b/source/blender/blenkernel/BKE_writeframeserver.h
@@ -37,7 +37,7 @@ struct RenderData;
extern void start_frameserver(struct RenderData *rd, int rectx, int recty);
extern void end_frameserver(void);
extern void append_frameserver(int frame, int *pixels, int rectx, int recty);
-extern int frameserver_loop(void);
+extern int frameserver_loop(struct RenderData *rd);
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c
index da6ab7ea816..58bd4b59181 100644
--- a/source/blender/blenkernel/intern/BME_conversions.c
+++ b/source/blender/blenkernel/intern/BME_conversions.c
@@ -56,6 +56,8 @@
//XXX #include "BSE_edit.h"
+/* XXX IMPORTANT: editmesh stuff doesn't belong in kernel! (ton) */
+
/*merge these functions*/
static void BME_DMcorners_to_loops(BME_Mesh *bm, CustomData *facedata, int index, BME_Poly *f, int numCol, int numTex){
int i, j;
@@ -397,7 +399,7 @@ void BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em) {
if(e->flag & SELECT) eed->f |= SELECT;
//XXX if(e->flag & ME_FGON) eed->h= EM_FGON; // 2 different defines!
if(e->flag & ME_HIDE) eed->h |= 1;
- if(G.scene->selectmode==SCE_SELECT_EDGE)
+ if(em->selectmode==SCE_SELECT_EDGE)
; //XXX EM_select_edge(eed, eed->f & SELECT);
CustomData_em_copy_data(&bm->edata, &em->edata, e->data, &eed->data);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 9c8e88aceb5..2aeef91538c 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1957,12 +1957,14 @@ DerivedMesh *derivedmesh_from_versemesh(VNode *vnode, float (*vertexCos)[3])
/***/
-DerivedMesh *mesh_create_derived_for_modifier(Object *ob, ModifierData *md)
+DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, ModifierData *md)
{
Mesh *me = ob->data;
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
DerivedMesh *dm;
+ md->scene= scene;
+
if (!(md->mode&eModifierMode_Realtime)) return NULL;
if (mti->isDisabled && mti->isDisabled(md)) return NULL;
@@ -2099,7 +2101,7 @@ static void add_orco_dm(Object *ob, EditMesh *em, DerivedMesh *dm, DerivedMesh *
DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, orco);
}
-static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
+static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos)[3],
DerivedMesh **deform_r, DerivedMesh **final_r,
int useRenderParams, int useDeform,
int needMapping, CustomDataMask dataMask, int index)
@@ -2130,13 +2132,15 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
else required_mode = eModifierMode_Realtime;
if(useDeform) {
- if(do_ob_key(ob)) /* shape key makes deform verts */
+ if(do_ob_key(scene, ob)) /* shape key makes deform verts */
deformedVerts = mesh_getVertexCos(me, &numVerts);
/* Apply all leading deforming modifiers */
for(;md; md = md->next, curr = curr->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ md->scene= scene;
+
if((md->mode & required_mode) != required_mode) continue;
if(mti->isDisabled && mti->isDisabled(md)) continue;
@@ -2201,6 +2205,8 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
for(;md; md = md->next, curr = curr->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ md->scene= scene;
+
if((md->mode & required_mode) != required_mode) continue;
if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
@@ -2396,7 +2402,7 @@ static int editmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm)
return 1;
}
-static void editmesh_calc_modifiers(Object *ob, EditMesh *em, DerivedMesh **cage_r,
+static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, DerivedMesh **cage_r,
DerivedMesh **final_r,
CustomDataMask dataMask)
{
@@ -2415,7 +2421,7 @@ static void editmesh_calc_modifiers(Object *ob, EditMesh *em, DerivedMesh **cage
dm = NULL;
md = ob->modifiers.first;
-
+
/* we always want to keep original indices */
dataMask |= CD_MASK_ORIGINDEX;
@@ -2425,6 +2431,8 @@ static void editmesh_calc_modifiers(Object *ob, EditMesh *em, DerivedMesh **cage
for(i = 0; md; i++, md = md->next, curr = curr->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ md->scene= scene;
+
if(!editmesh_modifier_is_enabled(md, dm))
continue;
@@ -2689,7 +2697,7 @@ static void clear_mesh_caches(Object *ob)
}
}
-static void mesh_build_data(Object *ob, CustomDataMask dataMask)
+static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask)
{
Mesh *me = ob->data;
float min[3], max[3];
@@ -2713,7 +2721,7 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask)
CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
CustomData_set_layer_render(&me->fdata, CD_MCOL, layernum);
- mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
+ mesh_calc_modifiers(scene, ob, NULL, &ob->derivedDeform,
&ob->derivedFinal, 0, 1,
needMapping, dataMask, -1);
@@ -2722,7 +2730,7 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask)
CustomData_set_layer_render(&me->fdata, CD_MCOL, prevrender);
}
else {
- mesh_calc_modifiers(ob, NULL, &ob->derivedDeform,
+ mesh_calc_modifiers(scene, ob, NULL, &ob->derivedDeform,
&ob->derivedFinal, G.rendering, 1,
needMapping, dataMask, -1);
}
@@ -2741,7 +2749,7 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask)
}
-static void editmesh_build_data(Object *obedit, EditMesh *em, CustomDataMask dataMask)
+static void editmesh_build_data(Scene *scene, Object *obedit, EditMesh *em, CustomDataMask dataMask)
{
float min[3], max[3];
@@ -2760,7 +2768,7 @@ static void editmesh_build_data(Object *obedit, EditMesh *em, CustomDataMask dat
em->derivedCage = NULL;
}
- editmesh_calc_modifiers(obedit, em, &em->derivedCage, &em->derivedFinal, dataMask);
+ editmesh_calc_modifiers(scene, obedit, em, &em->derivedCage, &em->derivedFinal, dataMask);
em->lastDataMask = dataMask;
INIT_MINMAX(min, max);
@@ -2775,35 +2783,35 @@ static void editmesh_build_data(Object *obedit, EditMesh *em, CustomDataMask dat
em->derivedCage->needsFree = 0;
}
-void makeDerivedMesh(Object *ob, EditMesh *em, CustomDataMask dataMask)
+void makeDerivedMesh(Scene *scene, Object *ob, EditMesh *em, CustomDataMask dataMask)
{
if (em) {
- editmesh_build_data(ob, em, dataMask);
+ editmesh_build_data(scene, ob, em, dataMask);
} else {
- mesh_build_data(ob, dataMask);
+ mesh_build_data(scene, ob, dataMask);
}
}
/***/
-DerivedMesh *mesh_get_derived_final(Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
if(!ob->derivedFinal || (dataMask & ob->lastDataMask) != dataMask)
- mesh_build_data(ob, dataMask);
+ mesh_build_data(scene, ob, dataMask);
return ob->derivedFinal;
}
-DerivedMesh *mesh_get_derived_deform(Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_deform(Scene *scene, Object *ob, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
if(!ob->derivedDeform || (dataMask & ob->lastDataMask) != dataMask)
- mesh_build_data(ob, dataMask);
+ mesh_build_data(scene, ob, dataMask);
return ob->derivedDeform;
}
@@ -2885,7 +2893,7 @@ void multires_render_final(Object *ob, Mesh *me, DerivedMesh **dm, float *vert_c
/* Multires note - if mesh has multires enabled, mesh is first set to the Pin level,
where all modifiers are applied, then if the topology hasn't changed, the changes
from modifiers are propagated up to the Render level. */
-DerivedMesh *mesh_create_derived_render(Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask dataMask)
{
DerivedMesh *final;
Mesh *me= get_mesh(ob);
@@ -2893,13 +2901,13 @@ DerivedMesh *mesh_create_derived_render(Object *ob, CustomDataMask dataMask)
int orig_lvl= 0;
vert_copy= multires_render_pin(ob, me, &orig_lvl);
- mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1, 0, dataMask, -1);
+ mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, -1);
multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask);
return final;
}
-DerivedMesh *mesh_create_derived_index_render(Object *ob, CustomDataMask dataMask, int index)
+DerivedMesh *mesh_create_derived_index_render(Scene *scene, Object *ob, CustomDataMask dataMask, int index)
{
DerivedMesh *final;
Mesh *me= get_mesh(ob);
@@ -2907,32 +2915,32 @@ DerivedMesh *mesh_create_derived_index_render(Object *ob, CustomDataMask dataMas
int orig_lvl= 0;
vert_copy= multires_render_pin(ob, me, &orig_lvl);
- mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1, 0, dataMask, index);
+ mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, index);
multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask);
return final;
}
-DerivedMesh *mesh_create_derived_view(Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_view(Scene *scene, Object *ob, CustomDataMask dataMask)
{
DerivedMesh *final;
- mesh_calc_modifiers(ob, NULL, NULL, &final, 0, 1, 0, dataMask, -1);
+ mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 0, 1, 0, dataMask, -1);
return final;
}
-DerivedMesh *mesh_create_derived_no_deform(Object *ob, float (*vertCos)[3],
+DerivedMesh *mesh_create_derived_no_deform(Scene *scene, Object *ob, float (*vertCos)[3],
CustomDataMask dataMask)
{
DerivedMesh *final;
- mesh_calc_modifiers(ob, vertCos, NULL, &final, 0, 0, 0, dataMask, -1);
+ mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, 0, 0, dataMask, -1);
return final;
}
-DerivedMesh *mesh_create_derived_no_deform_render(Object *ob,
+DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob,
float (*vertCos)[3],
CustomDataMask dataMask)
{
@@ -2942,7 +2950,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Object *ob,
int orig_lvl= 0;
vert_copy= multires_render_pin(ob, me, &orig_lvl);
- mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0, 0, dataMask, -1);
+ mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 1, 0, 0, dataMask, -1);
multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask);
return final;
@@ -2950,7 +2958,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Object *ob,
/***/
-DerivedMesh *editmesh_get_derived_cage_and_final(Object *obedit, EditMesh *em, DerivedMesh **final_r,
+DerivedMesh *editmesh_get_derived_cage_and_final(Scene *scene, Object *obedit, EditMesh *em, DerivedMesh **final_r,
CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
@@ -2958,20 +2966,20 @@ DerivedMesh *editmesh_get_derived_cage_and_final(Object *obedit, EditMesh *em, D
*/
if(!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
- editmesh_build_data(obedit, em, dataMask);
+ editmesh_build_data(scene, obedit, em, dataMask);
*final_r = em->derivedFinal;
return em->derivedCage;
}
-DerivedMesh *editmesh_get_derived_cage(Object *obedit, EditMesh *em, CustomDataMask dataMask)
+DerivedMesh *editmesh_get_derived_cage(Scene *scene, Object *obedit, EditMesh *em, CustomDataMask dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
if(!em->derivedCage ||
(em->lastDataMask & dataMask) != dataMask)
- editmesh_build_data(obedit, em, dataMask);
+ editmesh_build_data(scene, obedit, em, dataMask);
return em->derivedCage;
}
@@ -3008,7 +3016,7 @@ static void make_vertexcosnos__mapFunc(void *userData, int index, float *co, flo
/* it stores the normals as floats, but they can still be scaled as shorts (32767 = unit) */
/* in use now by vertex/weight paint and particle generating */
-float *mesh_get_mapped_verts_nors(Object *ob)
+float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
{
Mesh *me= ob->data;
DerivedMesh *dm;
@@ -3018,7 +3026,7 @@ float *mesh_get_mapped_verts_nors(Object *ob)
if(ob->type!=OB_MESH || me->totvert==0)
return NULL;
- dm= mesh_get_derived_final(ob, CD_MASK_BAREMESH);
+ dm= mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
vertexcosnos= MEM_callocN(6*sizeof(float)*me->totvert, "vertexcosnos map");
if(dm->foreachMappedVert) {
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index f2a92b9024f..31669cc212a 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1070,7 +1070,7 @@ int execute_ipochannels(ListBase *lb)
/* this now only used for repeating cycles, to enable fields and blur. */
/* the whole time control in blender needs serious thinking... */
-static float nla_time(float cfra, float unit)
+static float nla_time(Scene *scene, float cfra, float unit)
{
extern float bluroffs; // bad construct, borrowed from object.c for now
extern float fieldoffs;
@@ -1079,7 +1079,7 @@ static float nla_time(float cfra, float unit)
cfra+= unit*(bluroffs+fieldoffs);
/* global time */
- cfra*= G.scene->r.framelen;
+ cfra*= scene->r.framelen;
return cfra;
}
@@ -1236,7 +1236,7 @@ static Object *get_parent_path(Object *ob)
/* For the calculation of the effects of an action at the given frame on an object
* This is currently only used for the action constraint
*/
-void what_does_obaction (Object *ob, Object *workob, bAction *act, float cframe)
+void what_does_obaction (Scene *scene, Object *ob, Object *workob, bAction *act, float cframe)
{
ListBase tchanbase= {NULL, NULL};
@@ -1264,7 +1264,7 @@ void what_does_obaction (Object *ob, Object *workob, bAction *act, float cframe)
/* extract_ipochannels_from_action needs id's! */
workob->action= act;
- extract_ipochannels_from_action(&tchanbase, &workob->id, act, "Object", bsystem_time(workob, cframe, 0.0));
+ extract_ipochannels_from_action(&tchanbase, &workob->id, act, "Object", bsystem_time(scene, workob, cframe, 0.0));
if (tchanbase.first) {
execute_ipochannels(&tchanbase);
@@ -1274,7 +1274,7 @@ void what_does_obaction (Object *ob, Object *workob, bAction *act, float cframe)
/* ----- nla, etc. --------- */
-static void do_nla(Object *ob, int blocktype)
+static void do_nla(Scene *scene, Object *ob, int blocktype)
{
bPose *tpose= NULL;
Key *key= NULL;
@@ -1282,7 +1282,7 @@ static void do_nla(Object *ob, int blocktype)
bActionStrip *strip, *striplast=NULL, *stripfirst=NULL;
float striptime, frametime, length, actlength;
float blendfac, stripframe;
- float scene_cfra= frame_to_float(G.scene->r.cfra);
+ float scene_cfra= frame_to_float(scene, scene->r.cfra);
int doit, dostride;
if(blocktype==ID_AR) {
@@ -1348,11 +1348,11 @@ static void do_nla(Object *ob, int blocktype)
if (cu->flag & CU_PATH){
/* Ensure we have a valid path */
- if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(parent, 0);
+ if(cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0);
if(cu->path) {
/* Find the position on the path */
- ctime= bsystem_time(ob, scene_cfra, 0.0);
+ ctime= bsystem_time(scene, ob, scene_cfra, 0.0);
if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
/* correct for actions not starting on zero */
@@ -1374,7 +1374,7 @@ static void do_nla(Object *ob, int blocktype)
}
frametime = (striptime * actlength) + strip->actstart;
- frametime= bsystem_time(ob, frametime, 0.0);
+ frametime= bsystem_time(scene, ob, frametime, 0.0);
if(blocktype==ID_AR) {
extract_pose_from_action (tpose, strip->act, frametime);
@@ -1404,7 +1404,7 @@ static void do_nla(Object *ob, int blocktype)
}
frametime = (striptime * actlength) + strip->actstart;
- frametime= nla_time(frametime, (float)strip->repeat);
+ frametime= nla_time(scene, frametime, (float)strip->repeat);
if(blocktype==ID_AR) {
extract_pose_from_action (tpose, strip->act, frametime);
@@ -1425,7 +1425,7 @@ static void do_nla(Object *ob, int blocktype)
frametime = actlength * (strip->repeat-(int)strip->repeat);
if(frametime<=0.000001f) frametime= actlength; /* rounding errors... */
- frametime= bsystem_time(ob, frametime+strip->actstart, 0.0);
+ frametime= bsystem_time(scene, ob, frametime+strip->actstart, 0.0);
if(blocktype==ID_AR)
extract_pose_from_action (tpose, strip->act, frametime);
@@ -1490,7 +1490,7 @@ static void do_nla(Object *ob, int blocktype)
BLI_freelistN(&chanbase);
}
-void do_all_pose_actions(Object *ob)
+void do_all_pose_actions(Scene *scene, Object *ob)
{
/* only to have safe calls from editor */
if(ob==NULL) return;
@@ -1501,14 +1501,14 @@ void do_all_pose_actions(Object *ob)
ob->pose->flag &= ~(POSE_LOCKED|POSE_DO_UNLOCK);
}
else if(ob->action && ((ob->nlaflag & OB_NLA_OVERRIDE)==0 || ob->nlastrips.first==NULL) ) {
- float cframe= (float) G.scene->r.cfra;
+ float cframe= (float) scene->r.cfra;
cframe= get_action_frame(ob, cframe);
- extract_pose_from_action (ob->pose, ob->action, bsystem_time(ob, cframe, 0.0));
+ extract_pose_from_action (ob->pose, ob->action, bsystem_time(scene, ob, cframe, 0.0));
}
else if(ob->nlastrips.first) {
- do_nla(ob, ID_AR);
+ do_nla(scene, ob, ID_AR);
}
/* clear POSE_DO_UNLOCK flags that might have slipped through (just in case) */
@@ -1516,7 +1516,7 @@ void do_all_pose_actions(Object *ob)
}
/* called from where_is_object */
-void do_all_object_actions(Object *ob)
+void do_all_object_actions(Scene *scene, Object *ob)
{
if(ob==NULL) return;
if(ob->dup_group) return; /* prevent conflicts, might add smarter check later */
@@ -1525,13 +1525,13 @@ void do_all_object_actions(Object *ob)
if(ob->action && ((ob->nlaflag & OB_NLA_OVERRIDE)==0 || ob->nlastrips.first==NULL) ) {
ListBase tchanbase= {NULL, NULL};
Key *key= ob_get_key(ob);
- float cframe= (float) G.scene->r.cfra;
+ float cframe= (float) scene->r.cfra;
cframe= get_action_frame(ob, cframe);
- extract_ipochannels_from_action(&tchanbase, &ob->id, ob->action, "Object", bsystem_time(ob, cframe, 0.0));
+ extract_ipochannels_from_action(&tchanbase, &ob->id, ob->action, "Object", bsystem_time(scene, ob, cframe, 0.0));
if(key)
- extract_ipochannels_from_action(&tchanbase, &key->id, ob->action, "Shape", bsystem_time(ob, cframe, 0.0));
+ extract_ipochannels_from_action(&tchanbase, &key->id, ob->action, "Shape", bsystem_time(scene, ob, cframe, 0.0));
if(tchanbase.first) {
execute_ipochannels(&tchanbase);
@@ -1539,6 +1539,6 @@ void do_all_object_actions(Object *ob)
}
}
else if(ob->nlastrips.first) {
- do_nla(ob, ID_OB);
+ do_nla(scene, ob, ID_OB);
}
}
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index bf88ad16bdf..2845867b920 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -72,7 +72,7 @@
#include <config.h>
#endif
-static void object_duplilist_recursive(ID *id, Object *ob, Object *obedit, ListBase *duplilist, float par_space_mat[][4], int level, int animated);
+static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated);
void free_path(Path *path)
{
@@ -299,7 +299,7 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i
return dob;
}
-static void group_duplilist(ListBase *lb, Object *ob, Object *obedit, int level, int animated)
+static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated)
{
DupliObject *dob;
Group *group;
@@ -314,7 +314,7 @@ static void group_duplilist(ListBase *lb, Object *ob, Object *obedit, int level,
/* handles animated groups, and */
/* we need to check update for objects that are not in scene... */
- group_handle_recalc_and_update(ob, group);
+ group_handle_recalc_and_update(scene, ob, group);
animated= animated || group_is_animated(ob, group);
for(go= group->gobject.first; go; go= go->next) {
@@ -335,14 +335,14 @@ static void group_duplilist(ListBase *lb, Object *ob, Object *obedit, int level,
if(go->ob->transflag & OB_DUPLI) {
Mat4CpyMat4(dob->ob->obmat, dob->mat);
- object_duplilist_recursive((ID *)group, go->ob, obedit, lb, ob->obmat, level+1, animated);
+ object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated);
Mat4CpyMat4(dob->ob->obmat, dob->omat);
}
}
}
}
-static void frames_duplilist(ListBase *lb, Object *ob, int level, int animated)
+static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated)
{
extern int enable_cu_speed; /* object.c */
Object copyob;
@@ -352,31 +352,31 @@ static void frames_duplilist(ListBase *lb, Object *ob, int level, int animated)
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
- cfrao= G.scene->r.cfra;
+ cfrao= scene->r.cfra;
if(ob->parent==NULL && ob->track==NULL && ob->ipo==NULL && ob->constraints.first==NULL) return;
if(ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0;
copyob= *ob; /* store transform info */
- for(G.scene->r.cfra= ob->dupsta; G.scene->r.cfra<=ob->dupend; G.scene->r.cfra++) {
+ for(scene->r.cfra= ob->dupsta; scene->r.cfra<=ob->dupend; scene->r.cfra++) {
ok= 1;
if(ob->dupoff) {
- ok= G.scene->r.cfra - ob->dupsta;
+ ok= scene->r.cfra - ob->dupsta;
ok= ok % (ob->dupon+ob->dupoff);
if(ok < ob->dupon) ok= 1;
else ok= 0;
}
if(ok) {
- do_ob_ipo(ob);
- where_is_object_time(ob, (float)G.scene->r.cfra);
- dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, G.scene->r.cfra, OB_DUPLIFRAMES, animated);
+ do_ob_ipo(scene, ob);
+ where_is_object_time(scene, ob, (float)scene->r.cfra);
+ dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated);
Mat4CpyMat4(dob->omat, copyob.obmat);
}
}
*ob= copyob; /* restore transform info */
- G.scene->r.cfra= cfrao;
+ scene->r.cfra= cfrao;
enable_cu_speed= 1;
}
@@ -387,7 +387,8 @@ struct vertexDupliData {
ListBase *lb;
float pmat[4][4];
float obmat[4][4]; /* Only used for dupliverts inside dupligroups, where the ob->obmat is modified */
- Object *ob, *par, *obedit;
+ Scene *scene;
+ Object *ob, *par;
float (*orco)[3];
};
@@ -427,12 +428,12 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
float tmpmat[4][4];
Mat4CpyMat4(tmpmat, vdd->ob->obmat);
Mat4CpyMat4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
- object_duplilist_recursive((ID *)vdd->id, vdd->ob, vdd->obedit, vdd->lb, obmat, vdd->level+1, vdd->animated);
+ object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated);
Mat4CpyMat4(vdd->ob->obmat, tmpmat);
}
}
-static void vertex_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, float par_space_mat[][4], int level, int animated)
+static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int level, int animated)
{
Object *ob, *ob_iter;
Mesh *me= par->data;
@@ -451,9 +452,9 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par,
if(level>MAX_DUPLI_RECUR) return;
if(me->edit_mesh)
- dm= editmesh_get_derived_cage(par, me->edit_mesh, CD_MASK_BAREMESH);
+ dm= editmesh_get_derived_cage(scene, par, me->edit_mesh, CD_MASK_BAREMESH);
else
- dm= mesh_get_derived_deform(par, CD_MASK_BAREMESH);
+ dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
if(G.rendering) {
vdd.orco= (float(*)[3])get_mesh_orco_verts(par);
@@ -485,7 +486,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par,
oblay = ob_iter->lay;
}
- if (lay & oblay && obedit!=ob_iter) {
+ if (lay & oblay && scene->obedit!=ob_iter) {
ob=ob_iter->parent;
while(ob) {
if(ob==par) {
@@ -506,14 +507,14 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par,
vdd.animated= animated;
vdd.lb= lb;
vdd.ob= ob;
- vdd.obedit= obedit;
+ vdd.scene= scene;
vdd.par= par;
Mat4CpyMat4(vdd.pmat, pmat);
/* mballs have a different dupli handling */
if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
- if(par==obedit) {
+ if(par==scene->obedit) {
dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd);
}
else {
@@ -539,7 +540,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par,
dm->release(dm);
}
-static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, float par_space_mat[][4], int level, int animated)
+static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int level, int animated)
{
Object *ob, *ob_iter;
Base *base = NULL;
@@ -564,7 +565,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, fl
if(me->edit_mesh) {
int totvert;
- dm= editmesh_get_derived_cage(par, me->edit_mesh, CD_MASK_BAREMESH);
+ dm= editmesh_get_derived_cage(scene, par, me->edit_mesh, CD_MASK_BAREMESH);
totface= dm->getNumFaces(dm);
mface= MEM_mallocN(sizeof(MFace)*totface, "mface temp");
@@ -574,7 +575,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, fl
dm->copyVertArray(dm, mvert);
}
else {
- dm = mesh_get_derived_deform(par, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
totface= dm->getNumFaces(dm);
mface= dm->getFaceArray(dm);
@@ -613,7 +614,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, fl
oblay = ob_iter->lay;
}
- if (lay & oblay && obedit!=ob_iter) {
+ if (lay & oblay && scene->obedit!=ob_iter) {
ob=ob_iter->parent;
while(ob) {
if(ob==par) {
@@ -706,7 +707,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, fl
float tmpmat[4][4];
Mat4CpyMat4(tmpmat, ob->obmat);
Mat4CpyMat4(ob->obmat, obmat); /* pretend we are really this mat */
- object_duplilist_recursive((ID *)id, ob, obedit, lb, ob->obmat, level+1, animated);
+ object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated);
Mat4CpyMat4(ob->obmat, tmpmat);
}
}
@@ -720,7 +721,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, fl
else go= go->next; /* group loop */
}
- if(par==obedit) {
+ if(par==scene->obedit) {
MEM_freeN(mface);
MEM_freeN(mvert);
}
@@ -731,7 +732,7 @@ static void face_duplilist(ListBase *lb, ID *id, Object *obedit, Object *par, fl
dm->release(dm);
}
-static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated)
+static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated)
{
GroupObject *go;
Object *ob=0, **oblist=0, obcopy, *obcopylist=0;
@@ -762,14 +763,14 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
if(!psys_check_enabled(par, psys))
return;
- ctime = bsystem_time(par, (float)G.scene->r.cfra, 0.0);
+ ctime = bsystem_time(scene, par, (float)scene->r.cfra, 0.0);
totpart = psys->totpart;
totchild = psys->totchild;
BLI_srandom(31415926 + psys->seed);
- lay= G.scene->lay;
+ lay= scene->lay;
if((part->draw_as == PART_DRAW_OB && part->dup_ob) ||
(part->draw_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first)) {
@@ -790,11 +791,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
totpart = psys->totcached;
}
- psys->lattice = psys_get_lattice(par, psys);
+ psys->lattice = psys_get_lattice(scene, par, psys);
/* gather list of objects or single object */
if(part->draw_as==PART_DRAW_GR) {
- group_handle_recalc_and_update(par, part->dup_group);
+ group_handle_recalc_and_update(scene, par, part->dup_group);
for(go=part->dup_group->gobject.first; go; go=go->next)
totgroup++;
@@ -876,7 +877,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
else if(step_nbr) {
/* other keys */
state.time = (float)k / (float)step_nbr;
- psys_get_particle_on_path(par, psys, a, &state, 0);
+ psys_get_particle_on_path(scene, par, psys, a, &state, 0);
QuatToMat4(state.rot, pamat);
VECCOPY(pamat[3], state.co);
@@ -885,7 +886,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
else {
/* first key */
state.time = -1.0;
- if(psys_get_particle_state(par, psys, a, &state, 0) == 0)
+ if(psys_get_particle_state(scene, par, psys, a, &state, 0) == 0)
continue;
QuatToMat4(state.rot, pamat);
@@ -910,7 +911,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_
}
else {
/* to give ipos in object correct offset */
- where_is_object_time(ob, ctime-pa_time);
+ where_is_object_time(scene, ob, ctime-pa_time);
Mat4CpyMat4(mat, pamat);
@@ -973,7 +974,7 @@ static Object *find_family_object(Object **obar, char *family, char ch)
}
-static void font_duplilist(ListBase *lb, Object *par, int level, int animated)
+static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated)
{
Object *ob, *obar[256];
Curve *cu;
@@ -988,7 +989,7 @@ static void font_duplilist(ListBase *lb, Object *par, int level, int animated)
/* in par the family name is stored, use this to find the other objects */
- chartransdata= text_to_curve(par, FO_DUPLI);
+ chartransdata= text_to_curve(scene, par, FO_DUPLI);
if(chartransdata==0) return;
memset(obar, 0, 256*sizeof(void *));
@@ -1022,7 +1023,7 @@ static void font_duplilist(ListBase *lb, Object *par, int level, int animated)
}
/* ***************************** */
-static void object_duplilist_recursive(ID *id, Object *ob, Object *obedit, ListBase *duplilist, float par_space_mat[][4], int level, int animated)
+static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated)
{
if((ob->transflag & OB_DUPLI)==0)
return;
@@ -1041,30 +1042,30 @@ static void object_duplilist_recursive(ID *id, Object *ob, Object *obedit, ListB
if(ob->transflag & OB_DUPLIPARTS) {
ParticleSystem *psys = ob->particlesystem.first;
for(; psys; psys=psys->next)
- new_particle_duplilist(duplilist, id, ob, par_space_mat, psys, level+1, animated);
+ new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level+1, animated);
}
else if(ob->transflag & OB_DUPLIVERTS) {
if(ob->type==OB_MESH) {
- vertex_duplilist(duplilist, id, obedit, ob, par_space_mat, level+1, animated);
+ vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
}
else if(ob->type==OB_FONT) {
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
- font_duplilist(duplilist, ob, level+1, animated);
+ font_duplilist(duplilist, scene, ob, level+1, animated);
}
}
}
else if(ob->transflag & OB_DUPLIFACES) {
if(ob->type==OB_MESH)
- face_duplilist(duplilist, id, obedit, ob, par_space_mat, level+1, animated);
+ face_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated);
}
else if(ob->transflag & OB_DUPLIFRAMES) {
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
- frames_duplilist(duplilist, ob, level+1, animated);
+ frames_duplilist(duplilist, scene, ob, level+1, animated);
}
} else if(ob->transflag & OB_DUPLIGROUP) {
DupliObject *dob;
- group_duplilist(duplilist, ob, obedit, level+1, animated); /* now recursive */
+ group_duplilist(duplilist, scene, ob, level+1, animated); /* now recursive */
if (level==0) {
for(dob= duplilist->first; dob; dob= dob->next)
@@ -1080,7 +1081,7 @@ ListBase *object_duplilist(Scene *sce, Object *ob)
{
ListBase *duplilist= MEM_mallocN(sizeof(ListBase), "duplilist");
duplilist->first= duplilist->last= NULL;
- object_duplilist_recursive((ID *)sce, ob, sce->obedit, duplilist, NULL, 0, 0);
+ object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, 0, 0);
return duplilist;
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index e7ae7997e9f..ce5921a701d 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2032,11 +2032,11 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = t
}
/* NLA strip modifiers */
-static void do_strip_modifiers(Object *armob, Bone *bone, bPoseChannel *pchan)
+static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseChannel *pchan)
{
bActionModifier *amod;
bActionStrip *strip, *strip2;
- float scene_cfra= G.scene->r.cfra;
+ float scene_cfra= scene->r.cfra;
int do_modif;
for (strip=armob->nlastrips.first; strip; strip=strip->next) {
@@ -2085,7 +2085,7 @@ static void do_strip_modifiers(Object *armob, Bone *bone, bPoseChannel *pchan)
if( strcmp(pchan->name, amod->channel)==0 ) {
float mat4[4][4], mat3[3][3];
- curve_deform_vector(amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
+ curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
Mat4CpyMat4(mat4, pchan->pose_mat);
Mat4MulMat34(pchan->pose_mat, mat3, mat4);
@@ -2156,7 +2156,7 @@ static void do_strip_modifiers(Object *armob, Bone *bone, bPoseChannel *pchan)
/* The main armature solver, does all constraints excluding IK */
/* pchan is validated, as having bone and parent pointer */
-static void where_is_pose_bone(Object *ob, bPoseChannel *pchan, float ctime)
+static void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
{
Bone *bone, *parbone;
bPoseChannel *parchan;
@@ -2226,7 +2226,7 @@ static void where_is_pose_bone(Object *ob, bPoseChannel *pchan, float ctime)
}
/* do NLA strip modifiers - i.e. curve follow */
- do_strip_modifiers(ob, bone, pchan);
+ do_strip_modifiers(scene, ob, bone, pchan);
/* Do constraints */
if (pchan->constraints.first) {
@@ -2241,7 +2241,7 @@ static void where_is_pose_bone(Object *ob, bPoseChannel *pchan, float ctime)
/* prepare PoseChannel for Constraint solving
* - makes a copy of matrix, and creates temporary struct to use
*/
- cob= constraints_make_evalob(ob, pchan, CONSTRAINT_OBTYPE_BONE);
+ cob= constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
/* Solve PoseChannel's Constraints */
solve_constraints(&pchan->constraints, cob, ctime); // ctime doesnt alter objects
@@ -2267,13 +2267,13 @@ static void where_is_pose_bone(Object *ob, bPoseChannel *pchan, float ctime)
/* This only reads anim data from channels, and writes to channels */
/* This is the only function adding poses */
-void where_is_pose (Object *ob)
+void where_is_pose (Scene *scene, Object *ob)
{
bArmature *arm;
Bone *bone;
bPoseChannel *pchan;
float imat[4][4];
- float ctime= bsystem_time(ob, (float)G.scene->r.cfra, 0.0); /* not accurate... */
+ float ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0); /* not accurate... */
arm = get_armature(ob);
@@ -2315,7 +2315,7 @@ void where_is_pose (Object *ob)
/* 4. walk over the tree for regular solving */
for(a=0; a<tree->totchannel; a++) {
if(!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
- where_is_pose_bone(ob, tree->pchan[a], ctime);
+ where_is_pose_bone(scene, ob, tree->pchan[a], ctime);
}
/* 5. execute the IK solver */
execute_posetree(ob, tree);
@@ -2335,7 +2335,7 @@ void where_is_pose (Object *ob)
}
}
else if(!(pchan->flag & POSE_DONE)) {
- where_is_pose_bone(ob, pchan, ctime);
+ where_is_pose_bone(scene, ob, pchan, ctime);
}
}
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index ef740038e57..e6fd3cc8612 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -224,8 +224,6 @@ static void clear_global(void)
// free_vertexpaint();
- G.curscreen= NULL;
- G.scene= NULL;
G.main= NULL;
G.f &= ~(G_WEIGHTPAINT + G_VERTEXPAINT + G_FACESELECT + G_PARTICLEEDIT);
@@ -351,10 +349,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
CTX_wm_screen_set(C, bfd->curscreen);
CTX_data_scene_set(C, bfd->curscreen->scene);
}
+
/* this can happen when active scene was lib-linked, and doesnt exist anymore */
if(CTX_data_scene(C)==NULL) {
CTX_data_scene_set(C, G.main->scene.first);
CTX_wm_screen(C)->scene= CTX_data_scene(C);
+ curscene= CTX_data_scene(C);
}
/* special cases, override loaded flags: */
@@ -378,7 +378,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
/* last stage of do_versions actually, that sets recalc flags for recalc poses */
for(ob= G.main->object.first; ob; ob= ob->id.next) {
if(ob->type==OB_ARMATURE)
- if(ob->recalc) object_handle_update(ob);
+ if(ob->recalc) object_handle_update(curscene, ob);
}
/* now tag update flags, to ensure deformers get calculated on redraw */
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 2c1b5ced614..aca25237337 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -925,9 +925,10 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob)
/* works in conjunction with hack during modifier calc, where active mcol
layer with weight paint colors is temporarily added */
- if ((G.f & G_WEIGHTPAINT) &&
- (ob && ob==(G.scene->basact?G.scene->basact->object:NULL)))
- CustomData_duplicate_referenced_layer(&dm->faceData, CD_MCOL);
+ /* XXX make this real but temporary layer */
+// if ((G.f & G_WEIGHTPAINT) &&
+// (ob && ob==(scene->basact?scene->basact->object:NULL)))
+// CustomData_duplicate_referenced_layer(&dm->faceData, CD_MCOL);
return dm;
}
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index dbc94571cad..6c9dfe4bf0a 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -479,7 +479,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
/************************************************
* clothModifier_do - main simulation function
************************************************/
-DerivedMesh *clothModifier_do(ClothModifierData *clmd, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc)
+DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc)
{
DerivedMesh *result;
PointCache *cache;
@@ -487,12 +487,13 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Object *ob, DerivedMesh *
float timescale;
int framedelta, framenr, startframe, endframe;
- framenr= (int)G.scene->r.cfra;
+ clmd->scene= scene; /* nice to pass on later :) */
+ framenr= (int)scene->r.cfra;
cache= clmd->point_cache;
result = CDDM_copy(dm);
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
- BKE_ptcache_id_time(&pid, framenr, &startframe, &endframe, &timescale);
+ BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
clmd->sim_parms->timescale= timescale;
if(!result) {
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 4f8068ac252..9e57fef41f7 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1296,7 +1296,7 @@ int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierData *col
// return all collision objects in scene
// collision object will exclude self
-CollisionModifierData **get_collisionobjects(Object *self, int *numcollobj)
+CollisionModifierData **get_collisionobjects(Scene *scene, Object *self, int *numcollobj)
{
Base *base=NULL;
CollisionModifierData **objs = NULL;
@@ -1306,7 +1306,7 @@ CollisionModifierData **get_collisionobjects(Object *self, int *numcollobj)
objs = MEM_callocN(sizeof(CollisionModifierData *)*maxobj, "CollisionObjectsArray");
// check all collision objects
- for ( base = G.scene->base.first; base; base = base->next )
+ for ( base = scene->base.first; base; base = base->next )
{
/*Only proceed for mesh object in same layer */
if(!(base->object->type==OB_MESH && (base->lay & self->lay)))
@@ -1451,7 +1451,7 @@ int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, CollisionModifie
}
// cloth - object collisions
-int cloth_bvh_objcollision ( Object *ob, ClothModifierData * clmd, float step, float dt )
+int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, float dt )
{
Cloth *cloth=NULL;
BVHTree *cloth_bvh=NULL;
@@ -1481,7 +1481,7 @@ int cloth_bvh_objcollision ( Object *ob, ClothModifierData * clmd, float step, f
bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function)
bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function)
- collobjs = get_collisionobjects(ob, &numcollobj);
+ collobjs = get_collisionobjects(clmd->scene, ob, &numcollobj);
if(!collobjs)
return 0;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 82b1c71e56a..52448fca8d6 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -250,13 +250,16 @@ void unique_constraint_name (bConstraint *con, ListBase *list)
/* package an object/bone for use in constraint evaluation */
/* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */
-bConstraintOb *constraints_make_evalob (Object *ob, void *subdata, short datatype)
+bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, short datatype)
{
bConstraintOb *cob;
/* create regardless of whether we have any data! */
cob= MEM_callocN(sizeof(bConstraintOb), "bConstraintOb");
+ /* for system time, part of deglobalization, code nicer later with local time (ton) */
+ cob->scene= scene;
+
/* based on type of available data */
switch (datatype) {
case CONSTRAINT_OBTYPE_OBJECT:
@@ -1295,10 +1298,10 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
/* only happens on reload file, but violates depsgraph still... fix! */
if (cu->path==NULL || cu->path->data==NULL)
- makeDispListCurveTypes(ct->tar, 0);
+ makeDispListCurveTypes(cob->scene, ct->tar, 0);
if (cu->path && cu->path->data) {
- curvetime= bsystem_time(ct->tar, (float)ctime, 0.0) - data->offset;
+ curvetime= bsystem_time(cob->scene, ct->tar, (float)ctime, 0.0) - data->offset;
if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) {
curvetime /= cu->pathlen;
@@ -1883,7 +1886,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT
/* this check is to make sure curve objects get updated on file load correctly.*/
if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
- makeDispListCurveTypes(ct->tar, 0);
+ makeDispListCurveTypes(cob->scene, ct->tar, 0);
}
/* firstly calculate the matrix the normal way, then let the py-function override
@@ -2050,7 +2053,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
else if (cob->type == CONSTRAINT_OBTYPE_OBJECT) {
Object workob;
/* evaluate using workob */
- what_does_obaction(cob->ob, &workob, data->act, t);
+ what_does_obaction(cob->scene, cob->ob, &workob, data->act, t);
object_to_mat4(&workob, ct->matrix);
}
else {
@@ -2965,7 +2968,7 @@ static void clampto_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain
/* only happens on reload file, but violates depsgraph still... fix! */
if (cu->path==NULL || cu->path->data==NULL)
- makeDispListCurveTypes(ct->tar, 0);
+ makeDispListCurveTypes(cob->scene, ct->tar, 0);
}
/* technically, this isn't really needed for evaluation, but we don't know what else
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 0a58ae59386..ccb7811cbb9 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -48,21 +48,22 @@
/* for dereferencing pointers */
#include "DNA_ID.h"
-#include "DNA_vfont_types.h"
#include "DNA_key_types.h"
#include "DNA_ipo_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_vfont_types.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_utildefines.h" // VECCOPY
-#include "BKE_object.h"
-#include "BKE_mesh.h"
+#include "BKE_anim.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
+#include "BKE_global.h"
#include "BKE_ipo.h"
-#include "BKE_anim.h"
-#include "BKE_library.h"
#include "BKE_key.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_mesh.h"
+#include "BKE_object.h"
+#include "BKE_utildefines.h" // VECCOPY
/* globals */
@@ -1033,7 +1034,7 @@ float *make_orco_surf(Object *ob)
/* NOTE: This routine is tied to the order of vertex
* built by displist and as passed to the renderer.
*/
-float *make_orco_curve(Object *ob)
+float *make_orco_curve(Scene *scene, Object *ob)
{
Curve *cu = ob->data;
DispList *dl;
@@ -1043,7 +1044,7 @@ float *make_orco_curve(Object *ob)
if (!(cu->flag&CU_UV_ORCO) && cu->key && cu->key->refkey) {
cp_cu_key(cu, cu->key->refkey, 0, count_curveverts(&cu->nurb));
- makeDispListCurveTypes(ob, 1);
+ makeDispListCurveTypes(scene, ob, 1);
remakeDisp = 1;
}
@@ -1116,7 +1117,7 @@ float *make_orco_curve(Object *ob)
}
if (remakeDisp) {
- makeDispListCurveTypes(ob, 0);
+ makeDispListCurveTypes(scene, ob, 0);
}
return coord_array;
@@ -1125,7 +1126,7 @@ float *make_orco_curve(Object *ob)
/* ***************** BEVEL ****************** */
-void makebevelcurve(Object *ob, ListBase *disp)
+void makebevelcurve(Scene *scene, Object *ob, ListBase *disp)
{
DispList *dl, *dlnew;
Curve *bevcu, *cu;
@@ -1147,7 +1148,7 @@ void makebevelcurve(Object *ob, ListBase *disp)
dl= bevcu->disp.first;
if(dl==0) {
- makeDispListCurveTypes(cu->bevobj, 0);
+ makeDispListCurveTypes(scene, cu->bevobj, 0);
dl= bevcu->disp.first;
}
while(dl) {
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index e090a2e4cae..01dd6c0c657 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -349,14 +349,14 @@ static void dag_add_driver_relation(Ipo *ipo, DagForest *dag, DagNode *node, int
}
}
-static void dag_add_collision_field_relation(DagForest *dag, Object *ob, DagNode *node)
+static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node)
{
Base *base;
DagNode *node2;
// would be nice to have a list of colliders here
// so for now walk all objects in scene check 'same layer rule'
- for(base = G.scene->base.first; base; base= base->next) {
+ for(base = scene->base.first; base; base= base->next) {
if((base->lay & ob->lay) && base->object->pd) {
Object *ob1= base->object;
if((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) {
@@ -367,7 +367,7 @@ static void dag_add_collision_field_relation(DagForest *dag, Object *ob, DagNode
}
}
-static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int mask)
+static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, Object *ob, int mask)
{
bConstraint *con;
bConstraintChannel *conchan;
@@ -471,7 +471,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int
for(md=ob->modifiers.first; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (mti->updateDepgraph) mti->updateDepgraph(md, dag, ob, node);
+ if (mti->updateDepgraph) mti->updateDepgraph(md, dag, scene, ob, node);
}
}
if (ob->parent) {
@@ -546,10 +546,10 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int
/* softbody collision */
if((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE))
if(modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob))
- dag_add_collision_field_relation(dag, ob, node);
+ dag_add_collision_field_relation(dag, scene, ob, node);
if (ob->type==OB_MBALL) {
- Object *mom= find_basis_mball(ob);
+ Object *mom= find_basis_mball(scene, ob);
if(mom!=ob) {
node2 = dag_get_node(dag, mom);
dag_add_relation(dag,node,node2,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children!
@@ -612,7 +612,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int
if(psys->effectors.first)
psys_end_effectors(psys);
- psys_init_effectors(ob,psys->part->eff_group,psys);
+ psys_init_effectors(scene, ob, psys->part->eff_group, psys);
if(psys->effectors.first) {
for(nec= psys->effectors.first; nec; nec= nec->next) {
@@ -707,9 +707,9 @@ struct DagForest *build_dag(struct Scene *sce, short mask)
for(base = sce->base.first; base; base= base->next) {
ob= base->object;
- build_dag_object(dag, scenenode, ob, mask);
+ build_dag_object(dag, scenenode, sce, ob, mask);
if(ob->proxy)
- build_dag_object(dag, scenenode, ob->proxy, mask);
+ build_dag_object(dag, scenenode, sce, ob->proxy, mask);
/* handled in next loop */
if(ob->dup_group)
@@ -720,7 +720,7 @@ struct DagForest *build_dag(struct Scene *sce, short mask)
for(group= G.main->group.first; group; group= group->id.next) {
if(group->id.flag & LIB_DOIT) {
for(go= group->gobject.first; go; go= go->next) {
- build_dag_object(dag, scenenode, go->ob, mask);
+ build_dag_object(dag, scenenode, sce, go->ob, mask);
}
group->id.flag &= ~LIB_DOIT;
}
@@ -2137,22 +2137,6 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay)
}
-/* for depgraph updating, all layers visible in a screen */
-/* this is a copy from editscreen.c... I need to think over a more proper solution for this */
-/* probably the DAG_object_flush_update() should give layer too? */
-/* or some kind of dag context... (DAG_set_layer) */
-static unsigned int dag_screen_view3d_layers(void)
-{
- ScrArea *sa;
- int layer= 0;
-
- for(sa= G.curscreen->areabase.first; sa; sa= sa->next) {
- if(sa->spacetype==SPACE_VIEW3D)
- layer |= ((View3D *)sa->spacedata.first)->lay;
- }
- return layer;
-}
-
/* flag this object and all its relations to recalc */
/* if you need to do more objects, tag object yourself and
@@ -2186,9 +2170,9 @@ void DAG_object_flush_update(Scene *sce, Object *ob, short flag)
}
}
- if(G.curscreen)
- DAG_scene_flush_update(sce, dag_screen_view3d_layers(), 0);
- else
+// XXX if(G.curscreen)
+// DAG_scene_flush_update(sce, dag_screen_view3d_layers(), 0);
+// else
DAG_scene_flush_update(sce, sce->lay, 0);
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 52ec529b82a..952c49ea12a 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -304,22 +304,22 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i
/* create default shade input... save cpu cycles with ugly global */
/* XXXX bad code warning: local ShadeInput initialize... */
static ShadeInput shi;
-static void init_fastshade_shadeinput(void)
+static void init_fastshade_shadeinput(Render *re)
{
memset(&shi, 0, sizeof(ShadeInput));
- shi.lay= G.scene->lay;
+ shi.lay= RE_GetScene(re)->lay;
shi.view[2]= -1.0f;
shi.passflag= SCE_PASS_COMBINED;
shi.combinedflag= -1;
}
-static Render *fastshade_get_render(void)
+static Render *fastshade_get_render(Scene *scene)
{
Render *re= RE_GetRender("_Shade View_");
if(re==NULL) {
re= RE_NewRender("_Shade View_");
- RE_Database_Baking(re, G.scene, 0, 0); /* 0= no faces */
+ RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */
}
return re;
}
@@ -462,7 +462,7 @@ static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, floa
RE_shade_external(re, NULL, NULL);
/* initialize global here */
- init_fastshade_shadeinput();
+ init_fastshade_shadeinput(re);
RE_DataBase_GetView(re, tmat);
Mat4MulMat4(mat, ob->obmat, tmat);
@@ -515,9 +515,9 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
dataMask |= CD_MASK_ORCO;
if (onlyForMesh)
- dm = mesh_get_derived_deform(ob, dataMask);
+ dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask);
else
- dm = mesh_get_derived_final(ob, dataMask);
+ dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask);
mvert = dm->getVertArray(dm);
mface = dm->getFaceArray(dm);
@@ -609,13 +609,13 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
end_fastshade_for_ob(ob);
}
-void shadeMeshMCol(Object *ob, Mesh *me)
+void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me)
{
int a;
char *cp;
unsigned int *mcol= (unsigned int*)me->mcol;
- Render *re= fastshade_get_render();
+ Render *re= fastshade_get_render(scene);
mesh_create_shadedColors(re, ob, 1, &mcol, NULL);
me->mcol= (MCol*)mcol;
@@ -628,7 +628,7 @@ void shadeMeshMCol(Object *ob, Mesh *me)
/* has base pointer, to check for layer */
/* called from drawobject.c */
-void shadeDispList(Base *base)
+void shadeDispList(Scene *scene, Base *base)
{
Object *ob= base->object;
DispList *dl, *dlob;
@@ -640,7 +640,7 @@ void shadeDispList(Base *base)
unsigned int *col1;
int a, need_orco;
- re= fastshade_get_render();
+ re= fastshade_get_render(scene);
dl = find_displist(&ob->disp, DL_VERTCOL);
if (dl) {
@@ -779,22 +779,22 @@ void shadeDispList(Base *base)
/* frees render and shade part of displists */
/* note: dont do a shade again, until a redraw happens */
-void reshadeall_displist(void)
+void reshadeall_displist(Scene *scene)
{
Base *base;
Object *ob;
fastshade_free_render();
- for(base= G.scene->base.first; base; base= base->next) {
+ for(base= scene->base.first; base; base= base->next) {
ob= base->object;
if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
freedisplist(&ob->disp);
- if(base->lay & G.scene->lay) {
+ if(base->lay & scene->lay) {
/* Metaballs have standard displist at the Object */
- if(ob->type==OB_MBALL) shadeDispList(base);
+ if(ob->type==OB_MBALL) shadeDispList(scene, base);
}
}
}
@@ -1130,7 +1130,7 @@ void curve_to_filledpoly(Curve *cu, ListBase *nurb, ListBase *dispbase)
- first point left, last point right
- based on subdivided points in original curve, not on points in taper curve (still)
*/
-float calc_taper(Object *taperobj, int cur, int tot)
+float calc_taper(Scene *scene, Object *taperobj, int cur, int tot)
{
Curve *cu;
DispList *dl;
@@ -1140,7 +1140,7 @@ float calc_taper(Object *taperobj, int cur, int tot)
cu= taperobj->data;
dl= cu->disp.first;
if(dl==NULL) {
- makeDispListCurveTypes(taperobj, 0);
+ makeDispListCurveTypes(scene, taperobj, 0);
dl= cu->disp.first;
}
if(dl) {
@@ -1173,15 +1173,15 @@ float calc_taper(Object *taperobj, int cur, int tot)
return 1.0;
}
-void makeDispListMBall(Object *ob)
+void makeDispListMBall(Scene *scene, Object *ob)
{
if(!ob || ob->type!=OB_MBALL) return;
freedisplist(&(ob->disp));
if(ob->type==OB_MBALL) {
- if(ob==find_basis_mball(ob)) {
- metaball_polygonize(ob);
+ if(ob==find_basis_mball(scene, ob)) {
+ metaball_polygonize(scene, ob);
tex_space_mball(ob);
object_deform_mball(ob);
@@ -1217,7 +1217,7 @@ static ModifierData *curve_get_tesselate_point(Object *ob, int forRender, int ed
return preTesselatePoint;
}
-static void curve_calc_modifiers_pre(Object *ob, int forRender, float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r)
+static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r)
{
ModifierData *md = modifiers_getVirtualModifierList(ob);
ModifierData *preTesselatePoint;
@@ -1236,7 +1236,7 @@ static void curve_calc_modifiers_pre(Object *ob, int forRender, float (**origina
if(editmode) required_mode |= eModifierMode_Editmode;
- if(cu->editnurb==NULL && do_ob_key(ob)) {
+ if(cu->editnurb==NULL && do_ob_key(scene, ob)) {
deformedVerts = curve_getVertexCos(ob->data, nurb, &numVerts);
originalVerts = MEM_dupallocN(deformedVerts);
}
@@ -1245,6 +1245,8 @@ static void curve_calc_modifiers_pre(Object *ob, int forRender, float (**origina
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ md->scene= scene;
+
if ((md->mode & required_mode) != required_mode) continue;
if (mti->isDisabled && mti->isDisabled(md)) continue;
if (mti->type!=eModifierTypeType_OnlyDeform) continue;
@@ -1270,7 +1272,7 @@ static void curve_calc_modifiers_pre(Object *ob, int forRender, float (**origina
*numVerts_r = numVerts;
}
-static void curve_calc_modifiers_post(Object *ob, ListBase *dispbase, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3])
+static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3])
{
ModifierData *md = modifiers_getVirtualModifierList(ob);
ModifierData *preTesselatePoint;
@@ -1294,6 +1296,8 @@ static void curve_calc_modifiers_post(Object *ob, ListBase *dispbase, int forRen
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ md->scene= scene;
+
if ((md->mode & required_mode) != required_mode) continue;
if (mti->isDisabled && mti->isDisabled(md)) continue;
if (mti->type!=eModifierTypeType_OnlyDeform && mti->type!=eModifierTypeType_DeformOrConstruct) continue;
@@ -1367,7 +1371,7 @@ static void displist_surf_indices(DispList *dl)
}
-void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
+void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRender)
{
ListBase *nubase;
Nurb *nu;
@@ -1384,7 +1388,7 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
else
nubase= &cu->nurb;
- curve_calc_modifiers_pre(ob, forRender, &originalVerts, &deformedVerts, &numVerts);
+ curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
for (nu=nubase->first; nu; nu=nu->next) {
if(forRender || nu->hide==0) {
@@ -1438,10 +1442,10 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
tex_space_curve(cu);
}
- curve_calc_modifiers_post(ob, dispbase, forRender, originalVerts, deformedVerts);
+ curve_calc_modifiers_post(scene, ob, dispbase, forRender, originalVerts, deformedVerts);
}
-void makeDispListCurveTypes(Object *ob, int forOrco)
+void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
{
Curve *cu = ob->data;
ListBase *dispbase;
@@ -1454,7 +1458,7 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
freedisplist(dispbase);
if(ob->type==OB_SURF) {
- makeDispListSurf(ob, dispbase, 0);
+ makeDispListSurf(scene, ob, dispbase, 0);
}
else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
ListBase dlbev;
@@ -1473,14 +1477,14 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
if(cu->path) free_path(cu->path);
cu->path= NULL;
- if(ob->type==OB_FONT) text_to_curve(ob, 0);
+ if(ob->type==OB_FONT) text_to_curve(scene, ob, 0);
- if(!forOrco) curve_calc_modifiers_pre(ob, 0, &originalVerts, &deformedVerts, &numVerts);
+ if(!forOrco) curve_calc_modifiers_pre(scene, ob, 0, &originalVerts, &deformedVerts, &numVerts);
makeBevelList(ob);
/* If curve has no bevel will return nothing */
- makebevelcurve(ob, &dlbev);
+ makebevelcurve(scene, ob, &dlbev);
/* no bevel or extrude, and no width correction? */
if (!dlbev.first && cu->width==1.0f) {
@@ -1558,7 +1562,7 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
fac = bevp->radius;
} else {
- fac = calc_taper(cu->taperobj, a, bl->nr);
+ fac = calc_taper(scene, cu->taperobj, a, bl->nr);
}
if (bevp->f1) {
@@ -1603,7 +1607,7 @@ void makeDispListCurveTypes(Object *ob, int forOrco)
if(cu->flag & CU_PATH) calc_curvepath(ob);
- if(!forOrco) curve_calc_modifiers_post(ob, &cu->disp, 0, originalVerts, deformedVerts);
+ if(!forOrco) curve_calc_modifiers_post(scene, ob, &cu->disp, 0, originalVerts, deformedVerts);
tex_space_curve(cu);
}
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 66e8a039dda..6c959f2190e 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -140,7 +140,7 @@ void free_effects(ListBase *lb)
/* -------------------------- Effectors ------------------ */
-static void add_to_effectorcache(ListBase *lb, Object *ob, Object *obsrc)
+static void add_to_effectorcache(ListBase *lb, Scene *scene, Object *ob, Object *obsrc)
{
pEffectorCache *ec;
PartDeflect *pd= ob->pd;
@@ -150,7 +150,7 @@ static void add_to_effectorcache(ListBase *lb, Object *ob, Object *obsrc)
Curve *cu= ob->data;
if(cu->flag & CU_PATH) {
if(cu->path==NULL || cu->path->data==NULL)
- makeDispListCurveTypes(ob, 0);
+ makeDispListCurveTypes(scene, ob, 0);
if(cu->path && cu->path->data) {
ec= MEM_callocN(sizeof(pEffectorCache), "effector cache");
ec->ob= ob;
@@ -174,7 +174,7 @@ static void add_to_effectorcache(ListBase *lb, Object *ob, Object *obsrc)
}
/* returns ListBase handle with objects taking part in the effecting */
-ListBase *pdInitEffectors(Object *obsrc, Group *group)
+ListBase *pdInitEffectors(Scene *scene, Object *obsrc, Group *group)
{
static ListBase listb={NULL, NULL};
pEffectorCache *ec;
@@ -186,14 +186,14 @@ ListBase *pdInitEffectors(Object *obsrc, Group *group)
for(go= group->gobject.first; go; go= go->next) {
if( (go->ob->lay & layer) && go->ob->pd && go->ob!=obsrc) {
- add_to_effectorcache(&listb, go->ob, obsrc);
+ add_to_effectorcache(&listb, scene, go->ob, obsrc);
}
}
}
else {
- for(base = G.scene->base.first; base; base= base->next) {
+ for(base = scene->base.first; base; base= base->next) {
if( (base->lay & layer) && base->object->pd && base->object!=obsrc) {
- add_to_effectorcache(&listb, base->object, obsrc);
+ add_to_effectorcache(&listb, scene, base->object, obsrc);
}
}
}
@@ -240,14 +240,14 @@ static void eff_tri_ray_hit(void *userdata, int index, const BVHTreeRay *ray, BV
}
// get visibility of a wind ray
-static float eff_calc_visibility(Object *ob, float *co, float *dir)
+static float eff_calc_visibility(Scene *scene, Object *ob, float *co, float *dir)
{
CollisionModifierData **collobjs = NULL;
int numcollobj = 0, i;
float norm[3], len = 0.0;
float visibility = 1.0;
- collobjs = get_collisionobjects(ob, &numcollobj);
+ collobjs = get_collisionobjects(scene, ob, &numcollobj);
if(!collobjs)
return 0;
@@ -374,7 +374,7 @@ float effector_falloff(PartDeflect *pd, float *eff_velocity, float *vec_to_part)
return falloff;
}
-void do_physical_effector(Object *ob, float *opco, short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor, float charge, float pa_size)
+void do_physical_effector(Scene *scene, Object *ob, float *opco, short type, float force_val, float distance, float falloff, float size, float damp, float *eff_velocity, float *vec_to_part, float *velocity, float *field, int planar, struct RNG *rng, float noise_factor, float charge, float pa_size)
{
float mag_vec[3]={0,0,0};
float temp[3], temp2[3];
@@ -382,7 +382,7 @@ void do_physical_effector(Object *ob, float *opco, short type, float force_val,
float noise = 0, visibility;
// calculate visibility
- visibility = eff_calc_visibility(ob, opco, vec_to_part);
+ visibility = eff_calc_visibility(scene, ob, opco, vec_to_part);
if(visibility <= 0.0)
return;
falloff *= visibility;
@@ -499,6 +499,7 @@ void do_physical_effector(Object *ob, float *opco, short type, float force_val,
/* -------- pdDoEffectors() --------
generic force/speed system, now used for particles and softbodies
+ scene = scene where it runs in, for time and stuff
lb = listbase with objects that take part in effecting
opco = global coord, as input
force = force accumulator
@@ -510,7 +511,7 @@ void do_physical_effector(Object *ob, float *opco, short type, float force_val,
guide = old speed of particle
*/
-void pdDoEffectors(ListBase *lb, float *opco, float *force, float *speed, float cur_time, float loc_time, unsigned int flags)
+void pdDoEffectors(Scene *scene, ListBase *lb, float *opco, float *force, float *speed, float cur_time, float loc_time, unsigned int flags)
{
/*
Modifies the force on a particle according to its
@@ -541,7 +542,7 @@ void pdDoEffectors(ListBase *lb, float *opco, float *force, float *speed, float
pd= ob->pd;
/* Get IPO force strength and fall off values here */
- where_is_object_time(ob,cur_time);
+ where_is_object_time(scene, ob, cur_time);
/* use center of object for distance calculus */
VecSubf(vec_to_part, opco, ob->obmat[3]);
@@ -554,9 +555,9 @@ void pdDoEffectors(ListBase *lb, float *opco, float *force, float *speed, float
else {
float field[3]={0,0,0}, tmp[3];
VECCOPY(field, force);
- do_physical_effector(ob, opco, pd->forcefield,pd->f_strength,distance,
- falloff,pd->f_dist,pd->f_damp,ob->obmat[2],vec_to_part,
- speed,force,pd->flag&PFIELD_PLANAR, pd->rng, pd->f_noise, 0.0f, 0.0f);
+ do_physical_effector(scene, ob, opco, pd->forcefield,pd->f_strength,distance,
+ falloff, pd->f_dist, pd->f_damp, ob->obmat[2], vec_to_part,
+ speed,force, pd->flag&PFIELD_PLANAR, pd->rng, pd->f_noise, 0.0f, 0.0f);
// for softbody backward compatibility
if(flags & PE_WIND_AS_SPEED){
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index 911efda21bd..43056d7f98b 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -115,6 +115,7 @@
#include "BKE_object.h"
#include "BKE_material.h"
#include "BKE_exotic.h"
+
/* #include "BKE_error.h" */
#include "BKE_screen.h"
#include "BKE_displist.h"
@@ -129,7 +130,7 @@
#include "zlib.h"
static int is_dxf(char *str);
-static void dxf_read(char *filename);
+static void dxf_read(Scene *scene, char *filename);
static int is_stl(char *str);
static int is_stl_ascii(char *str)
@@ -233,7 +234,7 @@ static void mesh_add_normals_flags(Mesh *me)
}
}
-static void read_stl_mesh_binary(char *str)
+static void read_stl_mesh_binary(Scene *scene, char *str)
{
FILE *fpSTL;
Object *ob;
@@ -295,7 +296,7 @@ static void read_stl_mesh_binary(char *str)
fseek(fpSTL, 2, SEEK_CUR);
}
- ob= add_object(OB_MESH);
+ ob= add_object(scene, OB_MESH);
me= ob->data;
me->totvert = totvert;
me->totface = totface;
@@ -344,7 +345,7 @@ static void read_stl_mesh_binary(char *str)
STLBAILOUT("Bad vertex!"); \
++totvert; \
}
-static void read_stl_mesh_ascii(char *str)
+static void read_stl_mesh_ascii(Scene *scene, char *str)
{
FILE *fpSTL;
char buffer[2048], *cp;
@@ -436,7 +437,7 @@ static void read_stl_mesh_ascii(char *str)
fclose(fpSTL);
/* OK, lets create our mesh */
- ob = add_object(OB_MESH);
+ ob = add_object(scene, OB_MESH);
me = ob->data;
me->totface = totface;
@@ -481,7 +482,7 @@ static void read_stl_mesh_ascii(char *str)
#undef STLREADLINE
#undef STLREADVERT
-static void read_videoscape_mesh(char *str)
+static void read_videoscape_mesh(Scene *scene, char *str)
{
Object *ob;
Mesh *me;
@@ -555,7 +556,7 @@ static void read_videoscape_mesh(char *str)
}
/* new object */
- ob= add_object(OB_MESH);
+ ob= add_object(scene, OB_MESH);
me= ob->data;
me->totvert= verts;
me->totface= totedge+tottria+totquad;
@@ -688,7 +689,7 @@ static void read_videoscape_mesh(char *str)
//XXX waitcursor(1);
}
-static void read_videoscape_lamp(char *str)
+static void read_videoscape_lamp(Scene *scene, char *str)
{
Object *ob;
Lamp *la;
@@ -707,7 +708,7 @@ static void read_videoscape_lamp(char *str)
fscanf(fp, "%d\n", &tot);
while(tot--) {
- ob= add_object(OB_LAMP);
+ ob= add_object(scene, OB_LAMP);
la= ob->data;
fscanf(fp, "%d\n", &val);
@@ -730,7 +731,7 @@ static void read_videoscape_lamp(char *str)
fclose(fp);
}
-static void read_videoscape_nurbs(char *str)
+static void read_videoscape_nurbs(Scene *scene, char *str)
{
Object *ob;
Curve *cu;
@@ -751,8 +752,8 @@ static void read_videoscape_nurbs(char *str)
fscanf(fp, "%40s", s);
fscanf(fp, "%d\n", &type);
- if(type==5) ob= add_object(OB_SURF);
- else ob= add_object(OB_CURVE);
+ if(type==5) ob= add_object(scene, OB_SURF);
+ else ob= add_object(scene, OB_CURVE);
cu= ob->data;
fscanf(fp, "%d\n", &tot);
@@ -832,7 +833,7 @@ static void read_videoscape_nurbs(char *str)
fclose(fp);
}
-static void read_videoscape(char *str)
+static void read_videoscape(Scene *scene, char *str)
{
int file, type;
unsigned int val;
@@ -848,9 +849,9 @@ static void read_videoscape(char *str)
read(file, &type, 4);
close(file);
- if(type==DDG1) read_videoscape_mesh(name);
- else if(type==DDG2) read_videoscape_lamp(name);
- else if(type==DDG3) read_videoscape_nurbs(name);
+ if(type==DDG1) read_videoscape_mesh(scene, name);
+ else if(type==DDG2) read_videoscape_lamp(scene, name);
+ else if(type==DDG3) read_videoscape_nurbs(scene, name);
}
val = BLI_stringdec(name, head, tail, &numlen);
@@ -1043,7 +1044,7 @@ static void read_iv_index(float *data, float *baseadr, float *index, int nr, int
-static void read_inventor(char *str, struct ListBase *listb)
+static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
{
struct IvNode *iv, *ivp, *ivn;
char *maindata, *md, *cpa;
@@ -1641,7 +1642,7 @@ static void read_inventor(char *str, struct ListBase *listb)
BPoint *bp;
if(ivsurf==0) {
- ob= add_object(OB_SURF);
+ ob= add_object(scene, OB_SURF);
ivsurf= ob;
}
else ob= ivsurf;
@@ -1724,7 +1725,7 @@ static void read_inventor(char *str, struct ListBase *listb)
/* ************************************************************ */
-static void displist_to_mesh(DispList *dlfirst)
+static void displist_to_mesh(Scene *scene, DispList *dlfirst)
{
Object *ob;
Mesh *me;
@@ -1841,9 +1842,9 @@ static void displist_to_mesh(DispList *dlfirst)
vec[1]= (min[1]+max[1])/2;
vec[2]= (min[2]+max[2])/2;
- ob= add_object(OB_MESH);
+ ob= add_object(scene, OB_MESH);
VECCOPY(ob->loc, vec);
- where_is_object(ob);
+ where_is_object(scene, ob);
me= ob->data;
@@ -2063,7 +2064,7 @@ static void displist_to_mesh(DispList *dlfirst)
make_edges(me, 0);
}
-static void displist_to_objects(ListBase *lbase)
+static void displist_to_objects(Scene *scene, ListBase *lbase)
{
DispList *dl, *first, *prev, *next;
ListBase tempbase;
@@ -2071,7 +2072,7 @@ static void displist_to_objects(ListBase *lbase)
/* irst this: is still active */
if(ivsurf) {
- where_is_object(ivsurf);
+ where_is_object(scene, ivsurf);
// XXX docenter_new();
}
@@ -2152,12 +2153,12 @@ static void displist_to_objects(ListBase *lbase)
totvert+= vert;
if(totvert > maxaantal || dl->next==0) {
if(dl->next==0) {
- displist_to_mesh(first);
+ displist_to_mesh(scene, first);
}
else if(dl->prev) {
prev= dl->prev;
prev->next= 0;
- displist_to_mesh(first);
+ displist_to_mesh(scene, first);
prev->next= dl;
first= dl;
totvert= 0;
@@ -2172,13 +2173,13 @@ static void displist_to_objects(ListBase *lbase)
curcol++;
}
}
- else displist_to_mesh(lbase->first);
+ else displist_to_mesh(scene, lbase->first);
freedisplist(lbase);
}
-int BKE_read_exotic(char *name)
+int BKE_read_exotic(Scene *scene, char *name)
{
ListBase lbase={0, 0};
int len;
@@ -2208,33 +2209,33 @@ int BKE_read_exotic(char *name)
if(0) { // XXX obedit) {
//XXX error("Unable to perform function in EditMode");
} else {
- read_videoscape(name);
+ read_videoscape(scene, name);
retval = 1;
}
}
else if(strncmp(str, "#Inventor V1.0", 14)==0) {
if( strncmp(str+15, "ascii", 5)==0) {
- read_inventor(name, &lbase);
- displist_to_objects(&lbase);
+ read_inventor(scene, name, &lbase);
+ displist_to_objects(scene, &lbase);
retval = 1;
} else {
//XXX error("Can only read Inventor 1.0 ascii");
}
}
else if((strncmp(str, "#VRML V1.0 asc", 14)==0)) {
- read_inventor(name, &lbase);
- displist_to_objects(&lbase);
+ read_inventor(scene, name, &lbase);
+ displist_to_objects(scene, &lbase);
retval = 1;
}
else if(is_dxf(name)) {
- dxf_read(name);
+ dxf_read(scene, name);
retval = 1;
}
else if(is_stl(name)) {
if (is_stl_ascii(name))
- read_stl_mesh_ascii(name);
+ read_stl_mesh_ascii(scene, name);
else
- read_stl_mesh_binary(name);
+ read_stl_mesh_binary(scene, name);
retval = 1;
}
#ifndef DISABLE_PYTHON
@@ -2306,10 +2307,10 @@ static int write_derivedmesh_stl(FILE *fpSTL, Object *ob, DerivedMesh *dm)
return numfacets;
}
-static int write_object_stl(FILE *fpSTL, Object *ob, Mesh *me)
+static int write_object_stl(FILE *fpSTL, Scene *scene, Object *ob, Mesh *me)
{
int numfacets = 0;
- DerivedMesh *dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
numfacets += write_derivedmesh_stl(fpSTL, ob, dm);
@@ -2318,7 +2319,7 @@ static int write_object_stl(FILE *fpSTL, Object *ob, Mesh *me)
return numfacets;
}
-void write_stl(char *str)
+void write_stl(Scene *scene, char *str)
{
Object *ob;
Mesh *me;
@@ -2356,14 +2357,14 @@ void write_stl(char *str)
fprintf(fpSTL, "Binary STL output from Blender: %-48.48s ", str);
/* Write all selected mesh objects */
- base= G.scene->base.first;
+ base= scene->base.first;
while(base) {
if (base->flag & SELECT) {
ob = base->object;
if (ob->type == OB_MESH) {
me = ob->data;
if (me)
- numfacets += write_object_stl(fpSTL, ob, me);
+ numfacets += write_object_stl(fpSTL, scene, ob, me);
}
}
base= base->next;
@@ -2384,7 +2385,7 @@ void write_stl(char *str)
//XXX waitcursor(0);
}
-static void write_videoscape_mesh(Object *ob, char *str)
+static void write_videoscape_mesh(Scene *scene, Object *ob, char *str)
{
Mesh *me;
EditMesh *em = me->edit_mesh;
@@ -2463,7 +2464,7 @@ static void write_videoscape_mesh(Object *ob, char *str)
}
}
else {
- DerivedMesh *dm = mesh_get_derived_deform(ob, CD_MASK_BAREMESH);
+ DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
me= ob->data;
@@ -2492,7 +2493,7 @@ static void write_videoscape_mesh(Object *ob, char *str)
}
-void write_videoscape(char *str)
+void write_videoscape(Scene *scene, char *str)
{
Base *base;
int file, val, lampdone=0;
@@ -2511,11 +2512,11 @@ void write_videoscape(char *str)
strcpy(temp_dir, str);
- base= G.scene->base.first;
+ base= scene->base.first;
while(base) {
- if((base->flag & SELECT) && (base->lay & G.scene->lay)) {
+ if((base->flag & SELECT) && (base->lay & scene->lay)) {
if(base->object->type==OB_MESH) {
- write_videoscape_mesh(base->object, str);
+ write_videoscape_mesh(scene, base->object, str);
val = BLI_stringdec(str, head, tail, &numlen);
BLI_stringenc(str, head, tail, numlen, val + 1);
}
@@ -2812,7 +2813,7 @@ static void write_object_vrml(FILE *fp, Object *ob)
}
-void write_vrml(char *str)
+void write_vrml(Scene *scene, char *str)
{
Mesh *me;
Material *ma;
@@ -2851,7 +2852,7 @@ void write_vrml(char *str)
/* only write meshes we're using in this scene */
flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0);
- for(base= G.scene->base.first; base; base= base->next)
+ for(base= scene->base.first; base; base= base->next)
if(base->object->type== OB_MESH)
((ID *)base->object->data)->flag |= LIB_DOIT;
@@ -2865,10 +2866,10 @@ void write_vrml(char *str)
/* THEN:Hidden Objects */
fprintf(fp, "\n\t# Hidden Objects, in invisible layers\n\n");
- base= G.scene->base.first;
+ base= scene->base.first;
while(base) {
if(base->object->type== OB_MESH) {
- if( (base->lay & G.scene->lay)==0 ) {
+ if( (base->lay & scene->lay)==0 ) {
write_object_vrml(fp, base->object);
}
}
@@ -2881,14 +2882,14 @@ void write_vrml(char *str)
/* The camera */
- write_camera_vrml(fp, G.scene->camera);
+ write_camera_vrml(fp, scene->camera);
/* THEN:The Objects */
- base= G.scene->base.first;
+ base= scene->base.first;
while(base) {
if(base->object->type== OB_MESH) {
- if(base->lay & G.scene->lay) {
+ if(base->lay & scene->lay) {
write_object_vrml(fp, base->object);
}
}
@@ -3123,7 +3124,7 @@ static void write_object_dxf(FILE *fp, Object *ob, int layer)
fprintf (fp, "50\n%f\n", (float) ob->rot[2]*180/M_PI); /* Can only write the Z rot */
}
-void write_dxf(char *str)
+void write_dxf(struct Scene *scene, char *str)
{
Mesh *me;
Base *base;
@@ -3164,7 +3165,7 @@ void write_dxf(char *str)
/* only write meshes we're using in this scene */
flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0);
- for(base= G.scene->base.first; base; base= base->next)
+ for(base= scene->base.first; base; base= base->next)
if(base->object->type== OB_MESH)
((ID *)base->object->data)->flag |= LIB_DOIT;
@@ -3185,7 +3186,7 @@ void write_dxf(char *str)
write_group(2, "ENTITIES");
/* Write all the mesh objects */
- base= G.scene->base.first;
+ base= scene->base.first;
while(base) {
if(base->object->type== OB_MESH) {
write_object_dxf(fp, base->object, base->lay);
@@ -3255,12 +3256,12 @@ static int dxf_get_layer_col(char *layer)
return 1;
}
-static int dxf_get_layer_num(char *layer)
+static int dxf_get_layer_num(Scene *scene, char *layer)
{
int ret = 0;
if (all_digits(layer) && atoi(layer)<(1<<20)) ret= atoi(layer);
- if (ret == 0) ret = G.scene->lay;
+ if (ret == 0) ret = scene->lay;
return ret;
}
@@ -3432,22 +3433,22 @@ static float zerovec[3]= {0.0, 0.0, 0.0};
#define reset_vars cent[0]= cent[1]= cent[2]=0.0; strcpy(layname, ""); color[0]= color[1]= color[2]= -1.0
-static void dxf_get_mesh(Mesh** m, Object** o, int noob)
+static void dxf_get_mesh(Scene *scene, Mesh** m, Object** o, int noob)
{
Mesh *me = NULL;
Object *ob;
if (!noob) {
- *o = add_object(OB_MESH);
+ *o = add_object(scene, OB_MESH);
ob = *o;
if (strlen(entname)) new_id(&G.main->object, (ID *)ob, entname);
else if (strlen(layname)) new_id(&G.main->object, (ID *)ob, layname);
- if (strlen(layname)) ob->lay= dxf_get_layer_num(layname);
- else ob->lay= G.scene->lay;
+ if (strlen(layname)) ob->lay= dxf_get_layer_num(scene, layname);
+ else ob->lay= scene->lay;
// not nice i know... but add_object() sets active base, which needs layer setting too (ton)
- G.scene->basact->lay= ob->lay;
+ scene->basact->lay= ob->lay;
*m = ob->data;
me= *m;
@@ -3474,7 +3475,7 @@ static void dxf_get_mesh(Mesh** m, Object** o, int noob)
me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0);
}
-static void dxf_read_point(int noob) {
+static void dxf_read_point(Scene *scene, int noob) {
/* Blender vars */
Object *ob;
Mesh *me;
@@ -3503,7 +3504,7 @@ static void dxf_read_point(int noob) {
read_group(id, val);
}
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
me->totvert= 1;
me->mvert= MEM_callocN(me->totvert*sizeof(MVert), "mverts");
CustomData_set_layer(&me->vdata, CD_MVERT, me->mvert);
@@ -3533,7 +3534,7 @@ static void dxf_close_line(void)
linehold=NULL;
}
-static void dxf_read_line(int noob) {
+static void dxf_read_line(Scene *scene, int noob) {
/* Entity specific vars */
float epoint[3]={0.0, 0.0, 0.0};
short vspace=0; /* Whether or not coords are relative */
@@ -3583,7 +3584,7 @@ static void dxf_read_line(int noob) {
dxf_close_line();
if (linemhold==NULL) {
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
if(ob) VECCOPY(ob->loc, cent);
@@ -3645,7 +3646,7 @@ static void dxf_close_2dpoly(void)
p2dhold=NULL;
}
-static void dxf_read_ellipse(int noob)
+static void dxf_read_ellipse(Scene *scene, int noob)
{
/*
@@ -3791,7 +3792,7 @@ static void dxf_read_ellipse(int noob)
cent[2]= center[2];
#endif
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
strcpy(oldllay, layname);
if(ob) VECCOPY(ob->loc, cent);
dxf_add_mat (ob, me, color, layname);
@@ -3841,7 +3842,7 @@ static void dxf_read_ellipse(int noob)
}
}
-static void dxf_read_arc(int noob)
+static void dxf_read_arc(Scene *scene, int noob)
{
/* Entity specific vars */
float epoint[3]={0.0, 0.0, 0.0};
@@ -3919,7 +3920,7 @@ static void dxf_read_arc(int noob)
cent[1]= center[1]+dia*cos(phi);
cent[2]= center[2];
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
strcpy(oldllay, layname);
if(ob) VECCOPY(ob->loc, cent);
dxf_add_mat (ob, me, color, layname);
@@ -3964,7 +3965,7 @@ static void dxf_read_arc(int noob)
}
}
-static void dxf_read_polyline(int noob) {
+static void dxf_read_polyline(Scene *scene, int noob) {
/* Entity specific vars */
short vspace=0; /* Whether or not coords are relative */
int flag=0;
@@ -4013,7 +4014,7 @@ static void dxf_read_polyline(int noob) {
dxf_close_2dpoly();
if (p2dmhold==NULL) {
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
strcpy(oldplay, layname);
@@ -4089,7 +4090,7 @@ static void dxf_read_polyline(int noob) {
lwasp2d=1;
}
else if (flag&64) {
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
if(ob) VECCOPY(ob->loc, cent);
@@ -4190,7 +4191,7 @@ static void dxf_read_polyline(int noob) {
}
}
-static void dxf_read_lwpolyline(int noob) {
+static void dxf_read_lwpolyline(Scene *scene, int noob) {
/* Entity specific vars */
short vspace=0; /* Whether or not coords are relative */
int flag=0;
@@ -4240,7 +4241,7 @@ static void dxf_read_lwpolyline(int noob) {
if (nverts == 0)
return;
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
strcpy(oldllay, layname);
if(ob) VECCOPY(ob->loc, cent);
dxf_add_mat (ob, me, color, layname);
@@ -4314,7 +4315,7 @@ static void dxf_close_3dface(void)
f3dhold=NULL;
}
-static void dxf_read_3dface(int noob)
+static void dxf_read_3dface(Scene *scene, int noob)
{
/* Entity specific vars */
float vert2[3]={0.0, 0.0, 0.0};
@@ -4410,7 +4411,7 @@ static void dxf_read_3dface(int noob)
}
if (f3dmhold==NULL) {
- dxf_get_mesh(&me, &ob, noob);
+ dxf_get_mesh(scene, &me, &ob, noob);
strcpy(oldflay, layname);
@@ -4477,7 +4478,7 @@ static void dxf_read_3dface(int noob)
hasbumped=1;
}
-static void dxf_read(char *filename)
+static void dxf_read(Scene *scene, char *filename)
{
Mesh *lastMe = G.main->mesh.last;
@@ -4525,7 +4526,7 @@ static void dxf_read(char *filename)
read_group(id, val);
if(group_is(0, "POLYLINE")) {
- dxf_read_polyline(1);
+ dxf_read_polyline(scene, 1);
if(error_exit) return;
lwasf3d=0;
lwasline=0;
@@ -4533,7 +4534,7 @@ static void dxf_read(char *filename)
while(group_isnt(0, "SEQEND")) read_group(id, val);
} else if(group_is(0, "LWPOLYLINE")) {
- dxf_read_lwpolyline(1);
+ dxf_read_lwpolyline(scene, 1);
if(error_exit) return;
lwasf3d=0;
lwasline=0;
@@ -4545,27 +4546,27 @@ static void dxf_read(char *filename)
lwasp2d=0;
lwasline=0;
} else if(group_is(0, "POINT")) {
- dxf_read_point(1);
+ dxf_read_point(scene, 1);
if(error_exit) return;
lwasf3d=0;
lwasp2d=0;
lwasline=0;
} else if(group_is(0, "LINE")) {
- dxf_read_line(1);
+ dxf_read_line(scene, 1);
if(error_exit) return;
lwasline=1;
lwasp2d=0;
lwasf3d=0;
} else if(group_is(0, "3DFACE")) {
- dxf_read_3dface(1);
+ dxf_read_3dface(scene, 1);
if(error_exit) return;
lwasf3d=1;
lwasp2d=0;
lwasline=0;
} else if (group_is(0, "CIRCLE")) {
- dxf_read_arc(1);
+ dxf_read_arc(scene, 1);
} else if (group_is(0, "ELLIPSE")) {
- dxf_read_ellipse(1);
+ dxf_read_ellipse(scene, 1);
} else if (group_is(0, "ENDBLK")) {
break;
}
@@ -4667,12 +4668,12 @@ static void dxf_read(char *filename)
I leave it commented out here as warning (ton) */
//for (i=0; i<ob->totcol; i++) ob->mat[i]= ((Mesh*)ob->data)->mat[i];
- if (strlen(layname)) ob->lay= dxf_get_layer_num(layname);
- else ob->lay= G.scene->lay;
+ if (strlen(layname)) ob->lay= dxf_get_layer_num(scene, layname);
+ else ob->lay= scene->lay;
/* link to scene */
base= MEM_callocN( sizeof(Base), "add_base");
- BLI_addhead(&G.scene->base, base);
+ BLI_addhead(&scene->base, base);
base->lay= ob->lay;
@@ -4685,7 +4686,7 @@ static void dxf_read(char *filename)
lwasp2d=0;
lwasline=0;
} else if(group_is(0, "POLYLINE")) {
- dxf_read_polyline(0);
+ dxf_read_polyline(scene, 0);
if(error_exit) return;
lwasf3d=0;
lwasline=0;
@@ -4693,7 +4694,7 @@ static void dxf_read(char *filename)
while(group_isnt(0, "SEQEND")) read_group(id, val);
} else if(group_is(0, "LWPOLYLINE")) {
- dxf_read_lwpolyline(0);
+ dxf_read_lwpolyline(scene, 0);
if(error_exit) return;
lwasf3d=0;
lwasline=0;
@@ -4705,27 +4706,27 @@ static void dxf_read(char *filename)
lwasp2d=0;
lwasline=0;
} else if(group_is(0, "POINT")) {
- dxf_read_point(0);
+ dxf_read_point(scene, 0);
if(error_exit) return;
lwasf3d=0;
lwasp2d=0;
lwasline=0;
} else if(group_is(0, "LINE")) {
- dxf_read_line(0);
+ dxf_read_line(scene, 0);
if(error_exit) return;
lwasline=1;
lwasp2d=0;
lwasf3d=0;
} else if(group_is(0, "3DFACE")) {
- dxf_read_3dface(0);
+ dxf_read_3dface(scene, 0);
if(error_exit) return;
lwasline=0;
lwasp2d=0;
lwasf3d=1;
} else if (group_is(0, "CIRCLE") || group_is(0, "ARC")) {
- dxf_read_arc(0);
+ dxf_read_arc(scene, 0);
} else if (group_is(0, "ELLIPSE")) {
- dxf_read_ellipse(0);
+ dxf_read_ellipse(scene, 0);
} else if(group_is(0, "ENDSEC")) {
break;
}
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 29c4e0f2fb5..060f9208796 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -167,14 +167,14 @@ void fluidsim_free(FluidsimModifierData *fluidmd)
return;
}
-DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc)
+DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc)
{
#ifndef DISABLE_ELBEEM
DerivedMesh *result = NULL;
int framenr;
FluidsimSettings *fss = NULL;
- framenr= (int)G.scene->r.cfra;
+ framenr= (int)scene->r.cfra;
// only handle fluidsim domains
if(fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
@@ -396,7 +396,7 @@ static DerivedMesh *fluidsim_read_obj(char *filename)
DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int displaymode = 0;
- int curFrame = framenr - 1 /*G.scene->r.sfra*/; /* start with 0 at start frame */
+ int curFrame = framenr - 1 /*scene->r.sfra*/; /* start with 0 at start frame */
char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
FluidsimSettings *fss = fluidmd->fss;
DerivedMesh *dm = NULL;
@@ -598,7 +598,7 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
// file handling
//-------------------------------------------------------------------------------
-void initElbeemMesh(struct Object *ob,
+void initElbeemMesh(struct Scene *scene, struct Object *ob,
int *numVertices, float **vertices,
int *numTriangles, int **triangles,
int useGlobalCoords, int modifierIndex)
@@ -610,7 +610,7 @@ void initElbeemMesh(struct Object *ob,
float *verts;
int *tris;
- dm = mesh_create_derived_index_render(ob, CD_MASK_BAREMESH, modifierIndex);
+ dm = mesh_create_derived_index_render(scene, ob, CD_MASK_BAREMESH, modifierIndex);
//dm = mesh_create_derived_no_deform(ob,NULL);
mvert = dm->getVertArray(dm);
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 529d4cc5268..80670bf1228 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -641,7 +641,7 @@ int getselection(Object *ob, int *start, int *end)
}
}
-struct chartrans *text_to_curve(Object *ob, int mode)
+struct chartrans *text_to_curve(Scene *scene, Object *ob, int mode)
{
VFont *vfont, *oldvfont;
VFontData *vfd= NULL;
@@ -973,7 +973,7 @@ struct chartrans *text_to_curve(Object *ob, int mode)
oldflag= cucu->flag;
cucu->flag |= (CU_PATH+CU_FOLLOW);
- if(cucu->path==NULL) makeDispListCurveTypes(cu->textoncurve, 0);
+ if(cucu->path==NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0);
if(cucu->path) {
float imat[4][4], imat3[3][3];
Mat4Invert(imat, ob->obmat);
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 0d2f86bb151..6fffbd794ef 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -280,7 +280,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
you can draw everything, leaves tags in objects to signal it needs further updating */
/* note: does not work for derivedmesh and render... it recreates all again in convertblender.c */
-void group_handle_recalc_and_update(Object *parent, Group *group)
+void group_handle_recalc_and_update(Scene *scene, Object *parent, Group *group)
{
GroupObject *go;
@@ -289,8 +289,8 @@ void group_handle_recalc_and_update(Object *parent, Group *group)
int cfrao;
/* switch to local time */
- cfrao= G.scene->r.cfra;
- G.scene->r.cfra -= (int)give_timeoffset(parent);
+ cfrao= scene->r.cfra;
+ scene->r.cfra -= (int)give_timeoffset(parent);
/* we need a DAG per group... */
for(go= group->gobject.first; go; go= go->next) {
@@ -298,7 +298,7 @@ void group_handle_recalc_and_update(Object *parent, Group *group)
go->ob->recalc= go->recalc;
group_replaces_nla(parent, go->ob, 's');
- object_handle_update(go->ob);
+ object_handle_update(scene, go->ob);
group_replaces_nla(parent, go->ob, 'e');
/* leave recalc tags in case group members are in normal scene */
@@ -307,14 +307,14 @@ void group_handle_recalc_and_update(Object *parent, Group *group)
}
/* restore */
- G.scene->r.cfra= cfrao;
+ scene->r.cfra= cfrao;
}
else {
/* only do existing tags, as set by regular depsgraph */
for(go= group->gobject.first; go; go= go->next) {
if(go->ob) {
if(go->ob->recalc) {
- object_handle_update(go->ob);
+ object_handle_update(scene, go->ob);
}
}
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 93109b6d0ef..597687101b0 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -21,9 +21,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
- * The Original Code is: all of this file.
- *
- * Contributor(s): Blender Foundation, 2006
+ * Contributor(s): Blender Foundation, 2006, full recode
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -337,7 +335,8 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame)
/* checks if image was already loaded, then returns same image */
/* otherwise creates new. */
/* does not load ibuf itself */
-Image *BKE_add_image_file(const char *name)
+/* pass on optional frame for #name images */
+Image *BKE_add_image_file(const char *name, int frame)
{
Image *ima;
int file, len;
@@ -353,7 +352,7 @@ Image *BKE_add_image_file(const char *name)
BLI_strncpy(str, name, sizeof(str));
BLI_convertstringcode(str, G.sce);
- BLI_convertstringframe(str, G.scene->r.cfra); /* TODO - should this realy be here? */
+ BLI_convertstringframe(str, frame);
/* exists? */
file= open(str, O_BINARY|O_RDONLY);
@@ -365,7 +364,7 @@ Image *BKE_add_image_file(const char *name)
if(ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) {
BLI_strncpy(strtest, ima->name, sizeof(ima->name));
BLI_convertstringcode(strtest, G.sce);
- BLI_convertstringframe(strtest, G.scene->r.cfra); /* TODO - should this be here? */
+ BLI_convertstringframe(strtest, frame);
if( strcmp(strtest, str)==0 ) {
if(ima->anim==NULL || ima->id.us==0) {
@@ -821,11 +820,11 @@ int BKE_imtype_is_movie(int imtype)
return 0;
}
-void BKE_add_image_extension(char *string, int imtype)
+void BKE_add_image_extension(Scene *scene, char *string, int imtype)
{
char *extension="";
- if(G.scene->r.imtype== R_IRIS) {
+ if(scene->r.imtype== R_IRIS) {
if(!BLI_testextensie(string, ".rgb"))
extension= ".rgb";
}
@@ -898,7 +897,7 @@ typedef struct StampData {
char strip[64];
} StampData;
-static void stampdata(StampData *stamp_data, int do_prefix)
+static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
{
char text[256];
@@ -909,7 +908,7 @@ static void stampdata(StampData *stamp_data, int do_prefix)
char sdate[9];
#endif /* WIN32 */
- if (G.scene->r.stamp & R_STAMP_FILENAME) {
+ if (scene->r.stamp & R_STAMP_FILENAME) {
if (G.relbase_valid) {
if (do_prefix) sprintf(stamp_data->file, "File %s", G.sce);
else sprintf(stamp_data->file, "%s", G.sce);
@@ -922,14 +921,14 @@ static void stampdata(StampData *stamp_data, int do_prefix)
stamp_data->file[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_NOTE) {
+ if (scene->r.stamp & R_STAMP_NOTE) {
/* Never do prefix for Note */
- sprintf(stamp_data->note, "%s", G.scene->r.stamp_udata);
+ sprintf(stamp_data->note, "%s", scene->r.stamp_udata);
} else {
stamp_data->note[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_DATE) {
+ if (scene->r.stamp & R_STAMP_DATE) {
#ifdef WIN32
_strdate (sdate);
sprintf (text, "%s", sdate);
@@ -944,8 +943,8 @@ static void stampdata(StampData *stamp_data, int do_prefix)
stamp_data->date[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_MARKER) {
- TimeMarker *marker = NULL; // XXX get_frame_marker(G.scene->r.cfra);
+ if (scene->r.stamp & R_STAMP_MARKER) {
+ TimeMarker *marker = NULL; // XXX get_frame_marker(scene->r.cfra);
if (marker) strcpy(text, marker->name);
else strcpy(text, "<none>");
@@ -956,11 +955,11 @@ static void stampdata(StampData *stamp_data, int do_prefix)
stamp_data->marker[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_TIME) {
+ if (scene->r.stamp & R_STAMP_TIME) {
int h, m, s, f;
h= m= s= f= 0;
- f = (int)(G.scene->r.cfra % G.scene->r.frs_sec);
- s = (int)(G.scene->r.cfra / G.scene->r.frs_sec);
+ f = (int)(scene->r.cfra % scene->r.frs_sec);
+ s = (int)(scene->r.cfra / scene->r.frs_sec);
if (s) {
m = (int)(s / 60);
@@ -972,7 +971,7 @@ static void stampdata(StampData *stamp_data, int do_prefix)
}
}
- if (G.scene->r.frs_sec < 100)
+ if (scene->r.frs_sec < 100)
sprintf (text, "%02d:%02d:%02d.%02d", h, m, s, f);
else
sprintf (text, "%02d:%02d:%02d.%03d", h, m, s, f);
@@ -983,17 +982,17 @@ static void stampdata(StampData *stamp_data, int do_prefix)
stamp_data->time[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_FRAME) {
+ if (scene->r.stamp & R_STAMP_FRAME) {
char format[32];
- if (do_prefix) sprintf(format, "Frame %%0%di\n", 1 + (int) log10(G.scene->r.efra));
- else sprintf(format, "%%0%di\n", 1 + (int) log10(G.scene->r.efra));
- sprintf (stamp_data->frame, format, G.scene->r.cfra);
+ if (do_prefix) sprintf(format, "Frame %%0%di\n", 1 + (int) log10(scene->r.efra));
+ else sprintf(format, "%%0%di\n", 1 + (int) log10(scene->r.efra));
+ sprintf (stamp_data->frame, format, scene->r.cfra);
} else {
stamp_data->frame[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_CAMERA) {
- if (G.scene->camera) strcpy(text, ((Camera *) G.scene->camera)->id.name+2);
+ if (scene->r.stamp & R_STAMP_CAMERA) {
+ if (scene->camera) strcpy(text, ((Camera *) scene->camera)->id.name+2);
else strcpy(text, "<none>");
if (do_prefix) sprintf(stamp_data->camera, "Camera %s", text);
@@ -1002,15 +1001,15 @@ static void stampdata(StampData *stamp_data, int do_prefix)
stamp_data->camera[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_SCENE) {
- if (do_prefix) sprintf(stamp_data->scene, "Scene %s", G.scene->id.name+2);
- else sprintf(stamp_data->scene, "%s", G.scene->id.name+2);
+ if (scene->r.stamp & R_STAMP_SCENE) {
+ if (do_prefix) sprintf(stamp_data->scene, "Scene %s", scene->id.name+2);
+ else sprintf(stamp_data->scene, "%s", scene->id.name+2);
} else {
stamp_data->scene[0] = '\0';
}
- if (G.scene->r.stamp & R_STAMP_SEQSTRIP) {
- Sequence *seq; //XXX = get_forground_frame_seq(G.scene->r.cfra);
+ if (scene->r.stamp & R_STAMP_SEQSTRIP) {
+ Sequence *seq; //XXX = get_forground_frame_seq(scene->r.cfra);
if (seq) strcpy(text, seq->name+2);
else strcpy(text, "<none>");
@@ -1022,7 +1021,7 @@ static void stampdata(StampData *stamp_data, int do_prefix)
}
}
-void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int channels)
+void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels)
{
struct StampData stamp_data;
@@ -1035,9 +1034,9 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
if (!rect && !rectf)
return;
- stampdata(&stamp_data, 1);
+ stampdata(scene, &stamp_data, 1);
- switch (G.scene->r.stamp_font_id) {
+ switch (scene->r.stamp_font_id) {
case 1: /* tiny */
font = BMF_GetFont(BMF_kHelveticaBold8);
break;
@@ -1069,24 +1068,24 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
if (stamp_data.file[0]) {
/* Top left corner */
text_width = BMF_GetStringWidth(font, stamp_data.file);
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
y -= font_height+2; /* Top and bottom 1 pix padding each */
}
/* Top left corner, below File */
if (stamp_data.note[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.note);
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
y -= font_height+2; /* Top and bottom 1 pix padding each */
}
/* Top left corner, below File (or Note) */
if (stamp_data.date[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.date);
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
}
/* Bottom left corner, leaving space for timing */
@@ -1094,8 +1093,8 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
x = 1;
y = font_height+2+1; /* 2 for padding in TIME|FRAME fields below and 1 for padding in this one */
text_width = BMF_GetStringWidth(font, stamp_data.marker);
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
}
/* Left bottom corner */
@@ -1103,8 +1102,8 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
x = 1;
y = 1;
text_width = BMF_GetStringWidth(font, stamp_data.time);
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */
}
@@ -1113,8 +1112,8 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
/* Left bottom corner (after SMPTE if exists) */
if (!stamp_data.time[0]) x = 1;
y = 1;
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
}
if (stamp_data.camera[0]) {
@@ -1122,8 +1121,8 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
/* Center of bottom edge */
x = (width/2) - (BMF_GetStringWidth(font, stamp_data.camera)/2);
y = 1;
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
}
if (stamp_data.scene[0]) {
@@ -1131,8 +1130,8 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
/* Bottom right corner */
x = width - (text_width+1+text_pad);
y = 1;
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
}
if (stamp_data.strip[0]) {
@@ -1140,20 +1139,20 @@ void BKE_stamp_buf(unsigned char *rect, float *rectf, int width, int height, int
/* Top right corner */
x = width - (text_width+1+text_pad);
y = height - font_height - 1;
- buf_rectfill_area(rect, rectf, width, height, G.scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
- BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, G.scene->r.fg_stamp, rect, rectf, width, height, channels);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
+ BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
}
}
-void BKE_stamp_info(struct ImBuf *ibuf)
+void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf)
{
struct StampData stamp_data;
if (!ibuf) return;
/* fill all the data values, no prefix */
- stampdata(&stamp_data, 0);
+ stampdata(scene, &stamp_data, 0);
if (stamp_data.file[0]) IMB_imginfo_change_field (ibuf, "File", stamp_data.file);
if (stamp_data.note[0]) IMB_imginfo_change_field (ibuf, "Note", stamp_data.note);
@@ -1166,7 +1165,7 @@ void BKE_stamp_info(struct ImBuf *ibuf)
if (stamp_data.strip[0]) IMB_imginfo_change_field (ibuf, "Strip", stamp_data.strip);
}
-int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quality)
+int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality)
{
int ok;
@@ -1229,8 +1228,8 @@ int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quali
BLI_make_existing_file(name);
- if(G.scene->r.scemode & R_STAMP_INFO)
- BKE_stamp_info(ibuf);
+ if(scene->r.scemode & R_STAMP_INFO)
+ BKE_stamp_info(scene, ibuf);
ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat);
if (ok == 0) {
@@ -1241,7 +1240,7 @@ int BKE_write_ibuf(ImBuf *ibuf, char *name, int imtype, int subimtype, int quali
}
-void BKE_makepicstring(char *string, char *base, int frame, int imtype)
+void BKE_makepicstring(struct Scene *scene, char *string, char *base, int frame, int imtype)
{
if (string==NULL) return;
@@ -1254,8 +1253,8 @@ void BKE_makepicstring(char *string, char *base, int frame, int imtype)
BLI_convertstringcode(string, G.sce);
BLI_convertstringframe(string, frame);
- if(G.scene->r.scemode & R_EXTENSION)
- BKE_add_image_extension(string, imtype);
+ if(scene->r.scemode & R_EXTENSION)
+ BKE_add_image_extension(scene, string, imtype);
}
@@ -1426,12 +1425,12 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
return rpass;
}
-RenderResult *BKE_image_get_renderresult(Image *ima)
+RenderResult *BKE_image_get_renderresult(struct Scene *scene, Image *ima)
{
if(ima->rr)
return ima->rr;
if(ima->type==IMA_TYPE_R_RESULT)
- return RE_GetResult(RE_GetRender(G.scene->id.name));
+ return RE_GetResult(RE_GetRender(scene->id.name));
return NULL;
}
@@ -1736,7 +1735,10 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser)
like exr, using layers etc */
static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser)
{
- RenderResult *rr= RE_GetResult(RE_GetRender(G.scene->id.name));
+ RenderResult *rr= NULL;
+
+ if(iuser->scene)
+ rr= RE_GetResult(RE_GetRender(iuser->scene->id.name));
if(rr) {
RenderResult rres;
@@ -1750,10 +1752,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser)
pass= (iuser)? iuser->pass: 0;
/* this gives active layer, composite or seqence result */
- RE_GetResultImage(RE_GetRender(G.scene->id.name), &rres);
+ RE_GetResultImage(RE_GetRender(iuser->scene->id.name), &rres);
rect= (unsigned int *)rres.rect32;
rectf= rres.rectf;
- dither= G.scene->r.dither_intensity;
+ dither= iuser->scene->r.dither_intensity;
/* get compo/seq result by default */
if(rr->rectf && layer==0);
@@ -1928,7 +1930,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser)
else if(ima->source==IMA_SRC_FILE) {
if(ima->type==IMA_TYPE_IMAGE)
- ibuf= image_load_image_file(ima, iuser, G.scene->r.cfra); /* cfra only for '#', this global is OK */
+ ibuf= image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */
/* no else; on load the ima type can change */
if(ima->type==IMA_TYPE_MULTILAYER)
/* keeps render result, stores ibufs in listbase, allows saving */
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 93e35a4db06..40c98c1d9cc 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1393,7 +1393,7 @@ float calculateVertexWindForce(float wind[3], float vertexnormal[3])
return (INPR(wind, vertexnormal));
}
-void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M)
+static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M)
{
/* Collect forces and derivatives: F,dFdX,dFdV */
Cloth *cloth = clmd->clothObject;
@@ -1442,7 +1442,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
{
float speed[3] = {0.0f, 0.0f,0.0f};
- pdDoEffectors(effectors, lX[i], winvec[i], speed, (float)G.scene->r.cfra, 0.0f, 0);
+ pdDoEffectors(clmd->scene, effectors, lX[i], winvec[i], speed, frame, 0.0f, 0);
}
for(i = 0; i < cloth->numfaces; i++)
@@ -1570,8 +1570,8 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
while(step < tf)
{
// calculate forces
- effectors= pdInitEffectors(ob,NULL);
- cloth_calc_force(clmd, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step, id->M);
+ effectors= pdInitEffectors(clmd->scene, ob, NULL);
+ cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step, id->M);
if(effectors) pdEndEffectors(effectors);
// calculate new velocity
@@ -1648,8 +1648,8 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
cp_lfvector(id->V, id->Vnew, numverts);
// calculate
- effectors= pdInitEffectors(ob,NULL);
- cloth_calc_force(clmd, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M);
+ effectors= pdInitEffectors(clmd->scene, ob, NULL);
+ cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M);
if(effectors) pdEndEffectors(effectors);
simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI);
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index e5c58860cf5..de374587f4e 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -233,27 +233,27 @@ void free_ipo (Ipo *ipo)
/* ---------------------- Init --------------------------- */
/* on adding new ipos, or for empty views */
-void ipo_default_v2d_cur (int blocktype, rctf *cur)
+void ipo_default_v2d_cur (Scene *scene, int blocktype, rctf *cur)
{
switch (blocktype) {
case ID_CA:
- cur->xmin= (float)G.scene->r.sfra;
- cur->xmax= (float)G.scene->r.efra;
+ cur->xmin= (float)scene->r.sfra;
+ cur->xmax= (float)scene->r.efra;
cur->ymin= 0.0f;
cur->ymax= 100.0f;
break;
case ID_MA: case ID_WO: case ID_LA:
case ID_CU: case ID_CO:
- cur->xmin= (float)(G.scene->r.sfra - 0.1f);
- cur->xmax= (float)G.scene->r.efra;
+ cur->xmin= (float)(scene->r.sfra - 0.1f);
+ cur->xmax= (float)scene->r.efra;
cur->ymin= (float)-0.1f;
cur->ymax= (float)+1.1f;
break;
case ID_TE:
- cur->xmin= (float)(G.scene->r.sfra - 0.1f);
- cur->xmax= (float)G.scene->r.efra;
+ cur->xmin= (float)(scene->r.sfra - 0.1f);
+ cur->xmax= (float)scene->r.efra;
cur->ymin= (float)-0.1f;
cur->ymax= (float)+1.1f;
break;
@@ -266,15 +266,15 @@ void ipo_default_v2d_cur (int blocktype, rctf *cur)
break;
case ID_KE:
- cur->xmin= (float)(G.scene->r.sfra - 0.1f);
- cur->xmax= (float)G.scene->r.efra;
+ cur->xmin= (float)(scene->r.sfra - 0.1f);
+ cur->xmax= (float)scene->r.efra;
cur->ymin= (float)-0.1f;
cur->ymax= (float)+2.1f;
break;
default: /* ID_OB and everything else */
- cur->xmin= (float)G.scene->r.sfra;
- cur->xmax= (float)G.scene->r.efra;
+ cur->xmin= (float)scene->r.sfra;
+ cur->xmax= (float)scene->r.efra;
cur->ymin= -5.0f;
cur->ymax= +5.0f;
break;
@@ -282,13 +282,13 @@ void ipo_default_v2d_cur (int blocktype, rctf *cur)
}
/* create a new IPO block (allocates the block) */
-Ipo *add_ipo (char name[], int blocktype)
+Ipo *add_ipo (Scene *scene, char name[], int blocktype)
{
Ipo *ipo;
ipo= alloc_libblock(&G.main->ipo, ID_IP, name);
ipo->blocktype= blocktype;
- ipo_default_v2d_cur(blocktype, &ipo->cur);
+ if(scene) ipo_default_v2d_cur(scene, blocktype, &ipo->cur);
return ipo;
}
@@ -572,7 +572,7 @@ void make_cfra_list (Ipo *ipo, ListBase *elems)
* rendering. Thus, the use of ugly globals from object.c
*/
// BAD... EVIL... JUJU...!!!!
-float frame_to_float (int cfra) /* see also bsystem_time in object.c */
+float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in object.c */
{
extern float bluroffs; /* bad stuff borrowed from object.c */
extern float fieldoffs;
@@ -580,7 +580,7 @@ float frame_to_float (int cfra) /* see also bsystem_time in object.c */
ctime= (float)cfra;
ctime+= bluroffs+fieldoffs;
- ctime*= G.scene->r.framelen;
+ ctime*= scene->r.framelen;
return ctime;
}
@@ -1513,26 +1513,26 @@ void execute_action_ipo (bActionChannel *achan, bPoseChannel *pchan)
/* Calculate values for given IPO block, then flush to all of block's users
* - for general usage
*/
-void do_ipo (Ipo *ipo)
+void do_ipo (Scene *scene, Ipo *ipo)
{
if (ipo) {
- float ctime= frame_to_float(G.scene->r.cfra);
+ float ctime= frame_to_float(scene, scene->r.cfra);
/* calculate values, then flush to all users of this IPO block */
calc_ipo(ipo, ctime);
- do_ipo_nocalc(ipo);
+ do_ipo_nocalc(scene, ipo);
}
}
/* Calculate values for given Material's IPO block, then flush to given Material only */
-void do_mat_ipo (Material *ma)
+void do_mat_ipo (Scene *scene, Material *ma)
{
float ctime;
if (ELEM(NULL, ma, ma->ipo))
return;
- ctime= frame_to_float(G.scene->r.cfra);
+ ctime= frame_to_float(scene, scene->r.cfra);
/* if(ob->ipoflag & OB_OFFS_OB) ctime-= ob->sf; */
/* calculate values for current time, then flush values to given material only */
@@ -1543,7 +1543,7 @@ void do_mat_ipo (Material *ma)
/* Calculate values for given Object's IPO block, then flush to given Object only
* - there's also some funky stuff that looks like it's for scene layers
*/
-void do_ob_ipo (Object *ob)
+void do_ob_ipo (Scene *scene, Object *ob)
{
float ctime;
unsigned int lay;
@@ -1552,7 +1552,7 @@ void do_ob_ipo (Object *ob)
return;
/* do not set ob->ctime here: for example when parent in invisible layer */
- ctime= bsystem_time(ob, (float) G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(scene, ob, (float) scene->r.cfra, 0.0);
/* calculate values of */
calc_ipo(ob->ipo, ctime);
@@ -1566,8 +1566,8 @@ void do_ob_ipo (Object *ob)
/* hack: for layer animation??? - is this what this is? (Aligorith, 28Sep2008) */
ob->lay |= lay;
if ((ob->id.name[2]=='S') && (ob->id.name[3]=='C') && (ob->id.name[4]=='E')) {
- if (strcmp(G.scene->id.name+2, ob->id.name+6)==0) {
- G.scene->lay= ob->lay;
+ if (strcmp(scene->id.name+2, ob->id.name+6)==0) {
+ scene->lay= ob->lay;
//XXX copy_view3d_lock(0);
/* no redraw here! creates too many calls */
}
@@ -1594,18 +1594,18 @@ void do_ob_ipodrivers (Object *ob, Ipo *ipo, float ctime)
}
/* Special variation to calculate IPO values for Sequence + perform other stuff */
-void do_seq_ipo (Sequence *seq, int cfra)
+void do_seq_ipo (Scene *scene, Sequence *seq, int cfra)
{
float ctime, div;
/* seq_ipo has an exception: calc both fields immediately */
if (seq->ipo) {
if ((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
- ctime = frame_to_float(cfra);
+ ctime = frame_to_float(scene, cfra);
div = 1.0;
}
else {
- ctime= frame_to_float(cfra - seq->startdisp);
+ ctime= frame_to_float(scene, cfra - seq->startdisp);
div= (seq->enddisp - seq->startdisp) / 100.0f;
if (div == 0.0) return;
}
@@ -1629,7 +1629,7 @@ void do_seq_ipo (Sequence *seq, int cfra)
/* exception: it does calc for objects...
* now find out why this routine was used anyway!
*/
-void do_ipo_nocalc (Ipo *ipo)
+void do_ipo_nocalc (struct Scene *scene, Ipo *ipo)
{
Object *ob;
Material *ma;
@@ -1648,7 +1648,7 @@ void do_ipo_nocalc (Ipo *ipo)
switch (ipo->blocktype) {
case ID_OB:
for (ob= G.main->object.first; ob; ob= ob->id.next) {
- if (ob->ipo == ipo) do_ob_ipo(ob);
+ if (ob->ipo == ipo) do_ob_ipo(scene, ob);
}
break;
case ID_MA:
@@ -1688,7 +1688,7 @@ void do_ipo_nocalc (Ipo *ipo)
* with datablocks being calculated in alphabetical order
* - called on scene_update_for_newframe() only
*/
-void do_all_data_ipos ()
+void do_all_data_ipos (Scene *scene)
{
Material *ma;
Tex *tex;
@@ -1703,26 +1703,26 @@ void do_all_data_ipos ()
Base *base;
float ctime;
- ctime= frame_to_float(G.scene->r.cfra);
+ ctime= frame_to_float(scene, scene->r.cfra);
/* this exception cannot be depgraphed yet... what todo with objects in other layers?... */
- for (base= G.scene->base.first; base; base= base->next) {
+ for (base= scene->base.first; base; base= base->next) {
Object *ob= base->object;
/* only update layer when an ipo */
if (has_ipo_code(ob->ipo, OB_LAY)) {
- do_ob_ipo(ob);
+ do_ob_ipo(scene, ob);
base->lay= ob->lay;
}
}
/* layers for the set...*/
- if (G.scene->set) {
- for (base= G.scene->set->base.first; base; base= base->next) {
+ if (scene->set) {
+ for (base= scene->set->base.first; base; base= base->next) {
Object *ob= base->object;
if (has_ipo_code(ob->ipo, OB_LAY)) {
- do_ob_ipo(ob);
+ do_ob_ipo(scene, ob);
base->lay= ob->lay;
}
}
@@ -1771,15 +1771,15 @@ void do_all_data_ipos ()
}
/* Sequencer: process FAC Ipos used as volume envelopes */
- ed= G.scene->ed;
+ ed= scene->ed;
if (ed) {
for (seq= ed->seqbasep->first; seq; seq= seq->next) {
if ( ((seq->type == SEQ_RAM_SOUND) || (seq->type == SEQ_HD_SOUND)) &&
- (seq->startdisp <= G.scene->r.cfra+2) &&
- (seq->enddisp>G.scene->r.cfra) &&
+ (seq->startdisp <= scene->r.cfra+2) &&
+ (seq->enddisp>scene->r.cfra) &&
(seq->ipo) )
{
- do_seq_ipo(seq, G.scene->r.cfra);
+ do_seq_ipo(scene, seq, scene->r.cfra);
}
}
}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 5540a262a1d..baf6e4630ee 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -993,7 +993,7 @@ static float *get_weights_array(Object *ob, char *vgroup)
return NULL;
}
-static int do_mesh_key(Object *ob, Mesh *me)
+static int do_mesh_key(Scene *scene, Object *ob, Mesh *me)
{
KeyBlock *k[4];
float cfra, ctime, t[4], delta, loc[3], size[3];
@@ -1017,11 +1017,11 @@ static int do_mesh_key(Object *ob, Mesh *me)
/* in do_key and cp_key the case a>tot is handled */
}
- cfra= G.scene->r.cfra;
+ cfra= scene->r.cfra;
for(a=0; a<me->totvert; a+=step, cfra+= delta) {
- ctime= bsystem_time(0, cfra, 0.0);
+ ctime= bsystem_time(scene, 0, cfra, 0.0);
if(calc_ipo_spec(me->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
@@ -1056,7 +1056,7 @@ static int do_mesh_key(Object *ob, Mesh *me)
}
}
else {
- ctime= bsystem_time(ob, G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(scene, ob, scene->r.cfra, 0.0);
if(calc_ipo_spec(me->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
@@ -1149,7 +1149,7 @@ static void do_rel_cu_key(Curve *cu, float ctime)
}
}
-static int do_curve_key(Curve *cu)
+static int do_curve_key(Scene *scene, Curve *cu)
{
KeyBlock *k[4];
float cfra, ctime, t[4], delta;
@@ -1172,11 +1172,11 @@ static int do_curve_key(Curve *cu)
/* in do_key and cp_key the case a>tot has been handled */
}
- cfra= G.scene->r.cfra;
+ cfra= scene->r.cfra;
for(a=0; a<tot; a+=step, cfra+= delta) {
- ctime= bsystem_time(0, cfra, 0.0);
+ ctime= bsystem_time(scene, 0, cfra, 0.0);
if(calc_ipo_spec(cu->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
@@ -1198,7 +1198,7 @@ static int do_curve_key(Curve *cu)
}
else {
- ctime= bsystem_time(NULL, (float)G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(scene, NULL, (float)scene->r.cfra, 0.0);
if(cu->key->type==KEY_RELATIVE) {
do_rel_cu_key(cu, ctime);
@@ -1221,7 +1221,7 @@ static int do_curve_key(Curve *cu)
return 1;
}
-static int do_latt_key(Object *ob, Lattice *lt)
+static int do_latt_key(Scene *scene, Object *ob, Lattice *lt)
{
KeyBlock *k[4];
float delta, cfra, ctime, t[4];
@@ -1236,11 +1236,11 @@ static int do_latt_key(Object *ob, Lattice *lt)
delta= lt->key->slurph;
delta/= (float)tot;
- cfra= G.scene->r.cfra;
+ cfra= scene->r.cfra;
for(a=0; a<tot; a++, cfra+= delta) {
- ctime= bsystem_time(0, cfra, 0.0);
+ ctime= bsystem_time(scene, 0, cfra, 0.0);
if(calc_ipo_spec(lt->key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
CLAMP(ctime, 0.0, 1.0);
@@ -1257,7 +1257,7 @@ static int do_latt_key(Object *ob, Lattice *lt)
}
}
else {
- ctime= bsystem_time(NULL, (float)G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(scene, NULL, (float)scene->r.cfra, 0.0);
if(lt->key->type==KEY_RELATIVE) {
KeyBlock *kb;
@@ -1294,7 +1294,7 @@ static int do_latt_key(Object *ob, Lattice *lt)
}
/* returns 1 when key applied */
-int do_ob_key(Object *ob)
+int do_ob_key(Scene *scene, Object *ob)
{
Key *key= ob_get_key(ob);
@@ -1339,16 +1339,16 @@ int do_ob_key(Object *ob)
}
else {
if(ob->ipoflag & OB_ACTION_KEY)
- do_all_object_actions(ob);
+ do_all_object_actions(scene, ob);
else {
- calc_ipo(key->ipo, bsystem_time(ob, G.scene->r.cfra, 0.0));
+ calc_ipo(key->ipo, bsystem_time(scene, ob, scene->r.cfra, 0.0));
execute_ipo((ID *)key, key->ipo);
}
- if(ob->type==OB_MESH) return do_mesh_key(ob, ob->data);
- else if(ob->type==OB_CURVE) return do_curve_key( ob->data);
- else if(ob->type==OB_SURF) return do_curve_key( ob->data);
- else if(ob->type==OB_LATTICE) return do_latt_key(ob, ob->data);
+ if(ob->type==OB_MESH) return do_mesh_key(scene, ob, ob->data);
+ else if(ob->type==OB_CURVE) return do_curve_key(scene, ob->data);
+ else if(ob->type==OB_SURF) return do_curve_key(scene, ob->data);
+ else if(ob->type==OB_LATTICE) return do_latt_key(scene, ob, ob->data);
}
return 0;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index d397279e63e..48e931229b6 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -517,7 +517,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir)
/* co: local coord, result local too */
/* returns quaternion for rotation, using cd->no_rot_axis */
/* axis is using another define!!! */
-static int calc_curve_deform(Object *par, float *co, short axis, CurveDeform *cd, float *quatp)
+static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, CurveDeform *cd, float *quatp)
{
Curve *cu= par->data;
float fac, loc[4], dir[3], cent[3];
@@ -546,7 +546,7 @@ static int calc_curve_deform(Object *par, float *co, short axis, CurveDeform *cd
}
/* to be sure, mostly after file load */
if(cu->path==NULL) {
- makeDispListCurveTypes(par, 0);
+ makeDispListCurveTypes(scene, par, 0);
if(cu->path==NULL) return 0; // happens on append...
}
@@ -607,7 +607,7 @@ static int calc_curve_deform(Object *par, float *co, short axis, CurveDeform *cd
return 0;
}
-void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup, short defaxis)
+void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup, short defaxis)
{
Curve *cu;
int a, flag;
@@ -673,7 +673,7 @@ void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*v
for(j = 0; j < dvert->totweight; j++) {
if(dvert->dw[j].def_nr == index) {
VECCOPY(vec, vertexCos[a]);
- calc_curve_deform(cuOb, vec, defaxis, &cd, NULL);
+ calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
VecLerpf(vertexCos[a], vertexCos[a], vec,
dvert->dw[j].weight);
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
@@ -691,7 +691,7 @@ void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*v
}
for(a = 0; a < numVerts; a++) {
- calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL);
+ calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
}
}
@@ -701,7 +701,7 @@ void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*v
/* input vec and orco = local coord in armature space */
/* orco is original not-animated or deformed reference point */
/* result written in vec and mat */
-void curve_deform_vector(Object *cuOb, Object *target, float *orco, float *vec, float mat[][3], int no_rot_axis)
+void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco, float *vec, float mat[][3], int no_rot_axis)
{
CurveDeform cd;
float quat[4];
@@ -719,7 +719,7 @@ void curve_deform_vector(Object *cuOb, Object *target, float *orco, float *vec,
Mat4MulVecfl(cd.curvespace, vec);
- if(calc_curve_deform(cuOb, vec, target->trackflag+1, &cd, quat)) {
+ if(calc_curve_deform(scene, cuOb, vec, target->trackflag+1, &cd, quat)) {
float qmat[3][3];
QuatToMat3(quat, qmat);
@@ -895,7 +895,7 @@ void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3])
}
}
-void lattice_calc_modifiers(Object *ob)
+void lattice_calc_modifiers(Scene *scene, Object *ob)
{
Lattice *lt= ob->data;
ModifierData *md = modifiers_getVirtualModifierList(ob);
@@ -905,12 +905,14 @@ void lattice_calc_modifiers(Object *ob)
freedisplist(&ob->disp);
if (!editmode) {
- do_ob_key(ob);
+ do_ob_key(scene, ob);
}
for (; md; md=md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ md->scene= scene;
+
if (!(md->mode&eModifierMode_Realtime)) continue;
if (editmode && !(md->mode&eModifierMode_Editmode)) continue;
if (mti->isDisabled && mti->isDisabled(md)) continue;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 4fd36806393..317ec5b4659 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -556,7 +556,7 @@ void free_libblock_us(ListBase *lb, void *idv) /* test users */
else printf("ERROR block %s users %d\n", id->name, id->us);
}
if(id->us==0) {
- if( GS(id->name)==ID_OB ) unlink_object((Object *)id);
+ if( GS(id->name)==ID_OB ) unlink_object(NULL, (Object *)id);
free_libblock(lb, id);
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index ccbc1cc17a1..d34bd02cbcd 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -849,21 +849,15 @@ void automatname(Material *ma)
}
-void delete_material_index()
+void delete_material_index(Object *ob)
{
Material *mao, ***matarar;
- Object *ob, *obt;
+ Object *obt;
Curve *cu;
Nurb *nu;
short *totcolp;
int a, actcol;
- // if(obedit) {
- //XXX error("Unable to perform function in EditMode");
- // return;
- // }
-
- ob= ((G.scene->basact)? (G.scene->basact->object) : 0) ;
if(ob==NULL || ob->totcol==0) return;
/* take a mesh/curve/mball as starting point, remove 1 index,
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 8914ebac4e0..3e881f2d871 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -285,7 +285,7 @@ int is_basis_mball(Object *ob)
* blended. MetaBalls with different basic name can't be
* blended.
*/
-Object *find_basis_mball(Object *basis)
+Object *find_basis_mball(Scene *scene, Object *basis)
{
Base *base;
Object *ob,*bob= basis;
@@ -296,8 +296,8 @@ Object *find_basis_mball(Object *basis)
splitIDname(basis->id.name+2, basisname, &basisnr);
totelem= 0;
- next_object(0, 0, 0);
- while(next_object(1, &base, &ob)) {
+ next_object(scene, 0, 0, 0);
+ while(next_object(scene, 1, &base, &ob)) {
if (ob->type==OB_MBALL) {
if(ob==bob){
@@ -1451,7 +1451,7 @@ void polygonize(PROCESS *mbproc, MetaBall *mb)
}
}
-float init_meta(Object *ob) /* return totsize */
+float init_meta(Scene *scene, Object *ob) /* return totsize */
{
Base *base;
Object *bob;
@@ -1470,8 +1470,8 @@ float init_meta(Object *ob) /* return totsize */
/* make main array */
- next_object(0, 0, 0);
- while(next_object(1, &base, &bob)) {
+ next_object(scene, 0, 0, 0);
+ while(next_object(scene, 1, &base, &bob)) {
if(bob->type==OB_MBALL) {
zero_size= 0;
@@ -2034,7 +2034,7 @@ void init_metaball_octal_tree(int depth)
subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth);
}
-void metaball_polygonize(Object *ob)
+void metaball_polygonize(Scene *scene, Object *ob)
{
PROCESS mbproc;
MetaBall *mb;
@@ -2057,7 +2057,7 @@ void metaball_polygonize(Object *ob)
mainb= MEM_mallocN(sizeof(void *)*totelem, "mainb");
/* initialize all mainb (MetaElems) */
- totsize= init_meta(ob);
+ totsize= init_meta(scene, ob);
if(metaball_tree){
free_metaball_octal_node(metaball_tree->first);
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index f531c2c5337..b41f82bbcf8 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -24,9 +24,7 @@
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
+ * Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -952,7 +950,8 @@ void nurbs_to_mesh(Object *ob)
}
-void mesh_delete_material_index(Mesh *me, int index) {
+void mesh_delete_material_index(Mesh *me, int index)
+{
int i;
for (i=0; i<me->totface; i++) {
@@ -962,7 +961,8 @@ void mesh_delete_material_index(Mesh *me, int index) {
}
}
-void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) {
+void mesh_set_smooth_flag(Object *meshOb, int enableSmooth)
+{
Mesh *me = meshOb->data;
int i;
@@ -976,7 +976,7 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) {
}
}
- DAG_object_flush_update(G.scene, meshOb, OB_RECALC_DATA);
+// XXX do this in caller DAG_object_flush_update(scene, meshOb, OB_RECALC_DATA);
}
void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float **faceNors_r)
@@ -1246,7 +1246,7 @@ void mesh_pmv_revert(Object *ob, Mesh *me)
MEM_freeN(me->pv->vert_map);
me->pv->vert_map= NULL;
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+// XXX do this in caller DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 30f065a40a0..fc016f0f130 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -20,8 +20,6 @@
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
*
-* The Original Code is: all of this file.
-*
* Contributor(s): Daniel Dunbar
* Ton Roosendaal,
* Ben Batt,
@@ -170,7 +168,7 @@ static void curveModifier_foreachObjectLink(
}
static void curveModifier_updateDepgraph(
- ModifierData *md, DagForest *forest,
+ ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
CurveModifierData *cmd = (CurveModifierData*) md;
@@ -189,7 +187,7 @@ static void curveModifier_deformVerts(
{
CurveModifierData *cmd = (CurveModifierData*) md;
- curve_deform_verts(cmd->object, ob, derivedData, vertexCos, numVerts,
+ curve_deform_verts(md->scene, cmd->object, ob, derivedData, vertexCos, numVerts,
cmd->name, cmd->defaxis);
}
@@ -245,7 +243,7 @@ static void latticeModifier_foreachObjectLink(
walk(userData, ob, &lmd->object);
}
-static void latticeModifier_updateDepgraph(ModifierData *md, DagForest *forest,
+static void latticeModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
LatticeModifierData *lmd = (LatticeModifierData*) md;
@@ -421,10 +419,10 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob,
for(i = 0; i < maxFaces; ++i) faceMap[i] = i;
if (ob) {
- frac = bsystem_time(ob, (float)G.scene->r.cfra,
+ frac = bsystem_time(md->scene, ob, md->scene->r.cfra,
bmd->start - 1.0f) / bmd->length;
} else {
- frac = G.scene->r.cfra - bmd->start / bmd->length;
+ frac = md->scene->r.cfra - bmd->start / bmd->length;
}
CLAMP(frac, 0.0, 1.0);
@@ -614,7 +612,7 @@ static void maskModifier_foreachObjectLink(
walk(userData, ob, &mmd->ob_arm);
}
-static void maskModifier_updateDepgraph(ModifierData *md, DagForest *forest,
+static void maskModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
MaskModifierData *mmd = (MaskModifierData *)md;
@@ -1000,7 +998,7 @@ static void arrayModifier_foreachObjectLink(
walk(userData, ob, &amd->offset_ob);
}
-static void arrayModifier_updateDepgraph(ModifierData *md, DagForest *forest,
+static void arrayModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
ArrayModifierData *amd = (ArrayModifierData*) md;
@@ -1089,7 +1087,7 @@ static int calc_mapping(IndexMapEntry *indexMap, int oldIndex, int copyNum)
}
static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
- Object *ob, DerivedMesh *dm,
+ Scene *scene, Object *ob, DerivedMesh *dm,
int initFlags)
{
int i, j;
@@ -1113,9 +1111,9 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
/* need to avoid infinite recursion here */
if(amd->start_cap && amd->start_cap != ob)
- start_cap = mesh_get_derived_final(amd->start_cap, CD_MASK_MESH);
+ start_cap = mesh_get_derived_final(scene, amd->start_cap, CD_MASK_MESH);
if(amd->end_cap && amd->end_cap != ob)
- end_cap = mesh_get_derived_final(amd->end_cap, CD_MASK_MESH);
+ end_cap = mesh_get_derived_final(scene, amd->end_cap, CD_MASK_MESH);
MTC_Mat4One(offset);
@@ -1160,7 +1158,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(!cu->path) {
cu->flag |= CU_PATH; // needed for path & bevlist
- makeDispListCurveTypes(amd->curve_ob, 0);
+ makeDispListCurveTypes(scene, amd->curve_ob, 0);
}
if(cu->path)
length = scale*cu->path->totdist;
@@ -1636,7 +1634,7 @@ static DerivedMesh *arrayModifier_applyModifier(
DerivedMesh *result;
ArrayModifierData *amd = (ArrayModifierData*) md;
- result = arrayModifier_doArray(amd, ob, derivedData, 0);
+ result = arrayModifier_doArray(amd, md->scene, ob, derivedData, 0);
if(result != derivedData)
CDDM_calc_normals(result);
@@ -1683,7 +1681,7 @@ static void mirrorModifier_foreachObjectLink(
walk(userData, ob, &mmd->mirror_ob);
}
-static void mirrorModifier_updateDepgraph(ModifierData *md, DagForest *forest,
+static void mirrorModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
MirrorModifierData *mmd = (MirrorModifierData*) md;
@@ -3462,7 +3460,7 @@ static int displaceModifier_isDisabled(ModifierData *md)
}
static void displaceModifier_updateDepgraph(
- ModifierData *md, DagForest *forest,
+ ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
DisplaceModifierData *dmd = (DisplaceModifierData*) md;
@@ -3783,7 +3781,7 @@ static void uvprojectModifier_foreachIDLink(ModifierData *md, Object *ob,
}
static void uvprojectModifier_updateDepgraph(ModifierData *md,
- DagForest *forest, Object *ob, DagNode *obNode)
+ DagForest *forest, Scene *scene, Object *ob, DagNode *obNode)
{
UVProjectModifierData *umd = (UVProjectModifierData*) md;
int i;
@@ -4465,7 +4463,7 @@ static void castModifier_foreachObjectLink(
}
static void castModifier_updateDepgraph(
- ModifierData *md, DagForest *forest, Object *ob,
+ ModifierData *md, DagForest *forest, Scene *scene, Object *ob,
DagNode *obNode)
{
CastModifierData *cmd = (CastModifierData*) md;
@@ -5054,7 +5052,7 @@ static void waveModifier_foreachIDLink(ModifierData *md, Object *ob,
}
static void waveModifier_updateDepgraph(
- ModifierData *md, DagForest *forest, Object *ob,
+ ModifierData *md, DagForest *forest, Scene *scene, Object *ob,
DagNode *obNode)
{
WaveModifierData *wmd = (WaveModifierData*) md;
@@ -5179,15 +5177,15 @@ static void wavemod_get_texture_coords(WaveModifierData *wmd, Object *ob,
}
}
-static void waveModifier_do(
- WaveModifierData *md, Object *ob, DerivedMesh *dm,
+static void waveModifier_do(WaveModifierData *md,
+ Scene *scene, Object *ob, DerivedMesh *dm,
float (*vertexCos)[3], int numVerts)
{
WaveModifierData *wmd = (WaveModifierData*) md;
MVert *mvert = NULL;
MDeformVert *dvert = NULL;
int defgrp_index;
- float ctime = bsystem_time(ob, (float)G.scene->r.cfra, 0.0);
+ float ctime = bsystem_time(scene, ob, (float)scene->r.cfra, 0.0);
float minfac =
(float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
float lifefac = wmd->height;
@@ -5365,7 +5363,7 @@ static void waveModifier_deformVerts(
CDDM_calc_normals(dm);
}
- waveModifier_do(wmd, ob, dm, vertexCos, numVerts);
+ waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
if(dm != derivedData) dm->release(dm);
}
@@ -5387,7 +5385,7 @@ static void waveModifier_deformVertsEM(
CDDM_calc_normals(dm);
}
- waveModifier_do(wmd, ob, dm, vertexCos, numVerts);
+ waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
if(dm != derivedData) dm->release(dm);
}
@@ -5439,7 +5437,7 @@ static void armatureModifier_foreachObjectLink(
}
static void armatureModifier_updateDepgraph(
- ModifierData *md, DagForest *forest, Object *ob,
+ ModifierData *md, DagForest *forest, Scene *scene, Object *ob,
DagNode *obNode)
{
ArmatureModifierData *amd = (ArmatureModifierData*) md;
@@ -5560,7 +5558,7 @@ static void hookModifier_foreachObjectLink(
walk(userData, ob, &hmd->object);
}
-static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest,
+static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
HookModifierData *hmd = (HookModifierData*) md;
@@ -5707,7 +5705,7 @@ static void softbodyModifier_deformVerts(
ModifierData *md, Object *ob, DerivedMesh *derivedData,
float (*vertexCos)[3], int numVerts)
{
- sbObjectStep(ob, (float)G.scene->r.cfra, vertexCos, numVerts);
+ sbObjectStep(md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts);
}
static int softbodyModifier_dependsOnTime(ModifierData *md)
@@ -5748,7 +5746,7 @@ static DerivedMesh *clothModifier_applyModifier(ModifierData *md, Object *ob,
return derivedData;
}
- result = clothModifier_do(clmd, ob, derivedData, useRenderParams, isFinalCalc);
+ result = clothModifier_do(clmd, md->scene, ob, derivedData, useRenderParams, isFinalCalc);
if(result)
{
@@ -5759,7 +5757,7 @@ static DerivedMesh *clothModifier_applyModifier(ModifierData *md, Object *ob,
}
static void clothModifier_updateDepgraph(
- ModifierData *md, DagForest *forest, Object *ob,
+ ModifierData *md, DagForest *forest, Scene *scene, Object *ob,
DagNode *obNode)
{
ClothModifierData *clmd = (ClothModifierData*) md;
@@ -5768,7 +5766,7 @@ static void clothModifier_updateDepgraph(
if(clmd)
{
- for(base = G.scene->base.first; base; base= base->next)
+ for(base = scene->base.first; base; base= base->next)
{
Object *ob1= base->object;
if(ob1 != ob)
@@ -5916,7 +5914,7 @@ static void collisionModifier_deformVerts(
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
- current_time = bsystem_time ( ob, ( float ) G.scene->r.cfra, 0.0 );
+ current_time = bsystem_time (md->scene, ob, ( float ) md->scene->r.cfra, 0.0 );
if(G.rt > 0)
printf("current_time %f, collmd->time %f\n", current_time, collmd->time);
@@ -6049,7 +6047,7 @@ static void booleanModifier_foreachObjectLink(
}
static void booleanModifier_updateDepgraph(
- ModifierData *md, DagForest *forest, Object *ob,
+ ModifierData *md, DagForest *forest, Scene *scene, Object *ob,
DagNode *obNode)
{
BooleanModifierData *bmd = (BooleanModifierData*) md;
@@ -6215,7 +6213,7 @@ static void particleSystemModifier_deformVerts(
/* copies the data */
tmpobj->data = copy_curve( (Curve *) ob->data );
- makeDispListCurveTypes( tmpobj, 1 );
+ makeDispListCurveTypes(md->scene, tmpobj, 1 );
nurbs_to_mesh( tmpobj );
dm = CDDM_from_mesh((Mesh*)(tmpobj->data), tmpobj);
@@ -6265,7 +6263,7 @@ static void particleSystemModifier_deformVerts(
}
if(psys){
- particle_system_update(ob,psys);
+ particle_system_update(md->scene, ob, psys);
psmd->flag |= eParticleSystemFlag_psys_updated;
psmd->flag &= ~eParticleSystemFlag_DM_changed;
}
@@ -6313,7 +6311,7 @@ static int particleInstanceModifier_dependsOnTime(ModifierData *md)
return 0;
}
static void particleInstanceModifier_updateDepgraph(ModifierData *md, DagForest *forest,
- Object *ob, DagNode *obNode)
+ Scene *scene,Object *ob, DagNode *obNode)
{
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData*) md;
@@ -6381,7 +6379,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
maxvert=totvert*totpart;
maxface=totface*totpart;
- psys->lattice=psys_get_lattice(ob, psys);
+ psys->lattice=psys_get_lattice(md->scene, ob, psys);
if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED)){
float co[3];
@@ -6424,7 +6422,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
state.time=(mv->co[0]-min_co)/(max_co-min_co);
if(trackneg)
state.time=1.0f-state.time;
- psys_get_particle_on_path(pimd->ob,psys,first_particle + i/totvert,&state,1);
+ psys_get_particle_on_path(md->scene, pimd->ob, psys,first_particle + i/totvert, &state,1);
mv->co[0] = 0.0;
@@ -6446,7 +6444,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
}
else{
state.time=-1.0;
- psys_get_particle_state(pimd->ob,psys,i/totvert,&state,1);
+ psys_get_particle_state(md->scene, pimd->ob, psys, i/totvert, &state,1);
}
QuatMulVecf(state.rot,mv->co);
@@ -7117,7 +7115,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive
}
static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
- ParticleSystemModifierData *psmd, Object *ob,
+ ParticleSystemModifierData *psmd, Scene *scene, Object *ob,
DerivedMesh *to_explode)
{
DerivedMesh *explode, *dm=to_explode;
@@ -7141,9 +7139,9 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
timestep= psys_get_timestep(part);
if(part->flag & PART_GLOB_TIME)
- cfra=bsystem_time(0,(float)G.scene->r.cfra,0.0);
+ cfra=bsystem_time(scene, 0,(float)scene->r.cfra,0.0);
else
- cfra=bsystem_time(ob,(float)G.scene->r.cfra,0.0);
+ cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0);
/* hash table for vertice <-> particle relations */
vertpahash= BLI_edgehash_new();
@@ -7181,7 +7179,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
/* getting back to object space */
Mat4Invert(imat,ob->obmat);
- psmd->psys->lattice = psys_get_lattice(ob, psmd->psys);
+ psmd->psys->lattice = psys_get_lattice(scene, ob, psmd->psys);
/* duplicate & displace vertices */
ehi= BLI_edgehashIterator_new(vertpahash);
@@ -7209,7 +7207,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
Mat4MulVecfl(ob->obmat,loc0);
state.time=cfra;
- psys_get_particle_state(ob,psmd->psys,i,&state,1);
+ psys_get_particle_state(scene, ob, psmd->psys, i, &state,1);
vertco=CDDM_get_vert(explode,v)->co;
@@ -7325,7 +7323,7 @@ static DerivedMesh * explodeModifier_applyModifier(
if(emd->flag & eExplodeFlag_EdgeSplit){
int *facepa = emd->facepa;
DerivedMesh *splitdm=explodeModifier_splitEdges(emd,dm);
- DerivedMesh *explode=explodeModifier_explodeMesh(emd,psmd,ob,splitdm);
+ DerivedMesh *explode=explodeModifier_explodeMesh(emd, psmd, scene, ob, splitdm);
MEM_freeN(emd->facepa);
emd->facepa=facepa;
@@ -7333,7 +7331,7 @@ static DerivedMesh * explodeModifier_applyModifier(
return explode;
}
else
- return explodeModifier_explodeMesh(emd,psmd,ob,derivedData);
+ return explodeModifier_explodeMesh(emd, psmd, scene, ob, derivedData);
}
return derivedData;
}
@@ -7379,7 +7377,7 @@ static DerivedMesh * fluidsimModifier_applyModifier(
return derivedData;
}
- result = fluidsimModifier_do(fluidmd, ob, derivedData, useRenderParams, isFinalCalc);
+ result = fluidsimModifier_do(fluidmd, md->scene, ob, derivedData, useRenderParams, isFinalCalc);
if(result)
{
@@ -7390,7 +7388,7 @@ static DerivedMesh * fluidsimModifier_applyModifier(
}
static void fluidsimModifier_updateDepgraph(
- ModifierData *md, DagForest *forest,
+ ModifierData *md, DagForest *forest, Scene *scene,
Object *ob, DagNode *obNode)
{
FluidsimModifierData *fluidmd= (FluidsimModifierData*) md;
@@ -7400,7 +7398,7 @@ static void fluidsimModifier_updateDepgraph(
{
if(fluidmd->fss->type == OB_FLUIDSIM_DOMAIN)
{
- for(base = G.scene->base.first; base; base= base->next)
+ for(base = scene->base.first; base; base= base->next)
{
Object *ob1= base->object;
if(ob1 != ob)
@@ -7482,7 +7480,7 @@ static void meshdeformModifier_foreachObjectLink(
}
static void meshdeformModifier_updateDepgraph(
- ModifierData *md, DagForest *forest, Object *ob,
+ ModifierData *md, DagForest *forest, Scene *scene, Object *ob,
DagNode *obNode)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
@@ -7567,7 +7565,7 @@ static void meshdeformModifier_do(
/* get cage derivedmesh */
if(me->edit_mesh) {
- tmpdm= editmesh_get_derived_cage_and_final(ob, me->edit_mesh, &cagedm, 0);
+ tmpdm= editmesh_get_derived_cage_and_final(md->scene, ob, me->edit_mesh, &cagedm, 0);
if(tmpdm)
tmpdm->release(tmpdm);
}
@@ -7819,7 +7817,7 @@ static void shrinkwrapModifier_deformVerts(ModifierData *md, Object *ob, Derived
}
}
- shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, md->scene, ob, dm, vertexCos, numVerts);
if(dm)
dm->release(dm);
@@ -7844,13 +7842,13 @@ static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, EditM
}
}
- shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts);
+ shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, md->scene, ob, dm, vertexCos, numVerts);
if(dm)
dm->release(dm);
}
-static void shrinkwrapModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode)
+static void shrinkwrapModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode)
{
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md;
@@ -7905,7 +7903,7 @@ static void simpledeformModifier_foreachObjectLink(ModifierData *md, Object *ob,
walk(userData, ob, &smd->origin);
}
-static void simpledeformModifier_updateDepgraph(ModifierData *md, DagForest *forest, Object *ob, DagNode *obNode)
+static void simpledeformModifier_updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode)
{
SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md;
diff --git a/source/blender/blenkernel/intern/multires-firstlevel.c b/source/blender/blenkernel/intern/multires-firstlevel.c
index 0c21cefa9a0..30bb8c9c28d 100644
--- a/source/blender/blenkernel/intern/multires-firstlevel.c
+++ b/source/blender/blenkernel/intern/multires-firstlevel.c
@@ -376,8 +376,10 @@ MTFace *subdivide_mtfaces(MTFace *src, MultiresLevel *lvl)
return NULL;
}
-void multires_delete_layer(Mesh *me, CustomData *cd, const int type, int n)
+void multires_delete_layer(Object *ob, CustomData *cd, const int type, int n)
{
+ Mesh *me= ob->data;
+
if(me && me->mr && cd) {
MultiresLevel *lvl1= me->mr->levels.first;
@@ -386,12 +388,14 @@ void multires_delete_layer(Mesh *me, CustomData *cd, const int type, int n)
CustomData_set_layer_active(cd, type, n);
CustomData_free_layer_active(cd, type, lvl1->totface);
- multires_level_to_mesh((G.scene->basact)->object, me, 0);
+ multires_level_to_mesh(ob, me, 0);
}
}
-void multires_add_layer(Mesh *me, CustomData *cd, const int type, const int n)
+void multires_add_layer(Object *ob, CustomData *cd, const int type, const int n)
{
+ Mesh *me= ob->data;
+
if(me && me->mr && cd) {
multires_update_levels(me, 0);
@@ -402,6 +406,6 @@ void multires_add_layer(Mesh *me, CustomData *cd, const int type, const int n)
CustomData_add_layer(cd, type, CD_DEFAULT, NULL, current_level(me->mr)->totface);
CustomData_set_layer_active(cd, type, n);
- multires_level_to_mesh((G.scene->basact)->object, me, 0);
+ multires_level_to_mesh(ob, me, 0);
}
}
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index a1566b1a0ed..7b9711f48de 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -42,6 +42,7 @@
#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
+#include "BKE_mesh.h"
#include "BKE_multires.h"
//XXX #include "editmesh.h"
@@ -215,7 +216,7 @@ static void multires_get_face(MultiresFace *f, CustomData *fdata, int findex, Ed
tmp.v3= efa->v3->tmp.l;
tmp.v4= 0;
if(efa->v4) tmp.v4= efa->v4->tmp.l;
- //XXX test_index_face(&tmp, fdata, findex, efa->v4?4:3);
+ test_index_face(&tmp, fdata, findex, efa->v4?4:3);
for(j=0; j<4; ++j) f->v[j]= (&tmp.v1)[j];
/* Flags */
@@ -354,7 +355,7 @@ void multires_create(Object *ob, Mesh *me)
lvl= MEM_callocN(sizeof(MultiresLevel), "multires level");
- //XXX if(me->pv) mesh_pmv_off(ob, me);
+ if(me->pv) mesh_pmv_off(ob, me);
me->mr= MEM_callocN(sizeof(Multires), "multires data");
@@ -1034,7 +1035,7 @@ void multires_level_to_mesh(Object *ob, Mesh *me, const int render)
CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, me->totedge);
CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
- //XXX mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me);
/* Vertices/Edges/Faces */
@@ -1089,11 +1090,11 @@ void multires_level_to_mesh(Object *ob, Mesh *me, const int render)
}
- //XXX mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me);
multires_edge_level_update(ob,me);
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
- //XXX mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
+// XXX do this in caller DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
}
void multires_add_level(Object *ob, Mesh *me, const char subdiv_type)
@@ -1104,7 +1105,7 @@ void multires_add_level(Object *ob, Mesh *me, const char subdiv_type)
MVert *oldverts= NULL;
lvl= MEM_callocN(sizeof(MultiresLevel), "multireslevel");
- //XXX if(me->pv) mesh_pmv_off(ob, me);
+ if(me->pv) mesh_pmv_off(ob, me);
check_colors(me);
multires_update_levels(me, 0);
@@ -1270,7 +1271,7 @@ void multires_add_level(Object *ob, Mesh *me, const char subdiv_type)
void multires_set_level(Object *ob, Mesh *me, const int render)
{
- //XXX if(me->pv) mesh_pmv_off(ob, me);
+ if(me->pv) mesh_pmv_off(ob, me);
check_colors(me);
multires_update_levels(me, render);
@@ -1301,6 +1302,6 @@ void multires_edge_level_update(Object *ob, Mesh *me)
}
}
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+// XXX do this in caller DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 0e43ecd61e1..50eb9534a40 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2628,7 +2628,7 @@ static void force_hidden_passes(bNode *node, int passflag)
}
/* based on rules, force sockets hidden always */
-void ntreeCompositForceHidden(bNodeTree *ntree)
+void ntreeCompositForceHidden(bNodeTree *ntree, Scene *curscene)
{
bNode *node;
@@ -2636,7 +2636,7 @@ void ntreeCompositForceHidden(bNodeTree *ntree)
for(node= ntree->nodes.first; node; node= node->next) {
if( node->type==CMP_NODE_R_LAYERS) {
- Scene *sce= node->id?(Scene *)node->id:G.scene; /* G.scene is WEAK! */
+ Scene *sce= node->id?(Scene *)node->id:curscene;
SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1);
if(srl)
force_hidden_passes(node, srl->passflag);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d9101feb204..7f3f21e106a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -129,9 +129,9 @@ void clear_workob(Object *workob)
}
-void copy_baseflags()
+void copy_baseflags(struct Scene *scene)
{
- Base *base= G.scene->base.first;
+ Base *base= scene->base.first;
while(base) {
base->object->flag= base->flag;
@@ -139,9 +139,9 @@ void copy_baseflags()
}
}
-void copy_objectflags()
+void copy_objectflags(struct Scene *scene)
{
- Base *base= G.scene->base.first;
+ Base *base= scene->base.first;
while(base) {
base->flag= base->object->flag;
@@ -149,9 +149,9 @@ void copy_objectflags()
}
}
-void update_base_layer(Object *ob)
+void update_base_layer(struct Scene *scene, Object *ob)
{
- Base *base= G.scene->base.first;
+ Base *base= scene->base.first;
while (base) {
if (base->object == ob) base->lay= ob->lay;
@@ -291,7 +291,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec
ob->recalc |= OB_RECALC;
}
}
-void unlink_object(Object *ob)
+void unlink_object(Scene *scene, Object *ob)
{
Object *obt;
Material *mat;
@@ -493,9 +493,9 @@ void unlink_object(Object *ob)
tex= tex->id.next;
}
- /* mballs */
- if(ob->type==OB_MBALL) {
- obt= find_basis_mball(ob);
+ /* mballs (scene==NULL when called from library.c) */
+ if(scene && ob->type==OB_MBALL) {
+ obt= find_basis_mball(scene, ob);
if(obt) freedisplist(&obt->disp);
}
@@ -987,9 +987,9 @@ Object *add_only_object(int type, char *name)
return ob;
}
-/* general add: to G.scene, with layer from area and default name */
+/* general add: to scene, with layer from area and default name */
/* creates minimum required data, but without vertices etc. */
-Object *add_object(int type)
+Object *add_object(struct Scene *scene, int type)
{
Object *ob;
Base *base;
@@ -1000,23 +1000,23 @@ Object *add_object(int type)
ob->data= add_obdata_from_type(type);
- ob->lay= G.scene->lay;
+ ob->lay= scene->lay;
- base= scene_add_base(G.scene, ob);
- scene_select_base(G.scene, base);
+ base= scene_add_base(scene, ob);
+ scene_select_base(scene, base);
ob->recalc |= OB_RECALC;
return ob;
}
-void base_init_from_view3d(Base *base, View3D *v3d)
+void base_init_from_view3d(Base *base, View3D *v3d, struct Scene *scene)
{
Object *ob= base->object;
if (!v3d) {
/* no 3d view, this wont happen often */
base->lay = 1;
- VECCOPY(ob->loc, G.scene->cursor);
+ VECCOPY(ob->loc, scene->cursor);
/* return now because v3d->viewquat isnt available */
return;
@@ -1025,7 +1025,7 @@ void base_init_from_view3d(Base *base, View3D *v3d)
VECCOPY(ob->loc, v3d->cursor);
} else {
base->lay= ob->lay= v3d->layact;
- VECCOPY(ob->loc, G.scene->cursor);
+ VECCOPY(ob->loc, scene->cursor);
}
if (U.flag & USER_ADD_VIEWALIGNED) {
@@ -1462,7 +1462,7 @@ void disable_speed_curve(int val)
}
/* ob can be NULL */
-float bsystem_time(Object *ob, float cfra, float ofs)
+float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs)
{
/* returns float ( see frame_to_float in ipo.c) */
@@ -1470,7 +1470,7 @@ float bsystem_time(Object *ob, float cfra, float ofs)
cfra+= bluroffs+fieldoffs;
/* global time */
- cfra*= G.scene->r.framelen;
+ cfra*= scene->r.framelen;
if (ob) {
if (no_speed_curve==0 && ob->ipo)
@@ -1558,7 +1558,7 @@ void object_to_mat4(Object *ob, float mat[][4])
int enable_cu_speed= 1;
-static void ob_parcurve(Object *ob, Object *par, float mat[][4])
+static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
{
Curve *cu;
float q[4], vec[4], dir[3], quat[4], x1, ctime;
@@ -1568,7 +1568,7 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
cu= par->data;
if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
- makeDispListCurveTypes(par, 0);
+ makeDispListCurveTypes(scene, par, 0);
if(cu->path==NULL) return;
/* exception, timeoffset is regarded as distance offset */
@@ -1583,7 +1583,7 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
}
/* catch exceptions: curve paths used as a duplicator */
else if(enable_cu_speed) {
- ctime= bsystem_time(ob, (float)G.scene->r.cfra, 0.0);
+ ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0);
if(calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) {
ctime /= cu->pathlen;
@@ -1591,7 +1591,7 @@ static void ob_parcurve(Object *ob, Object *par, float mat[][4])
}
}
else {
- ctime= G.scene->r.cfra - give_timeoffset(ob);
+ ctime= scene->r.cfra - give_timeoffset(ob);
ctime /= cu->pathlen;
CLAMP(ctime, 0.0, 1.0);
@@ -1831,7 +1831,7 @@ int during_scriptlink(void) {
return during_scriptlink_flag;
}
-void where_is_object_time(Object *ob, float ctime)
+void where_is_object_time(Scene *scene, Object *ob, float ctime)
{
float *fp1, *fp2, slowmat[4][4] = MAT4_UNITY;
float stime, fac1, fac2, vec[3];
@@ -1845,7 +1845,7 @@ void where_is_object_time(Object *ob, float ctime)
if(ob==NULL) return;
/* this is needed to be able to grab objects with ipos, otherwise it always freezes them */
- stime= bsystem_time(ob, ctime, 0.0);
+ stime= bsystem_time(scene, ob, ctime, 0.0);
if(stime != ob->ctime) {
ob->ctime= stime;
@@ -1855,7 +1855,7 @@ void where_is_object_time(Object *ob, float ctime)
execute_ipo((ID *)ob, ob->ipo);
}
else
- do_all_object_actions(ob);
+ do_all_object_actions(scene, ob);
/* do constraint ipos ..., note it needs stime (0 = all ipos) */
do_constraint_channels(&ob->constraints, &ob->constraintChannels, stime, 0);
@@ -1882,7 +1882,7 @@ void where_is_object_time(Object *ob, float ctime)
pop= 1;
if(par->proxy_from); // was a copied matrix, no where_is! bad...
- else where_is_object_time(par, ctime);
+ else where_is_object_time(scene, par, ctime);
}
solve_parenting(ob, par, ob->obmat, slowmat, 0);
@@ -1912,7 +1912,7 @@ void where_is_object_time(Object *ob, float ctime)
/* Handle tracking */
if(ob->track) {
- if( ctime != ob->track->ctime) where_is_object_time(ob->track, ctime);
+ if( ctime != ob->track->ctime) where_is_object_time(scene, ob->track, ctime);
solve_tracking (ob, ob->track->obmat);
}
@@ -1921,7 +1921,7 @@ void where_is_object_time(Object *ob, float ctime)
if (ob->constraints.first) {
bConstraintOb *cob;
- cob= constraints_make_evalob(ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
+ cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
/* constraints need ctime, not stime. Some call where_is_object_time and bsystem_time */
solve_constraints (&ob->constraints, cob, ctime);
@@ -1958,7 +1958,7 @@ static void solve_parenting (Object *ob, Object *par, float obmat[][4], float sl
ok= 0;
if(par->type==OB_CURVE) {
if( ((Curve *)par->data)->flag & CU_PATH ) {
- ob_parcurve(ob, par, tmat);
+ ob_parcurve(scene, ob, par, tmat);
ok= 1;
}
}
@@ -2047,13 +2047,13 @@ void solve_tracking (Object *ob, float targetmat[][4])
}
-void where_is_object(Object *ob)
+void where_is_object(struct Scene *scene, Object *ob)
{
- where_is_object_time(ob, (float)G.scene->r.cfra);
+ where_is_object_time(scene, ob, (float)scene->r.cfra);
}
-void where_is_object_simul(Object *ob)
+void where_is_object_simul(Scene *scene, Object *ob)
/* was written for the old game engine (until 2.04) */
/* It seems that this function is only called
for a lamp that is the child of another object */
@@ -2099,8 +2099,8 @@ for a lamp that is the child of another object */
if (ob->constraints.first) {
bConstraintOb *cob;
- cob= constraints_make_evalob(ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
- solve_constraints (&ob->constraints, cob, G.scene->r.cfra);
+ cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
+ solve_constraints (&ob->constraints, cob, scene->r.cfra);
constraints_clear_evalob(cob);
}
@@ -2109,7 +2109,7 @@ for a lamp that is the child of another object */
}
/* for calculation of the inverse parent transform, only used for editor */
-void what_does_parent(Object *ob, Object *workob)
+void what_does_parent(Scene *scene, Object *ob, Object *workob)
{
clear_workob(workob);
@@ -2132,7 +2132,7 @@ void what_does_parent(Object *ob, Object *workob)
strcpy(workob->parsubstr, ob->parsubstr);
- where_is_object(workob);
+ where_is_object(scene, workob);
}
BoundBox *unit_boundbox()
@@ -2251,7 +2251,7 @@ void minmax_object(Object *ob, float *min, float *max)
}
/* TODO - use dupli objects bounding boxes */
-void minmax_object_duplis(Object *ob, float *min, float *max)
+void minmax_object_duplis(Scene *scene, Object *ob, float *min, float *max)
{
if ((ob->transflag & OB_DUPLI)==0) {
return;
@@ -2259,7 +2259,7 @@ void minmax_object_duplis(Object *ob, float *min, float *max)
ListBase *lb;
DupliObject *dob;
- lb= object_duplilist(G.scene, ob);
+ lb= object_duplilist(scene, ob);
for(dob= lb->first; dob; dob= dob->next) {
if(dob->no_draw);
else {
@@ -2279,7 +2279,7 @@ void minmax_object_duplis(Object *ob, float *min, float *max)
/* the main object update call, for object matrix, constraints, keys and displist (modifiers) */
/* requires flags to be set! */
-void object_handle_update(Object *ob)
+void object_handle_update(Scene *scene, Object *ob)
{
if(ob->recalc & OB_RECALC) {
@@ -2299,7 +2299,7 @@ void object_handle_update(Object *ob)
Mat4CpyMat4(ob->obmat, ob->proxy_from->obmat);
}
else
- where_is_object(ob);
+ where_is_object(scene, ob);
#ifndef DISABLE_PYTHON
if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBJECTUPDATE);
#endif
@@ -2311,25 +2311,25 @@ void object_handle_update(Object *ob)
/* includes all keys and modifiers */
if(ob->type==OB_MESH) {
- makeDerivedMesh(ob, NULL, get_viewedit_datamask());
+ makeDerivedMesh(scene, ob, NULL, get_viewedit_datamask());
}
else if(ob->type==OB_MBALL) {
- makeDispListMBall(ob);
+ makeDispListMBall(scene, ob);
}
else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
- makeDispListCurveTypes(ob, 0);
+ makeDispListCurveTypes(scene, ob, 0);
}
else if(ob->type==OB_LATTICE) {
- lattice_calc_modifiers(ob);
+ lattice_calc_modifiers(scene, ob);
}
else if(ob->type==OB_CAMERA) {
Camera *cam = (Camera *)ob->data;
- calc_ipo(cam->ipo, frame_to_float(G.scene->r.cfra));
+ calc_ipo(cam->ipo, frame_to_float(scene, scene->r.cfra));
execute_ipo(&cam->id, cam->ipo);
}
else if(ob->type==OB_LAMP) {
Lamp *la = (Lamp *)ob->data;
- calc_ipo(la->ipo, frame_to_float(G.scene->r.cfra));
+ calc_ipo(la->ipo, frame_to_float(scene, scene->r.cfra));
execute_ipo(&la->id, la->ipo);
}
else if(ob->type==OB_ARMATURE) {
@@ -2342,8 +2342,8 @@ void object_handle_update(Object *ob)
// printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
}
else {
- do_all_pose_actions(ob);
- where_is_pose(ob);
+ do_all_pose_actions(scene, ob);
+ where_is_pose(scene, ob);
}
}
@@ -2354,7 +2354,7 @@ void object_handle_update(Object *ob)
psys= ob->particlesystem.first;
while(psys) {
if(psys_check_enabled(ob, psys)) {
- particle_system_update(ob, psys);
+ particle_system_update(scene, ob, psys);
psys= psys->next;
}
else if(psys->flag & PSYS_DELETE) {
@@ -2371,7 +2371,7 @@ void object_handle_update(Object *ob)
/* this is to make sure we get render level duplis in groups:
* the derivedmesh must be created before init_render_mesh,
* since object_duplilist does dupliparticles before that */
- dm = mesh_create_derived_render(ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
+ dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
dm->release(dm);
for(psys=ob->particlesystem.first; psys; psys=psys->next)
@@ -2388,7 +2388,7 @@ void object_handle_update(Object *ob)
/* set pointer in library proxy target, for copying, but restore it */
ob->proxy->proxy_from= ob;
// printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name);
- object_handle_update(ob->proxy);
+ object_handle_update(scene, ob->proxy);
}
ob->recalc &= ~OB_RECALC;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 32da154321e..ff4d934ab3d 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -240,11 +240,11 @@ void psys_change_act(void *ob_v, void *act_v)
npsys->flag |= PSYS_CURRENT;
}
}
-Object *psys_get_lattice(Object *ob, ParticleSystem *psys)
+Object *psys_get_lattice(Scene *scene, Object *ob, ParticleSystem *psys)
{
Object *lattice=0;
- if(psys_in_edit_mode(psys)==0){
+ if(psys_in_edit_mode(scene, psys)==0){
ModifierData *md = (ModifierData*)psys_get_modifier(ob,psys);
@@ -285,9 +285,9 @@ int psys_ob_has_hair(Object *ob)
return 0;
}
-int psys_in_edit_mode(ParticleSystem *psys)
+int psys_in_edit_mode(Scene *scene, ParticleSystem *psys)
{
- return ((G.f & G_PARTICLEEDIT) && psys==psys_get_current((G.scene->basact)->object) && psys->edit);
+ return ((G.f & G_PARTICLEEDIT) && psys==psys_get_current((scene->basact)->object) && psys->edit);
}
int psys_check_enabled(Object *ob, ParticleSystem *psys)
{
@@ -1642,7 +1642,7 @@ int do_guide(ParticleKey *state, int pa_num, float time, ListBase *lb)
/* curve taper */
if(cu->taperobj)
- VecMulf(pa_loc,calc_taper(cu->taperobj,(int)(f_force*guidetime*100.0),100));
+ VecMulf(pa_loc, calc_taper(scene, cu->taperobj, (int)(f_force*guidetime*100.0), 100));
/* TODO */
//else{
///* curve size*/
@@ -1851,20 +1851,20 @@ static void get_strand_normal(Material *ma, float *surfnor, float surfdist, floa
VECCOPY(nor, vnor);
}
-int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate)
+int psys_threads_init_path(ParticleThread *threads, Scene *scene, float cfra, int editupdate)
{
ParticleThreadContext *ctx= threads[0].ctx;
Object *ob= ctx->ob;
ParticleSystem *psys= ctx->psys;
ParticleSettings *part = psys->part;
- ParticleEditSettings *pset = &G.scene->toolsettings->particle;
+ ParticleEditSettings *pset = &scene->toolsettings->particle;
int totparent=0, between=0;
int steps = (int)pow(2.0,(double)part->draw_step);
int totchild = psys->totchild;
int i, seed, totthread= threads[0].tot;
/*---start figuring out what is actually wanted---*/
- if(psys_in_edit_mode(psys))
+ if(psys_in_edit_mode(scene, psys))
if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_SHOW_CHILD)==0)
totchild=0;
@@ -1904,7 +1904,7 @@ int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate)
ctx->totparent= totparent;
ctx->cfra= cfra;
- psys->lattice = psys_get_lattice(ob, psys);
+ psys->lattice = psys_get_lattice(scene, ob, psys);
/* cache all relevant vertex groups if they exist */
if(part->from!=PART_FROM_PARTICLE){
@@ -2256,7 +2256,7 @@ static void *exec_child_path_cache(void *data)
return 0;
}
-void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int editupdate)
+void psys_cache_child_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra, int editupdate)
{
ParticleSettings *part = psys->part;
ParticleThread *pthreads;
@@ -2265,9 +2265,9 @@ void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int ed
ListBase threads;
int i, totchild, totparent, totthread;
- pthreads= psys_threads_create(ob, psys);
+ pthreads= psys_threads_create(scene, ob, psys);
- if(!psys_threads_init_path(pthreads, cfra, editupdate)) {
+ if(!psys_threads_init_path(pthreads, scene, cfra, editupdate)) {
psys_threads_free(pthreads);
return;
}
@@ -2306,11 +2306,11 @@ void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int ed
/* -Usefull for making use of opengl vertex arrays for super fast strand drawing. */
/* -Makes child strands possible and creates them too into the cache. */
/* -Cached path data is also used to determine cut position for the editmode tool. */
-void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupdate)
+void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra, int editupdate)
{
ParticleCacheKey *ca, **cache=psys->pathcache;
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
- ParticleEditSettings *pset = &G.scene->toolsettings->particle;
+ ParticleEditSettings *pset = &scene->toolsettings->particle;
ParticleSettings *part = psys->part;
ParticleData *pa;
@@ -2326,7 +2326,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
Material *ma;
float birthtime = 0.0, dietime = 0.0;
- float t, time = 0.0, keytime = 0.0, dfra = 1.0, frs_sec = G.scene->r.frs_sec;
+ float t, time = 0.0, keytime = 0.0, dfra = 1.0, frs_sec = scene->r.frs_sec;
float col[3] = {0.5f, 0.5f, 0.5f};
float prev_tangent[3], hairmat[4][4];
int k,i;
@@ -2346,7 +2346,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
if(psys->renderdata)
steps = (int)pow(2.0, (double)psys->part->ren_step);
- else if(psys_in_edit_mode(psys)){
+ else if(psys_in_edit_mode(scene, psys)){
edit=psys->edit;
//timed = edit->draw_timed;
@@ -2382,7 +2382,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
soft= NULL;
}
- psys->lattice = psys_get_lattice(ob, psys);
+ psys->lattice = psys_get_lattice(scene, ob, psys);
ma= give_current_material(ob, psys->part->omat);
if(ma && (psys->part->draw & PART_DRAW_MAT_COL))
VECCOPY(col, &ma->r)
@@ -3009,7 +3009,7 @@ void make_local_particlesettings(ParticleSettings *part)
}
/* should be integrated to depgraph signals */
-void psys_flush_settings(ParticleSettings *part, int event, int hair_recalc)
+void psys_flush_settings(struct Scene *scene, ParticleSettings *part, int event, int hair_recalc)
{
Base *base;
Object *ob, *tob;
@@ -3017,7 +3017,7 @@ void psys_flush_settings(ParticleSettings *part, int event, int hair_recalc)
int flush;
/* update all that have same particle settings */
- for(base = G.scene->base.first; base; base= base->next) {
+ for(base = scene->base.first; base; base= base->next) {
if(base->object->particlesystem.first) {
ob=base->object;
flush=0;
@@ -3042,12 +3042,12 @@ void psys_flush_settings(ParticleSettings *part, int event, int hair_recalc)
}
}
if(flush)
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
}
}
-LinkNode *psys_using_settings(ParticleSettings *part, int flush_update)
+LinkNode *psys_using_settings(struct Scene *scene, ParticleSettings *part, int flush_update)
{
Object *ob, *tob;
ParticleSystem *psys, *tpsys;
@@ -3075,7 +3075,7 @@ LinkNode *psys_using_settings(ParticleSettings *part, int flush_update)
}
if(flush_update && found)
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
return node;
@@ -3323,7 +3323,7 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float cfra,
return size;
}
/* get's hair (or keyed) particles state at the "path time" specified in state->time */
-void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, ParticleKey *state, int vel)
+void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, int p, ParticleKey *state, int vel)
{
ParticleSettings *part = psys->part;
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
@@ -3335,7 +3335,7 @@ void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, Particle
HairKey *hkey[2] = {NULL, NULL};
ParticleKey *par=0, keys[4];
- float t, real_t, dfra, keytime, frs_sec = G.scene->r.frs_sec;
+ float t, real_t, dfra, keytime, frs_sec = scene->r.frs_sec;
float co[3], orco[3];
float hairmat[4][4];
float pa_clump = 0.0, pa_kink = 0.0;
@@ -3346,7 +3346,7 @@ void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, Particle
float *cpa_fuv; int cpa_num; short cpa_from;
- //if(psys_in_edit_mode(psys)){
+ //if(psys_in_edit_mode(scene, psys)){
// if((psys->edit_path->flag & PSYS_EP_SHOW_CHILD)==0)
// totchild=0;
// edit=1;
@@ -3430,7 +3430,7 @@ void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, Particle
}
//}
- //psys_get_particle_on_path(bsys,p,t,bkey,ckey[0]);
+ //psys_get_particle_on_path(scene, bsys,p,t,bkey,ckey[0]);
//if(part->rotfrom==PART_ROT_KEYS)
// QuatInterpol(state->rot,k2.rot,k3.rot,keytime);
@@ -3494,7 +3494,7 @@ void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, Particle
/* get parent states */
while(w<4 && cpa->pa[w]>=0){
keys[w].time = t;
- psys_get_particle_on_path(ob, psys, cpa->pa[w], keys+w, 1);
+ psys_get_particle_on_path(scene, ob, psys, cpa->pa[w], keys+w, 1);
w++;
}
@@ -3520,7 +3520,7 @@ void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, Particle
/* get the parent state */
keys->time = t;
- psys_get_particle_on_path(ob,psys,cpa->parent,keys,1);
+ psys_get_particle_on_path(scene, ob, psys, cpa->parent, keys,1);
/* get the original coordinates (orco) for texture usage */
pa=psys->particles+cpa->parent;
@@ -3606,19 +3606,19 @@ void psys_get_particle_on_path(Object *ob, ParticleSystem *psys, int p, Particle
//if(vel){
// if(t>=0.001f){
// tstate.time=t-0.001f;
- // psys_get_particle_on_path(ob,psys,p,&tstate,0);
+ // psys_get_particle_on_path(scene,ob,psys,p,&tstate,0);
// VECSUB(state->vel,state->co,tstate.co);
// }
// else{
// tstate.time=t+0.001f;
- // psys_get_particle_on_path(ob,psys,p,&tstate,0);
+ // psys_get_particle_on_path(scene, ob,psys,p,&tstate,0);
// VECSUB(state->vel,tstate.co,state->co);
// }
//}
}
}
/* gets particle's state at a time, returns 1 if particle exists and can be seen and 0 if not */
-int psys_get_particle_state(Object *ob, ParticleSystem *psys, int p, ParticleKey *state, int always){
+int psys_get_particle_state(struct Scene *scene, Object *ob, ParticleSystem *psys, int p, ParticleKey *state, int always){
ParticleSettings *part=psys->part;
ParticleData *pa=0;
float cfra;
@@ -3628,7 +3628,7 @@ int psys_get_particle_state(Object *ob, ParticleSystem *psys, int p, ParticleKey
if(state->time>0)
cfra=state->time;
else
- cfra=bsystem_time(0,(float)G.scene->r.cfra,0.0);
+ cfra= bsystem_time(scene, 0, (float)scene->r.cfra,0.0);
if(psys->totchild && p>=totpart){
if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){
@@ -3664,7 +3664,7 @@ int psys_get_particle_state(Object *ob, ParticleSystem *psys, int p, ParticleKey
else
state->time= (cfra-pa->time)/(pa->dietime-pa->time);
- psys_get_particle_on_path(ob,psys,p,state,1);
+ psys_get_particle_on_path(scene, ob, psys, p, state,1);
return 1;
}
else{
@@ -3708,7 +3708,7 @@ int psys_get_particle_state(Object *ob, ParticleSystem *psys, int p, ParticleKey
/* let's interpolate to try to be as accurate as possible */
if(pa->state.time + 1.0f > state->time && pa->prev_state.time - 1.0f < state->time) {
ParticleKey keys[4];
- float dfra, keytime, frs_sec = G.scene->r.frs_sec;
+ float dfra, keytime, frs_sec = scene->r.frs_sec;
if(pa->prev_state.time >= pa->state.time) {
/* prev_state is wrong so let's not use it, this can happen at frame 1 or particle birth */
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 3ad17790f45..336b7037600 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -216,7 +216,7 @@ static void realloc_particles(Object *ob, ParticleSystem *psys, int new_totpart)
psys->totpart=totpart;
}
-static int get_psys_child_number(ParticleSystem *psys)
+static int get_psys_child_number(struct Scene *scene, ParticleSystem *psys)
{
int nbr;
@@ -225,15 +225,15 @@ static int get_psys_child_number(ParticleSystem *psys)
if(psys->renderdata) {
nbr= psys->part->ren_child_nbr;
- return get_render_child_particle_number(&G.scene->r, nbr);
+ return get_render_child_particle_number(&scene->r, nbr);
}
else
return psys->part->child_nbr;
}
-static int get_psys_tot_child(ParticleSystem *psys)
+static int get_psys_tot_child(struct Scene *scene, ParticleSystem *psys)
{
- return psys->totpart*get_psys_child_number(psys);
+ return psys->totpart*get_psys_child_number(scene, psys);
}
static void alloc_child_particles(ParticleSystem *psys, int tot)
@@ -929,7 +929,7 @@ static int compare_orig_index(const void *p1, const void *p2)
/* 6. and we're done! */
/* This is to denote functionality that does not yet work with mesh - only derived mesh */
-int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm, int from)
+int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, DerivedMesh *finaldm, int from)
{
ParticleThreadContext *ctx= threads[0].ctx;
Object *ob= ctx->ob;
@@ -982,7 +982,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
BLI_kdtree_balance(tree);
- totpart=get_psys_tot_child(psys);
+ totpart=get_psys_tot_child(scene, psys);
cfrom=from=PART_FROM_FACE;
if(part->flag&PART_CHILD_SEAMS){
@@ -1031,9 +1031,9 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
}
else{
/* no need to figure out distribution */
- int child_nbr= get_psys_child_number(psys);
+ int child_nbr= get_psys_child_number(scene, psys);
- totpart= get_psys_tot_child(psys);
+ totpart= get_psys_tot_child(scene, psys);
alloc_child_particles(psys, totpart);
cpa=psys->child;
for(i=0; i<child_nbr; i++){
@@ -1365,16 +1365,16 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
return 1;
}
-static void distribute_particles_on_dm(DerivedMesh *finaldm, Object *ob, ParticleSystem *psys, int from)
+static void distribute_particles_on_dm(DerivedMesh *finaldm, Scene *scene, Object *ob, ParticleSystem *psys, int from)
{
ListBase threads;
ParticleThread *pthreads;
ParticleThreadContext *ctx;
int i, totthread;
- pthreads= psys_threads_create(ob, psys);
+ pthreads= psys_threads_create(scene, ob, psys);
- if(!psys_threads_init_distribution(pthreads, finaldm, from)) {
+ if(!psys_threads_init_distribution(pthreads, scene, finaldm, from)) {
psys_threads_free(pthreads);
return;
}
@@ -1414,7 +1414,7 @@ static void distribute_particles_on_shape(Object *ob, ParticleSystem *psys, int
pa->num= -1;
}
}
-static void distribute_particles(Object *ob, ParticleSystem *psys, int from)
+static void distribute_particles(Scene *scene, Object *ob, ParticleSystem *psys, int from)
{
ParticleSystemModifierData *psmd=0;
int distr_error=0;
@@ -1422,7 +1422,7 @@ static void distribute_particles(Object *ob, ParticleSystem *psys, int from)
if(psmd){
if(psmd->dm)
- distribute_particles_on_dm(psmd->dm,ob,psys,from);
+ distribute_particles_on_dm(psmd->dm, scene, ob, psys, from);
else
distr_error=1;
}
@@ -1444,14 +1444,14 @@ static void distribute_particles(Object *ob, ParticleSystem *psys, int from)
}
/* threaded child particle distribution and path caching */
-ParticleThread *psys_threads_create(struct Object *ob, struct ParticleSystem *psys)
+ParticleThread *psys_threads_create(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
{
ParticleThread *threads;
ParticleThreadContext *ctx;
int i, totthread;
- if(G.scene->r.mode & R_FIXED_THREADS)
- totthread= G.scene->r.threads;
+ if(scene->r.mode & R_FIXED_THREADS)
+ totthread= scene->r.threads;
else
totthread= BLI_system_thread_count();
@@ -1714,7 +1714,7 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi
if(pa->num == -1)
memset(&state, 0, sizeof(state));
else
- psys_get_particle_state(tob,tpsys,pa->num,&state,1);
+ psys_get_particle_state(scene, tob,tpsys,pa->num,&state,1);
psys_get_from_key(&state,loc,nor,rot,0);
QuatMulVecf(rot,vtan);
@@ -1733,7 +1733,7 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi
else{
/* get precise emitter matrix if particle is born */
if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= psys->cfra)
- where_is_object_time(ob,pa->time);
+ where_is_object_time(scene, ob,pa->time);
/* get birth location from object */
psys_particle_on_emitter(psmd,part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
@@ -2027,7 +2027,7 @@ static void set_keyed_keys(Object *ob, ParticleSystem *psys)
for(k=0; k<totkeys; k++) {
for(i=0,pa=psys->particles; i<totpart; i++, pa++) {
if(kpsys->totpart > 0)
- psys_get_particle_state(kob, kpsys, i%kpsys->totpart, pa->keys + k, 1);
+ psys_get_particle_state(scene, kob, kpsys, i%kpsys->totpart, pa->keys + k, 1);
if(k==0)
pa->keys->time = pa->time;
@@ -2303,7 +2303,7 @@ static void add_to_effectors(ListBase *lb, Object *ob, Object *obsrc, ParticleSy
Curve *cu= ob->data;
if(cu->flag & CU_PATH) {
if(cu->path==NULL || cu->path->data==NULL)
- makeDispListCurveTypes(ob, 0);
+ makeDispListCurveTypes(scene, ob, 0);
if(cu->path && cu->path->data) {
type |= PSYS_EC_EFFECTOR;
}
@@ -2394,7 +2394,7 @@ static void psys_init_effectors_recurs(Object *ob, Object *obsrc, ParticleSystem
}
}
-void psys_init_effectors(Object *obsrc, Group *group, ParticleSystem *psys)
+void psys_init_effectors(Scene *scene, Object *obsrc, Group *group, ParticleSystem *psys)
{
ListBase *listb= &psys->effectors;
Base *base;
@@ -2408,7 +2408,7 @@ void psys_init_effectors(Object *obsrc, Group *group, ParticleSystem *psys)
psys_init_effectors_recurs(go->ob, obsrc, psys, listb, 0);
}
else {
- for(base = G.scene->base.first; base; base= base->next)
+ for(base = scene->base.first; base; base= base->next)
psys_init_effectors_recurs(base->object, obsrc, psys, listb, 0);
}
}
@@ -2505,7 +2505,7 @@ static void precalc_effectors(Object *ob, ParticleSystem *psys, ParticleSystemMo
ec->tree=tree;
for(p=0, epa=epsys->particles; p<totepart; p++,epa++)
- if(epa->alive==PARS_ALIVE && psys_get_particle_state(eob,epsys,p,&state,0))
+ if(epa->alive==PARS_ALIVE && psys_get_particle_state(scene, eob,epsys,p,&state,0))
BLI_kdtree_insert(tree, p, state.co, NULL);
BLI_kdtree_balance(tree);
@@ -2556,7 +2556,7 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P
if(ec->type & PSYS_EC_EFFECTOR){
pd=eob->pd;
if(psys->part->type!=PART_HAIR && psys->part->integrator)
- where_is_object_time(eob,cfra);
+ where_is_object_time(scene, eob,cfra);
/* use center of object for distance calculus */
VecSubf(vec_to_part, state->co, eob->obmat[3]);
@@ -2571,7 +2571,7 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P
pd->flag & PFIELD_TEX_OBJECT, (pd->flag & PFIELD_TEX_ROOTCO) ? rootco : state->co, eob->obmat,
pd->f_strength, falloff, force_field);
} else {
- do_physical_effector(eob, state->co, pd->forcefield,pd->f_strength,distance,
+ do_physical_effector(scene, eob, state->co, pd->forcefield,pd->f_strength,distance,
falloff,0.0,pd->f_damp,eob->obmat[2],vec_to_part,
state->vel,force_field,pd->flag&PFIELD_PLANAR,ec->rng,pd->f_noise,charge,pa->size);
}
@@ -2595,7 +2595,7 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P
p=0;
}
- epsys->lattice=psys_get_lattice(ob,psys);
+ epsys->lattice= psys_get_lattice(scene, ob, psys);
for(; p<totepart; p++){
/* particle skips itself as effector */
@@ -2603,7 +2603,7 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P
epa = epsys->particles + p;
estate.time=cfra;
- if(psys_get_particle_state(eob,epsys,p,&estate,0)){
+ if(psys_get_particle_state(scene, eob,epsys,p,&estate,0)){
VECSUB(vec_to_part, state->co, estate.co);
distance = VecLength(vec_to_part);
@@ -2615,14 +2615,14 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P
if(falloff<=0.0f)
; /* don't do anything */
else
- do_physical_effector(eob, state->co, pd->forcefield,pd->f_strength,distance,
+ do_physical_effector(scene, eob, state->co, pd->forcefield,pd->f_strength,distance,
falloff,epart->size,pd->f_damp,estate.vel,vec_to_part,
state->vel,force_field,0, ec->rng, pd->f_noise,charge,pa->size);
}
}
else if(pd && pd->forcefield==PFIELD_HARMONIC && cfra-framestep <= epa->dietime && cfra>epa->dietime){
/* first step after key release */
- psys_get_particle_state(eob,epsys,p,&estate,1);
+ psys_get_particle_state(scene, eob,epsys,p,&estate,1);
VECADD(vel,vel,estate.vel);
/* TODO: add rotation handling here too */
}
@@ -2842,7 +2842,7 @@ static void intersect_dm_quad_weights(float *v1, float *v2, float *v3, float *v4
}
/* check intersection with a derivedmesh */
-int psys_intersect_dm(Object *ob, DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_w,
+int psys_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float *vert_cos, float *co1, float* co2, float *min_d, int *min_face, float *min_w,
float *face_minmax, float *pa_minmax, float radius, float *ipoint)
{
MFace *mface=0;
@@ -2854,9 +2854,9 @@ int psys_intersect_dm(Object *ob, DerivedMesh *dm, float *vert_cos, float *co1,
if(dm==0){
psys_disable_all(ob);
- dm=mesh_get_derived_final(ob,0);
+ dm=mesh_get_derived_final(scene, ob, 0);
if(dm==0)
- dm=mesh_get_derived_deform(ob,0);
+ dm=mesh_get_derived_deform(scene, ob, 0);
psys_enable_all(ob);
@@ -3087,7 +3087,7 @@ static void deflect_particle(Object *pob, ParticleSystemModifierData *psmd, Part
ob= ec->ob;
if(part->type!=PART_HAIR)
- where_is_object_time(ob,cfra);
+ where_is_object_time(scene, ob,cfra);
/* particles should not collide with emitter at birth */
if(ob==pob && pa->time < cfra && pa->time >= psys->cfra)
@@ -3280,7 +3280,7 @@ static int boid_see_mesh(ListBase *lb, Object *pob, ParticleSystem *psys, float
ob= ec->ob;
if(psys->part->type!=PART_HAIR)
- where_is_object_time(ob,cfra);
+ where_is_object_time(scene, ob,cfra);
if(ob==pob)
dm=psmd->dm;
@@ -3298,7 +3298,7 @@ static int boid_see_mesh(ListBase *lb, Object *pob, ParticleSystem *psys, float
Mat4MulVecfl(imat,co2);
}
- if(psys_intersect_dm(ob,dm,ec->vert_cos,co1,co2,&min_d,&min_face,min_w,ec->face_minmax,0,0,0))
+ if(psys_intersect_dm(scene,ob,dm,ec->vert_cos,co1,co2,&min_d,&min_face,min_w,ec->face_minmax,0,0,0))
min_ob=ob;
}
}
@@ -3311,9 +3311,9 @@ static int boid_see_mesh(ListBase *lb, Object *pob, ParticleSystem *psys, float
else{
psys_disable_all(ob);
- dm=mesh_get_derived_final(ob,0);
+ dm=mesh_get_derived_final(scene, ob, 0);
if(dm==0)
- dm=mesh_get_derived_deform(ob,0);
+ dm=mesh_get_derived_deform(scene, ob, 0);
psys_enable_all(ob);
}
@@ -3416,7 +3416,7 @@ static int add_boid_acc(BoidVecFunc *bvf, float lat_max, float tan_max, float *l
}
}
/* determines the acceleration that the boid tries to acchieve */
-static void boid_brain(BoidVecFunc *bvf, ParticleData *pa, Object *ob, ParticleSystem *psys, ParticleSettings *part, KDTree *tree, float timestep, float cfra, float *acc)
+static void boid_brain(BoidVecFunc *bvf, ParticleData *pa, Scene *scene, Object *ob, ParticleSystem *psys, ParticleSettings *part, KDTree *tree, float timestep, float cfra, float *acc)
{
ParticleData *pars=psys->particles;
KDTreeNearest ptn[MAX_BOIDNEIGHBOURS+1];
@@ -3516,7 +3516,7 @@ static void boid_brain(BoidVecFunc *bvf, ParticleData *pa, Object *ob, ParticleS
count=BLI_kdtree_find_n_nearest(ec->tree,epart->boidneighbours,pa->prev_state.co,NULL,ptn2);
for(p=0; p<count; p++){
state.time=-1.0;
- if(psys_get_particle_state(eob,epsys,ptn2[p].index,&state,0)){
+ if(psys_get_particle_state(scene, eob,epsys,ptn2[p].index,&state,0)){
VECSUB(dvec, state.co, pa->prev_state.co);
distance = Normalize(dvec);
@@ -3663,7 +3663,7 @@ static void boid_brain(BoidVecFunc *bvf, ParticleData *pa, Object *ob, ParticleS
count=BLI_kdtree_find_n_nearest(ec->tree,epart->boidneighbours,pa->prev_state.co,NULL,ptn2);
for(p=0; p<count; p++){
state.time=-1.0;
- if(psys_get_particle_state(eob,epsys,ptn2[p].index,&state,0)){
+ if(psys_get_particle_state(scene, eob,epsys,ptn2[p].index,&state,0)){
VECSUB(dvec, state.co, pa->prev_state.co);
distance = Normalize(dvec);
@@ -3823,14 +3823,14 @@ static void boid_body(BoidVecFunc *bvf, ParticleData *pa, ParticleSystem *psys,
Mat4MulVecfl(imat,co1);
Mat4MulVecfl(imat,co2);
- if(psys_intersect_dm(zob,0,0,co1,co2,&min_d,&min_face,min_w,0,0,0,0)){
+ if(psys_intersect_dm(scene,zob,0,0,co1,co2,&min_d,&min_face,min_w,0,0,0,0)){
DerivedMesh *dm;
MFace *mface;
MVert *mvert;
float loc[3],nor[3],q1[4];
psys_disable_all(zob);
- dm=mesh_get_derived_final(zob,0);
+ dm=mesh_get_derived_final(scene, zob, 0);
psys_enable_all(zob);
mface=dm->getFaceDataArray(dm,CD_MFACE);
@@ -3872,7 +3872,7 @@ static void boid_body(BoidVecFunc *bvf, ParticleData *pa, ParticleSystem *psys,
/************************************************/
/* Hair */
/************************************************/
-static void save_hair(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float cfra){
+static void save_hair(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float cfra){
ParticleData *pa;
HairKey *key;
int totpart;
@@ -3880,7 +3880,7 @@ static void save_hair(Object *ob, ParticleSystem *psys, ParticleSystemModifierDa
Mat4Invert(ob->imat,ob->obmat);
- psys->lattice=psys_get_lattice(ob,psys);
+ psys->lattice= psys_get_lattice(scene, ob, psys);
if(psys->totpart==0) return;
@@ -3998,7 +3998,7 @@ static void dynamics_step(Object *ob, ParticleSystem *psys, ParticleSystemModifi
if(psys->effectors.first)
psys_end_effectors(psys);
- psys_init_effectors(ob,part->eff_group,psys);
+ psys_init_effectors(scene, ob, part->eff_group, psys);
if(psys->effectors.first)
precalc_effectors(ob,psys,psmd,cfra);
@@ -4080,7 +4080,7 @@ static void dynamics_step(Object *ob, ParticleSystem *psys, ParticleSystemModifi
case PART_PHYS_BOIDS:
{
float acc[3];
- boid_brain(&bvf,pa,ob,psys,part,tree,timestep,cfra,acc);
+ boid_brain(&bvf, pa, scene, ob, psys, part, tree, timestep,cfra,acc);
if(pa->alive != PARS_DYING)
boid_body(&bvf,pa,psys,part,timestep,acc);
break;
@@ -4118,13 +4118,13 @@ static void dynamics_step(Object *ob, ParticleSystem *psys, ParticleSystemModifi
}
/* check if path cache or children need updating and do it if needed */
-static void psys_update_path_cache(Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra)
+static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra)
{
ParticleSettings *part=psys->part;
- ParticleEditSettings *pset=&G.scene->toolsettings->particle;
+ ParticleEditSettings *pset=&scene->toolsettings->particle;
int distr=0,alloc=0;
- if((psys->part->childtype && psys->totchild != get_psys_tot_child(psys)) || psys->recalc&PSYS_ALLOC)
+ if((psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) || psys->recalc&PSYS_ALLOC)
alloc=1;
if(alloc || psys->recalc&PSYS_DISTR || (psys->vgroup[PSYS_VG_DENSITY] && (G.f & G_WEIGHTPAINT)))
@@ -4134,10 +4134,10 @@ static void psys_update_path_cache(Object *ob, ParticleSystemModifierData *psmd,
if(alloc)
realloc_particles(ob,psys,psys->totpart);
- if(get_psys_tot_child(psys)) {
+ if(get_psys_tot_child(scene, psys)) {
/* don't generate children while computing the hair keys */
if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
- distribute_particles(ob,psys,PART_FROM_CHILD);
+ distribute_particles(scene, ob, psys, PART_FROM_CHILD);
if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES && part->parents!=0.0)
psys_find_parents(ob,psmd,psys);
@@ -4145,22 +4145,22 @@ static void psys_update_path_cache(Object *ob, ParticleSystemModifierData *psmd,
}
}
- if((part->type==PART_HAIR || psys->flag&PSYS_KEYED) && (psys_in_edit_mode(psys)
+ if((part->type==PART_HAIR || psys->flag&PSYS_KEYED) && (psys_in_edit_mode(scene, psys)
|| (part->type==PART_HAIR || part->draw_as==PART_DRAW_PATH))){
- psys_cache_paths(ob, psys, cfra, 0);
+ psys_cache_paths(scene, ob, psys, cfra, 0);
/* for render, child particle paths are computed on the fly */
if(part->childtype) {
- if(((psys->totchild!=0)) || (psys_in_edit_mode(psys) && (pset->flag&PE_SHOW_CHILD)))
+ if(((psys->totchild!=0)) || (psys_in_edit_mode(scene, psys) && (pset->flag&PE_SHOW_CHILD)))
if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE))
- psys_cache_child_paths(ob, psys, cfra, 0);
+ psys_cache_child_paths(scene, ob, psys, cfra, 0);
}
}
else if(psys->pathcache)
psys_free_path_cache(psys);
}
-static void hair_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra)
+static void hair_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra)
{
ParticleSettings *part = psys->part;
ParticleData *pa;
@@ -4181,18 +4181,18 @@ static void hair_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSyst
if(psys->effectors.first)
psys_end_effectors(psys);
- psys_init_effectors(ob,part->eff_group,psys);
+ psys_init_effectors(scene, ob, part->eff_group, psys);
if(psys->effectors.first)
precalc_effectors(ob,psys,psmd,cfra);
- if(psys_in_edit_mode(psys))
+ if(psys_in_edit_mode(scene, psys))
; //XXX PE_recalc_world_cos(ob, psys);
- psys_update_path_cache(ob,psmd,psys,cfra);
+ psys_update_path_cache(scene, ob,psmd,psys,cfra);
}
/* updates cached particles' alive & other flags etc..*/
-static void cached_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra)
+static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra)
{
ParticleSettings *part=psys->part;
ParticleData *pa;
@@ -4209,7 +4209,7 @@ static void cached_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSy
psys_end_effectors(psys);
//if(part->flag & (PART_BAKED_GUIDES+PART_BAKED_DEATHS)){
- psys_init_effectors(ob,part->eff_group,psys);
+ psys_init_effectors(scene, ob, part->eff_group, psys);
if(psys->effectors.first)
precalc_effectors(ob,psys,psmd,cfra);
//}
@@ -4224,7 +4224,7 @@ static void cached_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSy
}
pa->size= psys_get_size(ob,ma,psmd,icu_esize,psys,part,pa,vg_size);
- psys->lattice=psys_get_lattice(ob,psys);
+ psys->lattice= psys_get_lattice(scene, ob, psys);
if(part->flag & PART_LOOP && part->type!=PART_HAIR)
pa->loop = (short)((cfra - pa->time) / pa->lifetime);
@@ -4240,7 +4240,7 @@ static void cached_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSy
else if(dietime <= cfra){
if(dietime > psys->cfra){
state.time = pa->dietime;
- psys_get_particle_state(ob,psys,p,&state,1);
+ psys_get_particle_state(scene, ob,psys,p,&state,1);
push_reaction(ob,psys,p,PART_EVENT_DEATH,&state);
}
pa->alive = PARS_DEAD;
@@ -4248,7 +4248,7 @@ static void cached_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSy
else{
pa->alive = PARS_ALIVE;
state.time = cfra;
- psys_get_particle_state(ob,psys,p,&state,1);
+ psys_get_particle_state(scene, ob,psys,p,&state,1);
state.time = cfra;
push_reaction(ob,psys,p,PART_EVENT_NEAR,&state);
}
@@ -4265,9 +4265,9 @@ static void cached_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSy
}
/* make sure that children are up to date */
- if(psys->part->childtype && psys->totchild != get_psys_tot_child(psys)) {
+ if(psys->part->childtype && psys->totchild != get_psys_tot_child(scene, psys)) {
realloc_particles(ob, psys, psys->totpart);
- distribute_particles(ob, psys, PART_FROM_CHILD);
+ distribute_particles(scene, ob, psys, PART_FROM_CHILD);
}
if(vg_size)
@@ -4308,7 +4308,7 @@ void psys_changed_type(ParticleSystem *psys)
psys_reset(psys, PSYS_RESET_ALL);
}
-static void particles_fluid_step(Object *ob, ParticleSystem *psys, int cfra)
+static void particles_fluid_step(Scene *scene, Object *ob, ParticleSystem *psys, int cfra)
{
if(psys->particles){
MEM_freeN(psys->particles);
@@ -4329,7 +4329,7 @@ static void particles_fluid_step(Object *ob, ParticleSystem *psys, int cfra)
char *suffix2 = ".gz";
char filename[256];
char debugStrBuffer[256];
- int curFrame = G.scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading
+ int curFrame = scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading
int p, j, numFileParts, totpart;
int readMask, activeParts = 0, fileParts = 0;
gzFile gzf;
@@ -4357,7 +4357,7 @@ static void particles_fluid_step(Object *ob, ParticleSystem *psys, int cfra)
part->totpart= totpart;
part->sta=part->end = 1.0f;
- part->lifetime = G.scene->r.efra + 1;
+ part->lifetime = scene->r.efra + 1;
/* initialize particles */
realloc_particles(ob, psys, part->totpart);
@@ -4415,7 +4415,7 @@ static void particles_fluid_step(Object *ob, ParticleSystem *psys, int cfra)
/* Calculates the next state for all particles of the system */
/* In particles code most fra-ending are frames, time-ending are fra*timestep (seconds)*/
-static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float cfra)
+static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float cfra)
{
ParticleSettings *part;
ParticleData *pa;
@@ -4429,11 +4429,11 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
part= psys->part;
cache= psys->pointcache;
- framenr= (int)G.scene->r.cfra;
+ framenr= (int)scene->r.cfra;
framedelta= framenr - cache->simframe;
BKE_ptcache_id_from_particles(&pid, ob, psys);
- BKE_ptcache_id_time(&pid, 0.0f, &startframe, &endframe, NULL);
+ BKE_ptcache_id_time(&pid, scene, 0.0f, &startframe, &endframe, NULL);
/* update ipo's */
if((part->flag & PART_ABS_TIME) && part->ipo) {
@@ -4443,14 +4443,14 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
/* hair if it's already done is handled separate */
if(part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DONE)) {
- hair_step(ob, psmd, psys, cfra);
+ hair_step(scene, ob, psmd, psys, cfra);
psys->cfra = cfra;
psys->recalc = 0;
return;
}
/* fluid is also handled separate */
else if(part->type == PART_FLUID) {
- particles_fluid_step(ob, psys, framenr);
+ particles_fluid_step(scene, ob, psys, framenr);
psys->cfra = cfra;
psys->recalc = 0;
return;
@@ -4485,7 +4485,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
totpart = part->grid_res*part->grid_res*part->grid_res;
else
totpart = psys->part->totpart;
- totchild = get_psys_tot_child(psys);
+ totchild = get_psys_tot_child(scene, psys);
if(oldtotpart != totpart || (psys->part->childtype && oldtotchild != totchild)) {
only_children_changed = (oldtotpart == totpart);
@@ -4505,13 +4505,13 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
if(alloc)
realloc_particles(ob, psys, totpart);
- distribute_particles(ob, psys, part->from);
+ distribute_particles(scene, ob, psys, part->from);
if((psys->part->type == PART_HAIR) && !(psys->flag & PSYS_HAIR_DONE))
/* don't generate children while growing hair - waste of time */
psys_free_children(psys);
- else if(get_psys_tot_child(psys))
- distribute_particles(ob, psys, PART_FROM_CHILD);
+ else if(get_psys_tot_child(scene, psys))
+ distribute_particles(scene, ob, psys, PART_FROM_CHILD);
}
if(only_children_changed==0) {
@@ -4533,12 +4533,12 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
set_keyed_keys(ob, psys);
}
- cached_step(ob,psmd,psys,cfra);
+ cached_step(scene, ob, psmd, psys, cfra);
psys->cfra=cfra;
psys->recalc = 0;
if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
- psys_update_path_cache(ob,psmd,psys,framenr);
+ psys_update_path_cache(scene, ob, psmd, psys, framenr);
}
cache->simframe= framenr;
@@ -4618,7 +4618,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
/* for keyed particles the path is allways known so it can be drawn */
if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED){
set_keyed_keys(ob, psys);
- psys_update_path_cache(ob,psmd,psys,(int)cfra);
+ psys_update_path_cache(scene, ob, psmd, psys,(int)cfra);
}
else if(psys->pathcache)
psys_free_path_cache(psys);
@@ -4635,7 +4635,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
}
}
-static void psys_to_softbody(Object *ob, ParticleSystem *psys)
+static void psys_to_softbody(Scene *scene, Object *ob, ParticleSystem *psys)
{
SoftBody *sb;
short softflag;
@@ -4655,7 +4655,7 @@ static void psys_to_softbody(Object *ob, ParticleSystem *psys)
ob->softflag= psys->softflag;
/* do softbody */
- sbObjectStep(ob, (float)G.scene->r.cfra, NULL, psys_count_keys(psys));
+ sbObjectStep(scene, ob, (float)scene->r.cfra, NULL, psys_count_keys(psys));
/* return things back to normal */
psys->soft= ob->soft;
@@ -4677,7 +4677,7 @@ static int hair_needs_recalc(ParticleSystem *psys)
}
/* main particle update call, checks that things are ok on the large scale before actual particle calculations */
-void particle_system_update(Object *ob, ParticleSystem *psys)
+void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd;
float cfra;
@@ -4685,7 +4685,7 @@ void particle_system_update(Object *ob, ParticleSystem *psys)
if(!psys_check_enabled(ob, psys))
return;
- cfra= bsystem_time(ob, (float)G.scene->r.cfra, 0.0f);
+ cfra= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0f);
psmd= psys_get_modifier(ob, psys);
/* system was already updated from modifier stack */
@@ -4711,8 +4711,8 @@ void particle_system_update(Object *ob, ParticleSystem *psys)
for(i=0; i<=psys->part->hair_step; i++){
hcfra=100.0f*(float)i/(float)psys->part->hair_step;
- system_step(ob, psys, psmd, hcfra);
- save_hair(ob, psys, psmd, hcfra);
+ system_step(scene, ob, psys, psmd, hcfra);
+ save_hair(scene, ob, psys, psmd, hcfra);
}
psys->flag |= PSYS_HAIR_DONE;
@@ -4720,10 +4720,10 @@ void particle_system_update(Object *ob, ParticleSystem *psys)
/* handle softbody hair */
if(psys->part->type==PART_HAIR && psys->soft)
- psys_to_softbody(ob, psys);
+ psys_to_softbody(scene, ob, psys);
/* the main particle system step */
- system_step(ob, psys, psmd, cfra);
+ system_step(scene, ob, psys, psmd, cfra);
/* save matrix for duplicators */
Mat4Invert(psys->imat, ob->obmat);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 596ac882d24..059aeadb24f 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -375,7 +375,7 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
return BLI_exists(filename);
}
-void BKE_ptcache_id_time(PTCacheID *pid, float cfra, int *startframe, int *endframe, float *timescale)
+void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startframe, int *endframe, float *timescale)
{
Object *ob;
PointCache *cache;
@@ -394,8 +394,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, float cfra, int *startframe, int *endfr
cache= pid->cache;
if(timescale) {
- time= bsystem_time(ob, cfra, 0.0f);
- nexttime= bsystem_time(ob, cfra+1.0f, 0.0f);
+ time= bsystem_time(scene, ob, cfra, 0.0f);
+ nexttime= bsystem_time(scene, ob, cfra+1.0f, 0.0f);
*timescale= MAX2(nexttime - time, 0.0f);
}
@@ -552,7 +552,7 @@ void BKE_ptcache_remove(void)
static int CONTINUE_PHYSICS = 0;
-void BKE_ptcache_set_continue_physics(int enable)
+void BKE_ptcache_set_continue_physics(Scene *scene, int enable)
{
Object *ob;
@@ -562,7 +562,7 @@ void BKE_ptcache_set_continue_physics(int enable)
if(CONTINUE_PHYSICS == 0) {
for(ob=G.main->object.first; ob; ob=ob->id.next)
if(BKE_ptcache_object_reset(ob, PTCACHE_RESET_OUTDATED))
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
}
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index d7df27d9c35..a59f1872263 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -317,21 +317,17 @@ Base *object_in_scene(Object *ob, Scene *sce)
return NULL;
}
-void set_scene_bg(Scene *sce)
+void set_scene_bg(Scene *scene)
{
+ Scene *sce;
Base *base;
Object *ob;
Group *group;
GroupObject *go;
int flag;
- // Note: this here is defined in editseq.c (BIF_editseq.h), NOT in blenkernel!
- //XXX clear_last_seq();
-
- G.scene= sce;
-
/* check for cyclic sets, for reading old files but also for definite security (py?) */
- scene_check_setscene(G.scene);
+ scene_check_setscene(scene);
/* deselect objects (for dataselect) */
for(ob= G.main->object.first; ob; ob= ob->id.next)
@@ -347,15 +343,15 @@ void set_scene_bg(Scene *sce)
}
/* sort baselist */
- DAG_scene_sort(sce);
+ DAG_scene_sort(scene);
/* ensure dags are built for sets */
- for(sce= sce->set; sce; sce= sce->set)
+ for(sce= scene->set; sce; sce= sce->set)
if(sce->theDag==NULL)
DAG_scene_sort(sce);
/* copy layers and flags from bases to objects */
- for(base= G.scene->base.first; base; base= base->next) {
+ for(base= scene->base.first; base; base= base->next) {
ob= base->object;
ob->lay= base->lay;
@@ -394,7 +390,7 @@ void set_scene_name(char *name)
/* used by metaballs
* doesnt return the original duplicated object, only dupli's
*/
-int next_object(int val, Base **base, Object **ob)
+int next_object(Scene *scene, int val, Base **base, Object **ob)
{
static ListBase *duplilist= NULL;
static DupliObject *dupob;
@@ -414,15 +410,15 @@ int next_object(int val, Base **base, Object **ob)
/* the first base */
if(fase==F_START) {
- *base= G.scene->base.first;
+ *base= scene->base.first;
if(*base) {
*ob= (*base)->object;
fase= F_SCENE;
}
else {
/* exception: empty scene */
- if(G.scene->set && G.scene->set->base.first) {
- *base= G.scene->set->base.first;
+ if(scene->set && scene->set->base.first) {
+ *base= scene->set->base.first;
*ob= (*base)->object;
fase= F_SET;
}
@@ -435,8 +431,8 @@ int next_object(int val, Base **base, Object **ob)
else {
if(fase==F_SCENE) {
/* scene is finished, now do the set */
- if(G.scene->set && G.scene->set->base.first) {
- *base= G.scene->set->base.first;
+ if(scene->set && scene->set->base.first) {
+ *base= scene->set->base.first;
*ob= (*base)->object;
fase= F_SET;
}
@@ -453,7 +449,7 @@ int next_object(int val, Base **base, Object **ob)
this enters eternal loop because of
makeDispListMBall getting called inside of group_duplilist */
if((*base)->object->dup_group == NULL) {
- duplilist= object_duplilist(G.scene, (*base)->object);
+ duplilist= object_duplilist(scene, (*base)->object);
dupob= duplilist->first;
@@ -573,7 +569,7 @@ static void scene_update(Scene *sce, unsigned int lay)
for(base= sce->base.first; base; base= base->next) {
ob= base->object;
- object_handle_update(ob); // bke_object.h
+ object_handle_update(sce, ob); // bke_object.h
/* only update layer when an ipo */
if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
@@ -591,7 +587,7 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay)
framechange_poses_clear_unkeyed();
/* object ipos are calculated in where_is_object */
- do_all_data_ipos();
+ do_all_data_ipos(sce);
#ifndef DISABLE_PYTHON
if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0);
#endif
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 3b29409d75c..f2197c932c9 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -91,18 +91,18 @@ typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *c
/* get derived mesh */
//TODO is anyfunction that does this? returning the derivedFinal witouth we caring if its in edit mode or not?
-DerivedMesh *object_get_derived_final(Object *ob, CustomDataMask dataMask)
+static DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDataMask dataMask)
{
Mesh *me= ob->data;
if (me->edit_mesh)
{
DerivedMesh *final = NULL;
- editmesh_get_derived_cage_and_final(ob, me->edit_mesh, &final, dataMask);
+ editmesh_get_derived_cage_and_final(scene, ob, me->edit_mesh, &final, dataMask);
return final;
}
else
- return mesh_get_derived_final(ob, dataMask);
+ return mesh_get_derived_final(scene, ob, dataMask);
}
/* Space transform */
@@ -124,13 +124,13 @@ void space_transform_invert(const SpaceTransform *data, float *co)
VecMat4MulVecfl(co, ((SpaceTransform*)data)->target2local, co);
}
-void space_transform_apply_normal(const SpaceTransform *data, float *no)
+static void space_transform_apply_normal(const SpaceTransform *data, float *no)
{
Mat4Mul3Vecfl( ((SpaceTransform*)data)->local2target, no);
Normalize(no); // TODO: could we just determine de scale value from the matrix?
}
-void space_transform_invert_normal(const SpaceTransform *data, float *no)
+static void space_transform_invert_normal(const SpaceTransform *data, float *no)
{
Mat4Mul3Vecfl(((SpaceTransform*)data)->target2local, no);
Normalize(no); // TODO: could we just determine de scale value from the matrix?
@@ -146,72 +146,6 @@ static float squared_dist(const float *a, const float *b)
return INPR(tmp, tmp);
}
-/* Main shrinkwrap function */
-void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts)
-{
-
- ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
-
- //remove loop dependencies on derived meshs (TODO should this be done elsewhere?)
- if(smd->target == ob) smd->target = NULL;
- if(smd->auxTarget == ob) smd->auxTarget = NULL;
-
-
- //Configure Shrinkwrap calc data
- calc.smd = smd;
- calc.ob = ob;
- calc.original = dm;
- calc.numVerts = numVerts;
- calc.vertexCos = vertexCos;
-
- //DeformVertex
- calc.vgroup = get_named_vertexgroup_num(calc.ob, calc.smd->vgroup_name);
- if(calc.original)
- {
- calc.dvert = calc.original->getVertDataArray(calc.original, CD_MDEFORMVERT);
- }
- else if(calc.ob->type == OB_LATTICE)
- {
- calc.dvert = lattice_get_deform_verts(calc.ob);
- }
-
-
- if(smd->target)
- {
- //TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array
- calc.target = CDDM_copy( object_get_derived_final(smd->target, CD_MASK_BAREMESH) );
-
- //TODO there might be several "bugs" on non-uniform scales matrixs.. because it will no longer be nearest surface, not sphere projection
- //because space has been deformed
- space_transform_setup(&calc.local2target, ob, smd->target);
-
- calc.keepDist = smd->keepDist; //TODO: smd->keepDist is in global units.. must change to local
- }
-
-
- //Projecting target defined - lets work!
- if(calc.target)
- {
- switch(smd->shrinkType)
- {
- case MOD_SHRINKWRAP_NEAREST_SURFACE:
- BENCH(shrinkwrap_calc_nearest_surface_point(&calc));
- break;
-
- case MOD_SHRINKWRAP_PROJECT:
- BENCH(shrinkwrap_calc_normal_projection(&calc));
- break;
-
- case MOD_SHRINKWRAP_NEAREST_VERTEX:
- BENCH(shrinkwrap_calc_nearest_vertex(&calc));
- break;
- }
- }
-
- //free memory
- if(calc.target)
- calc.target->release( calc.target );
-}
/*
* Shrinkwrap to the nearest vertex
@@ -219,7 +153,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
* it builds a kdtree of vertexs we can attach to and then
* for each vertex performs a nearest vertex search on the tree
*/
-void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
+static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
{
int i;
@@ -346,7 +280,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa
}
-void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
+static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct Scene *scene)
{
int i;
@@ -435,7 +369,7 @@ do
{
space_transform_setup( &local2aux, calc->ob, calc->smd->auxTarget);
- aux_mesh = CDDM_copy( object_get_derived_final(calc->smd->auxTarget, CD_MASK_BAREMESH) ); //TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array
+ aux_mesh = CDDM_copy( object_get_derived_final(scene, calc->smd->auxTarget, CD_MASK_BAREMESH) ); //TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array
if(aux_mesh)
BENCH(bvhtree_from_mesh_faces(&auxData, aux_mesh, 0.0, 4, 6));
else
@@ -527,7 +461,7 @@ do
* it builds a BVHTree from the target mesh and then performs a
* NN matchs for each vertex
*/
-void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
+static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
{
int i;
@@ -604,3 +538,70 @@ void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
free_bvhtree_from_mesh(&treeData);
}
+/* Main shrinkwrap function */
+void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, struct Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts)
+{
+
+ ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData;
+
+ //remove loop dependencies on derived meshs (TODO should this be done elsewhere?)
+ if(smd->target == ob) smd->target = NULL;
+ if(smd->auxTarget == ob) smd->auxTarget = NULL;
+
+
+ //Configure Shrinkwrap calc data
+ calc.smd = smd;
+ calc.ob = ob;
+ calc.original = dm;
+ calc.numVerts = numVerts;
+ calc.vertexCos = vertexCos;
+
+ //DeformVertex
+ calc.vgroup = get_named_vertexgroup_num(calc.ob, calc.smd->vgroup_name);
+ if(calc.original)
+ {
+ calc.dvert = calc.original->getVertDataArray(calc.original, CD_MDEFORMVERT);
+ }
+ else if(calc.ob->type == OB_LATTICE)
+ {
+ calc.dvert = lattice_get_deform_verts(calc.ob);
+ }
+
+
+ if(smd->target)
+ {
+ //TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array
+ calc.target = CDDM_copy( object_get_derived_final(scene, smd->target, CD_MASK_BAREMESH) );
+
+ //TODO there might be several "bugs" on non-uniform scales matrixs.. because it will no longer be nearest surface, not sphere projection
+ //because space has been deformed
+ space_transform_setup(&calc.local2target, ob, smd->target);
+
+ calc.keepDist = smd->keepDist; //TODO: smd->keepDist is in global units.. must change to local
+ }
+
+
+ //Projecting target defined - lets work!
+ if(calc.target)
+ {
+ switch(smd->shrinkType)
+ {
+ case MOD_SHRINKWRAP_NEAREST_SURFACE:
+ BENCH(shrinkwrap_calc_nearest_surface_point(&calc));
+ break;
+
+ case MOD_SHRINKWRAP_PROJECT:
+ BENCH(shrinkwrap_calc_normal_projection(&calc, scene));
+ break;
+
+ case MOD_SHRINKWRAP_NEAREST_VERTEX:
+ BENCH(shrinkwrap_calc_nearest_vertex(&calc));
+ break;
+ }
+ }
+
+ //free memory
+ if(calc.target)
+ calc.target->release( calc.target );
+}
+
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 1ae547ba7b8..422218e2957 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -120,7 +120,8 @@ typedef struct SBScratch {
float aabbmin[3],aabbmax[3];
}SBScratch;
-typedef struct SB_thread_context{
+typedef struct SB_thread_context {
+ Scene *scene;
Object *ob;
float forcetime;
float timenow;
@@ -196,7 +197,7 @@ static float sb_time_scale(Object *ob)
/*
this would be frames/sec independant timing assuming 25 fps is default
but does not work very well with NLA
- return (25.0f/G.scene->r.frs_sec)
+ return (25.0f/scene->r.frs_sec)
*/
}
/*--- frame based timing ---*/
@@ -484,12 +485,11 @@ static void ccd_mesh_free(ccd_Mesh *ccdm)
}
}
-static void ccd_build_deflector_hache(Object *vertexowner,GHash *hash)
+static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *hash)
{
- Base *base;
+ Base *base= scene->base.first;
Object *ob;
- base= G.scene->base.first;
- base= G.scene->base.first;
+
if (!hash) return;
while (base) {
/*Only proceed for mesh object in same layer */
@@ -516,9 +516,9 @@ static void ccd_build_deflector_hache(Object *vertexowner,GHash *hash)
}
else {
if(ob->softflag & OB_SB_COLLFINAL) /* so maybe someone wants overkill to collide with subsurfed */
- dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
else
- dm = mesh_get_derived_deform(ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
}
if(dm){
@@ -536,12 +536,11 @@ static void ccd_build_deflector_hache(Object *vertexowner,GHash *hash)
} /* while (base) */
}
-static void ccd_update_deflector_hache(Object *vertexowner,GHash *hash)
+static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash *hash)
{
- Base *base;
+ Base *base= scene->base.first;
Object *ob;
- base= G.scene->base.first;
- base= G.scene->base.first;
+
if ((!hash) || (!vertexowner)) return;
while (base) {
/*Only proceed for mesh object in same layer */
@@ -558,9 +557,9 @@ static void ccd_update_deflector_hache(Object *vertexowner,GHash *hash)
DerivedMesh *dm= NULL;
if(ob->softflag & OB_SB_COLLFINAL) { /* so maybe someone wants overkill to collide with subsurfed */
- dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
} else {
- dm = mesh_get_derived_deform(ob, CD_MASK_BAREMESH);
+ dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
}
if(dm){
ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob);
@@ -830,12 +829,12 @@ static void calculate_collision_balls(Object *ob)
/* creates new softbody if didn't exist yet, makes new points and springs arrays */
-static void renew_softbody(Object *ob, int totpoint, int totspring)
+static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring)
{
SoftBody *sb;
int i;
short softflag;
- if(ob->soft==NULL) ob->soft= sbNew();
+ if(ob->soft==NULL) ob->soft= sbNew(scene);
else free_softbody_intern(ob->soft);
sb= ob->soft;
softflag=ob->softflag;
@@ -970,11 +969,11 @@ static void Vec3PlusStVec(float *v, float s, float *v1)
/* +++ dependancy information functions*/
-static int are_there_deflectors(unsigned int layer)
+static int are_there_deflectors(Scene *scene, unsigned int layer)
{
Base *base;
- for(base = G.scene->base.first; base; base= base->next) {
+ for(base = scene->base.first; base; base= base->next) {
if( (base->lay & layer) && base->object->pd) {
if(base->object->pd->deflect)
return 1;
@@ -983,9 +982,9 @@ static int are_there_deflectors(unsigned int layer)
return 0;
}
-static int query_external_colliders(Object *me)
+static int query_external_colliders(Scene *scene, Object *me)
{
- return(are_there_deflectors(me->lay));
+ return(are_there_deflectors(scene, me->lay));
}
/* --- dependancy information functions*/
@@ -1528,9 +1527,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],floa
return deflected;
}
-
-
-static void _scan_for_ext_spring_forces(Object *ob,float timenow,int ifirst,int ilast, struct ListBase *do_effector)
+static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, int ifirst, int ilast, struct ListBase *do_effector)
{
SoftBody *sb = ob->soft;
int a;
@@ -1569,7 +1566,7 @@ static void _scan_for_ext_spring_forces(Object *ob,float timenow,int ifirst,int
float pos[3];
VecMidf(pos, sb->bpoint[bs->v1].pos , sb->bpoint[bs->v2].pos);
VecMidf(vel, sb->bpoint[bs->v1].vec , sb->bpoint[bs->v2].vec);
- pdDoEffectors(do_effector, pos, force, speed, (float)G.scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
+ pdDoEffectors(scene, do_effector, pos, force, speed, (float)scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
VecMulf(speed,windfactor);
VecAddf(vel,vel,speed);
}
@@ -1601,26 +1598,27 @@ static void _scan_for_ext_spring_forces(Object *ob,float timenow,int ifirst,int
}
-static void scan_for_ext_spring_forces(Object *ob,float timenow)
+static void scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow)
{
SoftBody *sb = ob->soft;
ListBase *do_effector= NULL;
- do_effector= pdInitEffectors(ob,NULL);
+
+ do_effector= pdInitEffectors(scene, ob,NULL);
if (sb){
- _scan_for_ext_spring_forces(ob,timenow,0,sb->totspring,do_effector);
+ _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector);
}
if(do_effector)
- pdEndEffectors(do_effector);
+ pdEndEffectors(do_effector);
}
static void *exec_scan_for_ext_spring_forces(void *data)
{
SB_thread_context *pctx = (SB_thread_context*)data;
- _scan_for_ext_spring_forces(pctx->ob,pctx->timenow,pctx->ifirst,pctx->ilast,pctx->do_effector);
+ _scan_for_ext_spring_forces(pctx->scene, pctx->ob, pctx->timenow, pctx->ifirst, pctx->ilast, pctx->do_effector);
return 0;
}
-static void sb_sfesf_threads_run(struct Object *ob, float timenow,int totsprings,int *ptr_to_break_func())
+static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *ptr_to_break_func())
{
ListBase *do_effector = NULL;
ListBase threads;
@@ -1628,11 +1626,11 @@ static void sb_sfesf_threads_run(struct Object *ob, float timenow,int totsprings
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 */
- do_effector= pdInitEffectors(ob,NULL);
+ do_effector= pdInitEffectors(scene, ob,NULL);
/* figure the number of threads while preventing pretty pointless threading overhead */
- if(G.scene->r.mode & R_FIXED_THREADS)
- totthread= G.scene->r.threads;
+ if(scene->r.mode & R_FIXED_THREADS)
+ totthread= scene->r.threads;
else
totthread= BLI_system_thread_count();
/* what if we got zillions of CPUs running but less to spread*/
@@ -1645,6 +1643,7 @@ static void sb_sfesf_threads_run(struct Object *ob, float timenow,int totsprings
left = totsprings;
dec = totsprings/totthread +1;
for(i=0; i<totthread; i++) {
+ sb_threads[i].scene = scene;
sb_threads[i].ob = ob;
sb_threads[i].forcetime = 0.0; // not used here
sb_threads[i].timenow = timenow;
@@ -2119,13 +2118,14 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo
/* since this is definitely the most CPU consuming task here .. try to spread it */
/* core function _softbody_calc_forces_slice_in_a_thread */
/* result is int to be able to flag user break */
-static int _softbody_calc_forces_slice_in_a_thread(Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *ptr_to_break_func(),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor)
+static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *ptr_to_break_func(),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor)
{
float iks;
int bb,do_selfcollision,do_springcollision,do_aero;
int number_of_points_here = ilast - ifirst;
SoftBody *sb= ob->soft; /* is supposed to be there */
BodyPoint *bp;
+
/* intitialize */
if (sb) {
/* check conditions for various options */
@@ -2247,7 +2247,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Object *ob, float forcetime,
float speed[3]= {0.0f, 0.0f, 0.0f};
float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */
- pdDoEffectors(do_effector, bp->pos, force, speed, (float)G.scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
+ pdDoEffectors(scene, do_effector, bp->pos, force, speed, (float)scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
/* apply forcefield*/
VecMulf(force,fieldfactor* eval_sb_fric_force_scale);
@@ -2322,11 +2322,11 @@ return 0; /*done fine*/
static void *exec_softbody_calc_forces(void *data)
{
SB_thread_context *pctx = (SB_thread_context*)data;
- _softbody_calc_forces_slice_in_a_thread(pctx->ob,pctx->forcetime,pctx->timenow,pctx->ifirst,pctx->ilast,NULL,pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor);
+ _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor);
return 0;
}
-static void sb_cf_threads_run(struct Object *ob, float forcetime, float timenow,int totpoint,int *ptr_to_break_func(),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor)
+static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *ptr_to_break_func(),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor)
{
ListBase threads;
SB_thread_context *sb_threads;
@@ -2334,8 +2334,8 @@ static void sb_cf_threads_run(struct Object *ob, float forcetime, float timenow,
int lowpoints =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
/* figure the number of threads while preventing pretty pointless threading overhead */
- if(G.scene->r.mode & R_FIXED_THREADS)
- totthread= G.scene->r.threads;
+ if(scene->r.mode & R_FIXED_THREADS)
+ totthread= scene->r.threads;
else
totthread= BLI_system_thread_count();
/* what if we got zillions of CPUs running but less to spread*/
@@ -2383,7 +2383,7 @@ static void sb_cf_threads_run(struct Object *ob, float forcetime, float timenow,
MEM_freeN(sb_threads);
}
-static void softbody_calc_forcesEx(Object *ob, float forcetime, float timenow, int nl_flags)
+static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, float timenow, int nl_flags)
{
/* rule we never alter free variables :bp->vec bp->pos in here !
* this will ruin adaptive stepsize AKA heun! (BM)
@@ -2398,7 +2398,7 @@ static void softbody_calc_forcesEx(Object *ob, float forcetime, float timenow, i
gravity = sb->grav * sb_grav_force_scale(ob);
/* check conditions for various options */
- do_deflector= query_external_colliders(ob);
+ do_deflector= query_external_colliders(scene, ob);
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_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2407,17 +2407,17 @@ static void softbody_calc_forcesEx(Object *ob, float forcetime, float timenow, i
bproot= sb->bpoint; /* need this for proper spring addressing */
if (do_springcollision || do_aero)
- sb_sfesf_threads_run(ob,timenow,sb->totspring,NULL);
+ sb_sfesf_threads_run(scene, ob, timenow,sb->totspring,NULL);
/* after spring scan because it uses Effoctors too */
- do_effector= pdInitEffectors(ob,NULL);
+ do_effector= pdInitEffectors(scene, ob,NULL);
if (do_deflector) {
float defforce[3];
do_deflector = sb_detect_aabb_collisionCached(defforce,ob->lay,ob,timenow);
}
- sb_cf_threads_run(ob,forcetime,timenow,sb->totpoint,NULL,do_effector,do_deflector,fieldfactor,windfactor);
+ sb_cf_threads_run(scene, ob, forcetime, timenow, sb->totpoint, NULL, do_effector, do_deflector, fieldfactor, windfactor);
/* finally add forces caused by face collision */
if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob,timenow);
@@ -2429,11 +2429,11 @@ static void softbody_calc_forcesEx(Object *ob, float forcetime, float timenow, i
-static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int nl_flags)
+static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, float timenow, int nl_flags)
{
/* redirection to the new threaded Version */
if (!(G.rt & 0x10)){ // 16
- softbody_calc_forcesEx(ob, forcetime, timenow, nl_flags);
+ softbody_calc_forcesEx(scene, ob, forcetime, timenow, nl_flags);
return;
}
else{
@@ -2472,7 +2472,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
gravity = sb->grav * sb_grav_force_scale(ob);
/* check conditions for various options */
- do_deflector= query_external_colliders(ob);
+ do_deflector= query_external_colliders(scene, ob);
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_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
@@ -2480,9 +2480,9 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
bproot= sb->bpoint; /* need this for proper spring addressing */
- if (do_springcollision || do_aero) scan_for_ext_spring_forces(ob,timenow);
+ if (do_springcollision || do_aero) scan_for_ext_spring_forces(scene, ob, timenow);
/* after spring scan because it uses Effoctors too */
- do_effector= pdInitEffectors(ob,NULL);
+ do_effector= pdInitEffectors(scene, ob,NULL);
if (do_deflector) {
float defforce[3];
@@ -2650,7 +2650,7 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow, int
float speed[3]= {0.0f, 0.0f, 0.0f};
float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */
- pdDoEffectors(do_effector, bp->pos, force, speed, (float)G.scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
+ pdDoEffectors(scene, do_effector, bp->pos, force, speed, (float)scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
/* apply forcefield*/
VecMulf(force,fieldfactor* eval_sb_fric_force_scale);
@@ -3191,7 +3191,7 @@ static void springs_from_mesh(Object *ob)
/* makes totally fresh start situation */
-static void mesh_to_softbody(Object *ob)
+static void mesh_to_softbody(Scene *scene, Object *ob)
{
SoftBody *sb;
Mesh *me= ob->data;
@@ -3204,7 +3204,7 @@ static void mesh_to_softbody(Object *ob)
else totedge= 0;
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
- renew_softbody(ob, me->totvert, totedge);
+ renew_softbody(scene, ob, me->totvert, totedge);
/* we always make body points */
sb= ob->soft;
@@ -3391,7 +3391,7 @@ static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff,Object *
/* makes totally fresh start situation */
-static void lattice_to_softbody(Object *ob)
+static void lattice_to_softbody(Scene *scene, Object *ob)
{
Lattice *lt= ob->data;
SoftBody *sb;
@@ -3410,7 +3410,7 @@ static void lattice_to_softbody(Object *ob)
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
- renew_softbody(ob, totvert, totspring);
+ renew_softbody(scene, ob, totvert, totspring);
sb= ob->soft; /* can be created in renew_softbody() */
/* weights from bpoints, same code used as for mesh vertices */
@@ -3435,7 +3435,7 @@ static void lattice_to_softbody(Object *ob)
}
/* makes totally fresh start situation */
-static void curve_surf_to_softbody(Object *ob)
+static void curve_surf_to_softbody(Scene *scene, Object *ob)
{
Curve *cu= ob->data;
SoftBody *sb;
@@ -3457,7 +3457,7 @@ static void curve_surf_to_softbody(Object *ob)
}
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
- renew_softbody(ob, totvert, totspring);
+ renew_softbody(scene, ob, totvert, totspring);
sb= ob->soft; /* can be created in renew_softbody() */
/* set vars now */
@@ -3581,7 +3581,7 @@ static void particles_to_softbody(Object *ob)
int totedge= totpoint-psys->totpart;
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
- renew_softbody(ob, totpoint, totedge);
+ renew_softbody(scene, ob, totpoint, totedge);
/* find first BodyPoint index for each particle */
if(psys->totpart > 0) {
@@ -3727,7 +3727,7 @@ static void sb_new_scratch(SoftBody *sb)
/* ************ Object level, exported functions *************** */
/* allocates and initializes general main data */
-SoftBody *sbNew(void)
+SoftBody *sbNew(Scene *scene)
{
SoftBody *sb;
@@ -3751,8 +3751,8 @@ SoftBody *sbNew(void)
sb->inpush = 0.5f;
sb->interval= 10;
- sb->sfra= G.scene->r.sfra;
- sb->efra= G.scene->r.efra;
+ sb->sfra= scene->r.sfra;
+ sb->efra= scene->r.efra;
sb->colball = 0.49f;
sb->balldamp = 0.50f;
@@ -3938,16 +3938,17 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
}
}
-static void softbody_step(Object *ob, SoftBody *sb, float dtime)
+static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
{
/* the simulator */
float forcetime;
double sct,sst=PIL_check_seconds_timer();
- ccd_update_deflector_hache(ob,sb->scratch->colliderhash);
+
+ ccd_update_deflector_hash(scene, ob, sb->scratch->colliderhash);
if(sb->scratch->needstobuildcollider){
- if (query_external_colliders(ob)){
- ccd_build_deflector_hache(ob,sb->scratch->colliderhash);
+ if (query_external_colliders(scene, ob)){
+ ccd_build_deflector_hash(scene, ob, sb->scratch->colliderhash);
}
sb->scratch->needstobuildcollider=0;
}
@@ -3980,12 +3981,12 @@ static void softbody_step(Object *ob, SoftBody *sb, float dtime)
sb->scratch->flag &= ~SBF_DOFUZZY;
/* do predictive euler step */
- softbody_calc_forces(ob, forcetime,timedone/dtime,0);
+ softbody_calc_forces(scene, ob, forcetime,timedone/dtime,0);
softbody_apply_forces(ob, forcetime, 1, NULL,mid_flags);
/* crop new slope values to do averaged slope step */
- softbody_calc_forces(ob, forcetime,timedone/dtime,0);
+ softbody_calc_forces(scene, ob, forcetime,timedone/dtime,0);
softbody_apply_forces(ob, forcetime, 2, &err,mid_flags);
softbody_apply_goalsnap(ob);
@@ -4067,7 +4068,7 @@ static void softbody_step(Object *ob, SoftBody *sb, float dtime)
}
/* simulates one step. framenr is in frames */
-void sbObjectStep(Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
+void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
{
ParticleSystemModifierData *psmd=0;
ParticleData *pa=0;
@@ -4083,7 +4084,7 @@ void sbObjectStep(Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
framedelta= framenr - cache->simframe;
BKE_ptcache_id_from_softbody(&pid, ob, sb);
- BKE_ptcache_id_time(&pid, framenr, &startframe, &endframe, &timescale);
+ BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
/* check for changes in mesh, should only happen in case the mesh
* structure changes during an animation */
@@ -4115,17 +4116,17 @@ void sbObjectStep(Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
else {
switch(ob->type) {
case OB_MESH:
- mesh_to_softbody(ob);
+ mesh_to_softbody(scene, ob);
break;
case OB_LATTICE:
- lattice_to_softbody(ob);
+ lattice_to_softbody(scene, ob);
break;
case OB_CURVE:
case OB_SURF:
- curve_surf_to_softbody(ob);
+ curve_surf_to_softbody(scene, ob);
break;
default:
- renew_softbody(ob, numVerts, 0);
+ renew_softbody(scene, ob, numVerts, 0);
break;
}
}
@@ -4143,7 +4144,7 @@ void sbObjectStep(Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
dtime = timescale;
softbody_update_positions(ob, sb, vertexCos, numVerts);
- softbody_step(ob, sb, dtime);
+ softbody_step(scene, ob, sb, dtime);
if(sb->particles==0)
softbody_to_object(ob, vertexCos, numVerts, 0);
@@ -4203,7 +4204,7 @@ void sbObjectStep(Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
/* checking time: */
dtime = framedelta*timescale;
- softbody_step(ob, sb, dtime);
+ softbody_step(scene, ob, sb, dtime);
if(sb->particles==0)
softbody_to_object(ob, vertexCos, numVerts, 0);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index f5124ed9056..577a5ee5308 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -2590,7 +2590,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
CCGSubSurf *ss;
int levels;
- levels= get_render_subsurf_level(&G.scene->r, smd->renderLevels);
+ levels= smd->renderLevels; // XXX get_render_subsurf_level(&scene->r, smd->renderLevels);
if(levels == 0)
return dm;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index d1d252ab210..999e1744ae6 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -322,7 +322,7 @@ int reopen_text(Text *text)
return 1;
}
-Text *add_text(char *file)
+Text *add_text(char *file, const char *relpath)
{
FILE *fp;
int i, llen, len, res;
@@ -334,8 +334,8 @@ Text *add_text(char *file)
struct stat st;
BLI_strncpy(str, file, FILE_MAXDIR+FILE_MAXFILE);
- if (G.scene) /* can be NULL (bg mode) */
- BLI_convertstringcode(str, G.sce);
+ if (relpath) /* can be NULL (bg mode) */
+ BLI_convertstringcode(str, relpath);
BLI_split_dirfile_basic(str, NULL, sfile);
fp= fopen(str, "r");
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 9300b39a767..cdbd2afb421 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -812,14 +812,14 @@ Tex *give_current_texture(Object *ob, int act)
return tex;
}
-Tex *give_current_world_texture(void)
+Tex *give_current_world_texture(Scene *scene)
{
MTex *mtex = 0;
Tex *tex = 0;
- if(!(G.scene->world)) return 0;
+ if(!(scene->world)) return 0;
- mtex= G.scene->world->mtex[(int)(G.scene->world->texact)];
+ mtex= scene->world->mtex[(int)(scene->world->texact)];
if(mtex) tex= mtex->tex;
return tex;
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index e63588e6d7f..1829a07d543 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -64,7 +64,7 @@ bMovieHandle *BKE_get_movie_handle(int imtype)
mh.start_movie= start_avi;
mh.append_movie= append_avi;
mh.end_movie= end_avi;
- mh.get_next_frame = 0;
+ mh.get_next_frame = NULL;
/* do the platform specific handles */
#ifdef __sgi
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 3ac3ed4f7aa..908defb08cc 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -70,7 +70,7 @@
#endif
extern void do_init_ffmpeg();
-void makeffmpegstring(char* string);
+static void makeffmpegstring(RenderData* rd, char* string);
static int ffmpeg_type = 0;
static int ffmpeg_codec = CODEC_ID_MPEG4;
@@ -96,8 +96,6 @@ static int audio_input_frame_size = 0;
static uint8_t* audio_output_buffer = 0;
static int audio_outbuf_size = 0;
-static RenderData *ffmpeg_renderdata = 0;
-
#define FFMPEG_AUTOSPLIT_SIZE 2000000000
/* Delete a picture buffer */
@@ -236,13 +234,13 @@ static const char** get_file_extensions(int format)
}
/* Write a frame to the output file */
-static void write_video_frame(AVFrame* frame)
+static void write_video_frame(RenderData *rd, AVFrame* frame)
{
int outsize = 0;
int ret;
AVCodecContext* c = get_codec_from_stream(video_stream);
#ifdef FFMPEG_CODEC_TIME_BASE
- frame->pts = G.scene->r.cfra - G.scene->r.sfra;
+ frame->pts = rd->cfra - rd->sfra;
#endif
outsize = avcodec_encode_video(c, video_buffer, video_buffersize,
@@ -393,18 +391,18 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
}
}
-static void set_ffmpeg_properties(AVCodecContext* c, const char * prop_name)
+static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char * prop_name)
{
IDProperty * prop;
void * iter;
IDProperty * curr;
- if (!G.scene->r.ffcodecdata.properties) {
+ if (!rd->ffcodecdata.properties) {
return;
}
prop = IDP_GetPropertyFromGroup(
- G.scene->r.ffcodecdata.properties, (char*) prop_name);
+ rd->ffcodecdata.properties, (char*) prop_name);
if (!prop) {
return;
}
@@ -418,7 +416,7 @@ static void set_ffmpeg_properties(AVCodecContext* c, const char * prop_name)
/* prepare a video stream for the output file */
-static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of,
+static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContext* of,
int rectx, int recty)
{
AVStream* st;
@@ -441,39 +439,39 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of,
#ifdef FFMPEG_CODEC_TIME_BASE
/* FIXME: Really bad hack (tm) for NTSC support */
- if (ffmpeg_type == FFMPEG_DV && G.scene->r.frs_sec != 25) {
+ if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
c->time_base.den = 2997;
c->time_base.num = 100;
- } else if ((double) ((int) G.scene->r.frs_sec_base) ==
- G.scene->r.frs_sec_base) {
- c->time_base.den = G.scene->r.frs_sec;
- c->time_base.num = (int) G.scene->r.frs_sec_base;
+ } else if ((double) ((int) rd->frs_sec_base) ==
+ rd->frs_sec_base) {
+ c->time_base.den = rd->frs_sec;
+ c->time_base.num = (int) rd->frs_sec_base;
} else {
- c->time_base.den = G.scene->r.frs_sec * 100000;
- c->time_base.num = ((double) G.scene->r.frs_sec_base) * 100000;
+ c->time_base.den = rd->frs_sec * 100000;
+ c->time_base.num = ((double) rd->frs_sec_base) * 100000;
}
#else
/* FIXME: Really bad hack (tm) for NTSC support */
- if (ffmpeg_type == FFMPEG_DV && G.scene->r.frs_sec != 25) {
+ if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
c->frame_rate = 2997;
c->frame_rate_base = 100;
- } else if ((double) ((int) G.scene->r.frs_sec_base) ==
- G.scene->r.frs_sec_base) {
- c->frame_rate = G.scene->r.frs_sec;
- c->frame_rate_base = G.scene->r.frs_sec_base;
+ } else if ((double) ((int) rd->frs_sec_base) ==
+ rd->frs_sec_base) {
+ c->frame_rate = rd->frs_sec;
+ c->frame_rate_base = rd->frs_sec_base;
} else {
- c->frame_rate = G.scene->r.frs_sec * 100000;
- c->frame_rate_base = ((double) G.scene->r.frs_sec_base)*100000;
+ c->frame_rate = rd->frs_sec * 100000;
+ c->frame_rate_base = ((double) rd->frs_sec_base)*100000;
}
#endif
c->gop_size = ffmpeg_gop_size;
c->bit_rate = ffmpeg_video_bitrate*1000;
- c->rc_max_rate = G.scene->r.ffcodecdata.rc_max_rate*1000;
- c->rc_min_rate = G.scene->r.ffcodecdata.rc_min_rate*1000;
- c->rc_buffer_size = G.scene->r.ffcodecdata.rc_buffer_size * 1024;
+ c->rc_max_rate = rd->ffcodecdata.rc_max_rate*1000;
+ c->rc_min_rate = rd->ffcodecdata.rc_min_rate*1000;
+ c->rc_buffer_size = rd->ffcodecdata.rc_buffer_size * 1024;
c->rc_initial_buffer_occupancy
- = G.scene->r.ffcodecdata.rc_buffer_size*3/4;
+ = rd->ffcodecdata.rc_buffer_size*3/4;
c->rc_buffer_aggressivity = 1.0;
c->me_method = ME_EPZS;
@@ -502,7 +500,7 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of,
}
/* Determine whether we are encoding interlaced material or not */
- if (G.scene->r.mode & R_FIELDS) {
+ if (rd->mode & R_FIELDS) {
fprintf(stderr, "Encoding interlaced video\n");
c->flags |= CODEC_FLAG_INTERLACED_DCT;
c->flags |= CODEC_FLAG_INTERLACED_ME;
@@ -511,9 +509,9 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of,
/* xasp & yasp got float lately... */
c->sample_aspect_ratio = av_d2q(
- ((double) G.scene->r.xasp / (double) G.scene->r.yasp), 255);
+ ((double) rd->xasp / (double) rd->yasp), 255);
- set_ffmpeg_properties(c, "video");
+ set_ffmpeg_properties(rd, c, "video");
if (avcodec_open(c, codec) < 0) {
//
@@ -538,7 +536,7 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of,
/* Prepare an audio stream for the output file */
-static AVStream* alloc_audio_stream(int codec_id, AVFormatContext* of)
+static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext* of)
{
AVStream* st;
AVCodecContext* c;
@@ -551,7 +549,7 @@ static AVStream* alloc_audio_stream(int codec_id, AVFormatContext* of)
c->codec_id = codec_id;
c->codec_type = CODEC_TYPE_AUDIO;
- c->sample_rate = G.scene->audio.mixrate;
+ c->sample_rate = rd->audio.mixrate;
c->bit_rate = ffmpeg_audio_bitrate*1000;
c->channels = 2;
codec = avcodec_find_encoder(c->codec_id);
@@ -627,7 +625,7 @@ void start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty)
do_init_ffmpeg();
/* Determine the correct filename */
- makeffmpegstring(name);
+ makeffmpegstring(rd, name);
fprintf(stderr, "Starting output to %s(ffmpeg)...\n"
" Using type=%d, codec=%d, audio_codec=%d,\n"
" video_bitrate=%d, audio_bitrate=%d,\n"
@@ -659,9 +657,9 @@ void start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty)
}
of->oformat = fmt;
- of->packet_size= G.scene->r.ffcodecdata.mux_packet_size;
+ of->packet_size= rd->ffcodecdata.mux_packet_size;
if (ffmpeg_multiplex_audio) {
- of->mux_rate = G.scene->r.ffcodecdata.mux_rate;
+ of->mux_rate = rd->ffcodecdata.mux_rate;
} else {
of->mux_rate = 0;
}
@@ -707,14 +705,14 @@ void start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty)
//XXX error("Render width has to be 720 pixels for DV!");
return;
}
- if (G.scene->r.frs_sec != 25 && recty != 480) {
+ if (rd->frs_sec != 25 && recty != 480) {
G.afbreek = 1;
//XXX error("Render height has to be 480 pixels "
// "for DV-NTSC!");
return;
}
- if (G.scene->r.frs_sec == 25 && recty != 576) {
+ if (rd->frs_sec == 25 && recty != 576) {
G.afbreek = 1;
//XXX error("Render height has to be 576 pixels "
// "for DV-PAL!");
@@ -726,8 +724,7 @@ void start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty)
if (ffmpeg_type == FFMPEG_DV) {
fmt->audio_codec = CODEC_ID_PCM_S16LE;
- if (ffmpeg_multiplex_audio
- && G.scene->audio.mixrate != 48000) {
+ if (ffmpeg_multiplex_audio && rd->audio.mixrate != 48000) {
G.afbreek = 1;
//XXX error("FFMPEG only supports 48khz / stereo "
// "audio for DV!");
@@ -735,7 +732,7 @@ void start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty)
}
}
- video_stream = alloc_video_stream(fmt->video_codec, of, rectx, recty);
+ video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty);
if (!video_stream) {
G.afbreek = 1;
//XXX error("Error initializing video stream");
@@ -743,7 +740,7 @@ void start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty)
}
if (ffmpeg_multiplex_audio) {
- audio_stream = alloc_audio_stream(fmt->audio_codec, of);
+ audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of);
if (!audio_stream) {
G.afbreek = 1;
//XXX error("Error initializing audio stream");
@@ -775,7 +772,7 @@ void start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty)
********************************************************************** */
/* Get the output filename-- similar to the other output formats */
-void makeffmpegstring(char* string) {
+static void makeffmpegstring(RenderData* rd, char* string) {
// XXX quick define, solve!
#define FILE_MAXDIR 256
@@ -787,20 +784,20 @@ void makeffmpegstring(char* string) {
#undef FILE_MAXFILE
char autosplit[20];
- const char ** exts = get_file_extensions(G.scene->r.ffcodecdata.type);
+ const char ** exts = get_file_extensions(rd->ffcodecdata.type);
const char ** fe = exts;
if (!string || !exts) return;
- strcpy(string, G.scene->r.pic);
+ strcpy(string, rd->pic);
BLI_convertstringcode(string, G.sce);
- BLI_convertstringframe(string, G.scene->r.cfra);
+ BLI_convertstringframe(string, rd->cfra);
BLI_make_existing_file(string);
autosplit[0] = 0;
- if ((G.scene->r.ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) {
+ if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) {
sprintf(autosplit, "_%03d", ffmpeg_autosplit_count);
}
@@ -814,8 +811,8 @@ void makeffmpegstring(char* string) {
if (!*fe) {
strcat(string, autosplit);
- sprintf(txt, "%04d_%04d%s", (G.scene->r.sfra),
- (G.scene->r.efra), *exts);
+ sprintf(txt, "%04d_%04d%s", (rd->sfra),
+ (rd->efra), *exts);
strcat(string, txt);
} else {
*(string + strlen(string) - strlen(*fe)) = 0;
@@ -829,8 +826,6 @@ void start_ffmpeg(RenderData *rd, int rectx, int recty)
{
ffmpeg_autosplit_count = 0;
- ffmpeg_renderdata = rd;
-
start_ffmpeg_impl(rd, rectx, recty);
}
@@ -856,21 +851,20 @@ static void write_audio_frames()
}
}
-void append_ffmpeg(int frame, int *pixels, int rectx, int recty)
+void append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty)
{
fprintf(stderr, "Writing frame %i, "
"render width=%d, render height=%d\n", frame,
rectx, recty);
write_audio_frames();
- write_video_frame(generate_video_frame((unsigned char*) pixels));
+ write_video_frame(rd, generate_video_frame((unsigned char*) pixels));
if (ffmpeg_autosplit) {
if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) {
end_ffmpeg();
ffmpeg_autosplit_count++;
- start_ffmpeg_impl(ffmpeg_renderdata,
- rectx, recty);
+ start_ffmpeg_impl(rd, rectx, recty);
}
}
}
diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c
index 64bf5f85d23..c22c2fbe8ad 100644
--- a/source/blender/blenkernel/intern/writeframeserver.c
+++ b/source/blender/blenkernel/intern/writeframeserver.c
@@ -188,7 +188,7 @@ static int safe_puts(char * s)
return safe_write(s, strlen(s));
}
-static int handle_request(char * req)
+static int handle_request(RenderData *rd, char * req)
{
char * p;
char * path;
@@ -230,11 +230,11 @@ static int handle_request(char * req)
"height %d\n"
"rate %d\n"
"ratescale %d\n",
- G.scene->r.sfra,
- G.scene->r.efra,
+ rd->sfra,
+ rd->efra,
render_width,
render_height,
- G.scene->r.frs_sec,
+ rd->frs_sec,
1
);
@@ -249,7 +249,7 @@ static int handle_request(char * req)
return -1;
}
-int frameserver_loop(void)
+int frameserver_loop(RenderData *rd)
{
fd_set readfds;
struct timeval tv;
@@ -312,7 +312,7 @@ int frameserver_loop(void)
buf[len] = 0;
- return handle_request(buf);
+ return handle_request(rd, buf);
}
static void serve_ppm(int *pixels, int rectx, int recty)