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
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Makefile11
-rw-r--r--source/blender/CMakeLists.txt1
-rw-r--r--source/blender/Makefile2
-rw-r--r--source/blender/SConscript1
-rw-r--r--source/blender/blenkernel/BKE_exotic.h1
-rw-r--r--source/blender/blenkernel/BKE_particle.h5
-rw-r--r--source/blender/blenkernel/BKE_pointcache.h56
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h8
-rw-r--r--source/blender/blenkernel/intern/blender.c1
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c18
-rw-r--r--source/blender/blenkernel/intern/exotic.c593
-rw-r--r--source/blender/blenkernel/intern/multires.c6
-rw-r--r--source/blender/blenkernel/intern/particle.c48
-rw-r--r--source/blender/blenkernel/intern/particle_system.c187
-rw-r--r--source/blender/blenkernel/intern/pointcache.c753
-rw-r--r--source/blender/blenkernel/intern/scene.c2
-rw-r--r--source/blender/blenlib/intern/storage.c12
-rw-r--r--source/blender/blenlib/intern/util.c5
-rw-r--r--source/blender/blenloader/intern/readfile.c32
-rw-r--r--source/blender/blenloader/intern/writefile.c21
-rw-r--r--source/blender/blenpluginapi/intern/Makefile4
-rw-r--r--source/blender/editors/include/ED_pointcache.h (renamed from source/blender/makesdna/DNA_radio_types.h)42
-rw-r--r--source/blender/editors/physics/ed_pointcache.c270
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c153
-rw-r--r--source/blender/editors/space_api/spacetypes.c2
-rw-r--r--source/blender/editors/space_buttons/SConscript3
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c12
-rw-r--r--source/blender/editors/space_info/SConscript3
-rw-r--r--source/blender/editors/space_logic/SConscript3
-rw-r--r--source/blender/editors/space_view3d/drawobject.c3
-rw-r--r--source/blender/editors/transform/transform_conversions.c2
-rw-r--r--source/blender/editors/transform/transform_input.c1
-rw-r--r--source/blender/editors/transform/transform_ndofinput.c1
-rw-r--r--source/blender/editors/transform/transform_numinput.c1
-rw-r--r--source/blender/gpu/intern/Makefile2
-rw-r--r--source/blender/imbuf/intern/imbuf.h2
-rw-r--r--source/blender/imbuf/intern/readimage.c21
-rw-r--r--source/blender/makesdna/DNA_object_force.h19
-rw-r--r--source/blender/makesdna/DNA_particle_types.h1
-rw-r--r--source/blender/makesdna/DNA_scene_types.h4
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h31
-rw-r--r--source/blender/makesdna/intern/makesdna.c2
-rw-r--r--source/blender/makesrna/RNA_access.h4
-rw-r--r--source/blender/makesrna/RNA_enum_types.h3
-rw-r--r--source/blender/makesrna/intern/makesrna.c1
-rw-r--r--source/blender/makesrna/intern/rna_access.c31
-rw-r--r--source/blender/makesrna/intern/rna_internal.h1
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c105
-rw-r--r--source/blender/makesrna/intern/rna_particle.c94
-rw-r--r--source/blender/makesrna/intern/rna_radio.c140
-rw-r--r--source/blender/makesrna/intern/rna_scene.c4
-rw-r--r--source/blender/makesrna/intern/rna_space.c25
-rw-r--r--source/blender/makesrna/intern/rna_wm.c202
-rw-r--r--source/blender/makesrna/intern/rna_world.c2
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c97
-rw-r--r--source/blender/radiosity/CMakeLists.txt36
-rw-r--r--source/blender/radiosity/Makefile34
-rw-r--r--source/blender/radiosity/SConscript12
-rw-r--r--source/blender/radiosity/extern/include/radio.h173
-rw-r--r--source/blender/radiosity/extern/include/radio_types.h168
-rw-r--r--source/blender/radiosity/intern/Makefile34
-rw-r--r--source/blender/radiosity/intern/source/Makefile55
-rw-r--r--source/blender/radiosity/intern/source/raddisplay.c477
-rw-r--r--source/blender/radiosity/intern/source/radfactors.c939
-rw-r--r--source/blender/radiosity/intern/source/radio.c390
-rw-r--r--source/blender/radiosity/intern/source/radnode.c1103
-rw-r--r--source/blender/radiosity/intern/source/radpostprocess.c824
-rw-r--r--source/blender/radiosity/intern/source/radpreprocess.c828
-rw-r--r--source/blender/radiosity/intern/source/radrender.c530
-rw-r--r--source/blender/render/extern/include/RE_render_ext.h3
-rw-r--r--source/blender/render/intern/source/convertblender.c10
-rw-r--r--source/blender/render/intern/source/pipeline.c19
-rw-r--r--source/blender/render/intern/source/zbuf.c108
-rw-r--r--source/blender/windowmanager/WM_types.h31
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c5
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c311
-rw-r--r--source/creator/CMakeLists.txt7
-rw-r--r--source/gameengine/BlenderRoutines/Makefile3
-rw-r--r--source/gameengine/BlenderRoutines/SConscript5
-rw-r--r--source/gameengine/CMakeLists.txt1
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp13
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp28
-rw-r--r--source/gameengine/Converter/Makefile3
-rw-r--r--source/gameengine/Converter/SConscript5
-rw-r--r--source/gameengine/Expressions/CMakeLists.txt1
-rw-r--r--source/gameengine/GamePlayer/common/Makefile3
-rw-r--r--source/gameengine/GamePlayer/common/SConscript5
-rw-r--r--source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp3
-rw-r--r--source/gameengine/GamePlayer/common/unix/Makefile2
-rw-r--r--source/gameengine/GamePlayer/ghost/SConscript4
-rw-r--r--source/gameengine/Ketsji/KX_ClientObjectInfo.h12
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h30
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp592
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.cpp257
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.h109
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.cpp244
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.h122
-rw-r--r--source/gameengine/Ketsji/Makefile4
-rw-r--r--source/gameengine/Ketsji/SConscript9
-rw-r--r--source/gameengine/Physics/BlOde/Makefile48
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.cpp625
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.h164
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp277
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h94
-rw-r--r--source/gameengine/Physics/BlOde/SConscript15
-rw-r--r--source/gameengine/Physics/Dummy/Makefile2
-rw-r--r--source/gameengine/Physics/Makefile3
-rw-r--r--source/gameengine/Physics/Sumo/CMakeLists.txt46
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/Makefile34
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h11
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h16
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h26
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h56
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h77
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h393
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h58
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h172
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile25
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp709
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp695
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/Makefile14
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp180
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp100
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp1298
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp378
-rw-r--r--source/gameengine/Physics/Sumo/Makefile50
-rw-r--r--source/gameengine/Physics/Sumo/SConscript25
-rw-r--r--source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp66
-rw-r--r--source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h28
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.cpp495
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.h192
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp264
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h110
-rw-r--r--source/gameengine/Physics/Sumo/convert.txt35
-rw-r--r--source/gameengine/Physics/Sumo/include/interpolator.h27
-rw-r--r--source/gameengine/Physics/common/Makefile2
-rw-r--r--source/gameengine/SConscript8
-rw-r--r--source/nan_compile.mk15
-rw-r--r--source/nan_definitions.mk41
-rw-r--r--source/nan_link.mk4
141 files changed, 1882 insertions, 15606 deletions
diff --git a/source/Makefile b/source/Makefile
index 2df57f58c73..62eb25acbc1 100644
--- a/source/Makefile
+++ b/source/Makefile
@@ -115,25 +115,16 @@ ifneq ($(NAN_NO_KETSJI),true)
COMLIB += $(OCGDIR)/gameengine/ketsji/$(DEBUG_DIR)libketsji.a
COMLIB += $(OCGDIR)/gameengine/blconverter/$(DEBUG_DIR)libblconverter.a
COMLIB += $(OCGDIR)/gameengine/blconverter/$(DEBUG_DIR)libblconverter.a
- COMLIB += $(NAN_SOLID)/lib/libsolid.a
- COMLIB += $(NAN_SOLID)/lib/libsolid_broad.a
- COMLIB += $(NAN_SOLID)/lib/libsolid_complex.a
- COMLIB += $(NAN_SOLID)/lib/libsolid_convex.a
- COMLIB += $(OCGDIR)/gameengine/blphys/sumo/$(DEBUG_DIR)libsumo.a
COMLIB += $(OCGDIR)/gameengine/blphys/fuzzics/$(DEBUG_DIR)libfuzzics.a
COMLIB += $(NAN_QHULL)/lib/libqhull.a
COMLIB += $(OCGDIR)/gameengine/blphys/dummy/$(DEBUG_DIR)libdummy.a
COMLIB += $(OCGDIR)/gameengine/blphys/common/$(DEBUG_DIR)libcommon.a
-# COMLIB += $(OCGDIR)/gameengine/blphys/sumo/$(DEBUG_DIR)libsumo.a
COMLIB += $(OCGDIR)/gameengine/blphys/dummy/$(DEBUG_DIR)libdummy.a
COMLIB += $(OCGDIR)/gameengine/ketsji/$(DEBUG_DIR)libketsji.a
COMLIB += $(OCGDIR)/gameengine/blphys/common/$(DEBUG_DIR)libcommon.a
-# COMLIB += $(OCGDIR)/gameengine/blphys/blode/$(DEBUG_DIR)libblode.a
-# COMLIB += $(OCGDIR)/gameengine/blphys/sumo/$(DEBUG_DIR)libsumo.a
COMLIB += $(OCGDIR)/gameengine/blphys/dummy/$(DEBUG_DIR)libdummy.a
COMLIB += $(OCGDIR)/gameengine/blphys/blbullet/$(DEBUG_DIR)libblbullet.a
COMLIB += $(OCGDIR)/gameengine/blphys/common/$(DEBUG_DIR)libcommon.a
-# COMLIB += $(OCGDIR)/gameengine/blphys/sumo/$(DEBUG_DIR)libsumo.a
COMLIB += $(OCGDIR)/gameengine/blphys/dummy/$(DEBUG_DIR)libdummy.a
COMLIB += $(OCGDIR)/gameengine/ketsji/$(DEBUG_DIR)libketsji.a
COMLIB += $(OCGDIR)/gameengine/logic/$(DEBUG_DIR)liblogic.a
@@ -143,8 +134,6 @@ ifneq ($(NAN_NO_KETSJI),true)
COMLIB += $(OCGDIR)/gameengine/expression/$(DEBUG_DIR)libexpression.a
COMLIB += $(OCGDIR)/gameengine/scenegraph/$(DEBUG_DIR)libscenegraph.a
COMLIB += $(OCGDIR)/gameengine/videotex/$(DEBUG_DIR)libvideotex.a
-# COMLIB += $(OCGDIR)/sumo/$(DEBUG_DIR)libfuzzics.a
-# COMLIB += $(OCGDIR)/sumo/$(DEBUG_DIR)libsolid.a
COMLIB += $(NAN_MOTO)/lib/libmoto.a
COMLIB += $(NAN_SND_LIBS)
COMLIB += $(OCGDIR)/kernel/gen_system/$(DEBUG_DIR)libgen_system.a
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index a53b15673e2..a9e3d50211f 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -37,7 +37,6 @@ ADD_SUBDIRECTORY(imbuf/intern/cineon)
ADD_SUBDIRECTORY(gpu)
ADD_SUBDIRECTORY(makesdna)
ADD_SUBDIRECTORY(makesrna)
-ADD_SUBDIRECTORY(radiosity)
ADD_SUBDIRECTORY(readblenfile)
ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(blenfont)
diff --git a/source/blender/Makefile b/source/blender/Makefile
index 64eb1a2614b..31636f838c3 100644
--- a/source/blender/Makefile
+++ b/source/blender/Makefile
@@ -31,7 +31,7 @@
include nan_definitions.mk
DIRS = windowmanager editors blenloader readblenfile
-DIRS += avi imbuf render radiosity blenlib blenkernel blenpluginapi
+DIRS += avi imbuf render blenlib blenkernel blenpluginapi
DIRS += makesdna makesrna
DIRS += python nodes gpu
DIRS += blenfont
diff --git a/source/blender/SConscript b/source/blender/SConscript
index 691fbf9b494..a064850c170 100644
--- a/source/blender/SConscript
+++ b/source/blender/SConscript
@@ -13,7 +13,6 @@ SConscript(['avi/SConscript',
'imbuf/intern/cineon/SConscript',
'makesdna/SConscript',
'makesrna/SConscript',
- 'radiosity/SConscript',
'readblenfile/SConscript',
'render/SConscript',
'nodes/SConscript',
diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h
index 11dc1f41109..5c47eeabfe8 100644
--- a/source/blender/blenkernel/BKE_exotic.h
+++ b/source/blender/blenkernel/BKE_exotic.h
@@ -47,7 +47,6 @@ int BKE_read_exotic(struct Scene *scene, char *name);
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_particle.h b/source/blender/blenkernel/BKE_particle.h
index 4efd9a7f8ba..0ecd71fc4a3 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -217,6 +217,7 @@ char *psys_menu_string(struct Object *ob, int for_sb);
struct ParticleSystem *psys_get_current(struct Object *ob);
short psys_get_current_num(struct Object *ob);
+struct Object *psys_find_object(struct Scene *scene, struct ParticleSystem *psys);
//struct ParticleSystem *psys_get(struct Object *ob, int index);
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);
@@ -251,6 +252,7 @@ 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);
+int psys_count_autocache(struct Scene *scene, struct ParticleSettings *part);
void psys_flush_particle_settings(struct Scene *scene, struct ParticleSettings *part, int recalc);
void make_local_particlesettings(struct ParticleSettings *part);
@@ -290,10 +292,13 @@ void psys_get_reactor_target(struct Object *ob, struct ParticleSystem *psys, str
void psys_init_effectors(struct Scene *scene, struct Object *obsrc, struct Group *group, struct ParticleSystem *psys);
void psys_end_effectors(struct ParticleSystem *psys);
+void psys_get_pointcache_start_end(struct Scene *scene, struct ParticleSystem *psys, int *sfra, int *efra);
+
void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
/* ----------- functions needed only inside particlesystem ------------ */
/* particle.c */
+void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, int velocity);
void psys_key_to_object(struct Object *ob, struct ParticleKey *key, float imat[][4]);
//void psys_key_to_geometry(struct DerivedMesh *dm, struct ParticleData *pa, struct ParticleKey *key);
//void psys_key_from_geometry(struct DerivedMesh *dm, struct ParticleData *pa, struct ParticleKey *key);
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h
index 8ef3ff4d4b7..b79357edf36 100644
--- a/source/blender/blenkernel/BKE_pointcache.h
+++ b/source/blender/blenkernel/BKE_pointcache.h
@@ -31,6 +31,8 @@
#include "DNA_ID.h"
+#include "MEM_guardedalloc.h"
+
/* Point cache clearing option, for BKE_ptcache_id_clear, before
* and after are non inclusive (they wont remove the cfra) */
#define PTCACHE_CLEAR_ALL 0
@@ -42,6 +44,7 @@
#define PTCACHE_RESET_DEPSGRAPH 0
#define PTCACHE_RESET_BAKED 1
#define PTCACHE_RESET_OUTDATED 2
+#define PTCACHE_RESET_FREE 3
/* Add the blendfile name after blendcache_ */
#define PTCACHE_EXT ".bphys"
@@ -56,6 +59,11 @@
#define PTCACHE_TYPE_PARTICLES 1
#define PTCACHE_TYPE_CLOTH 2
+/* PTCache read return code */
+#define PTCACHE_READ_EXACT 1
+#define PTCACHE_READ_INTERPOLATED 2
+#define PTCACHE_READ_OLD 3
+
/* Structs */
struct Object;
struct Scene;
@@ -80,6 +88,41 @@ typedef struct PTCacheID {
struct PointCache *cache;
} PTCacheID;
+typedef struct PTCacheWriter {
+ struct PTCacheID *pid;
+ int cfra;
+ int totelem;
+
+ float *(*elem_ptr)(int index, void *calldata);
+ void *calldata;
+} PTCacheWriter;
+
+typedef struct PTCacheReader {
+ struct Scene *scene;
+ struct PTCacheID *pid;
+ float cfra;
+ int totelem;
+
+ void (*set_elem)(int index, void *calldata, float *data);
+ void (*interpolate_elem)(int index, void *calldata, float frs_sec, float cfra, int cfra1, int cfra2, float *data1, float *data2);
+ void *calldata;
+
+ int allow_interpolate;
+ int allow_old;
+ int *old_frame;
+} PTCacheReader;
+
+typedef struct PTCacheBaker {
+ struct Scene *scene;
+ int bake;
+ int render;
+ struct PTCacheID *pid;
+ int (*break_test)(void *data);
+ void *break_data;
+ void (*progressbar)(void *data, int num);
+ void *progresscontext;
+} PTCacheBaker;
+
/* Creating ID's */
void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb);
void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys);
@@ -93,9 +136,9 @@ void BKE_ptcache_remove(void);
/* ID specific functions */
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);
+int BKE_ptcache_id_reset(struct Scene *scene, PTCacheID *id, int mode);
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);
+int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode);
/* File reading/writing */
PTCacheFile *BKE_ptcache_file_open(PTCacheID *id, int mode, int cfra);
@@ -103,6 +146,10 @@ void BKE_ptcache_file_close(PTCacheFile *pf);
int BKE_ptcache_file_read_floats(PTCacheFile *pf, float *f, int tot);
int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot);
+/* General cache reading/writing */
+int BKE_ptcache_read_cache(PTCacheReader *reader);
+int BKE_ptcache_write_cache(PTCacheWriter *writer);
+
/* Continue physics */
void BKE_ptcache_set_continue_physics(struct Scene *scene, int enable);
int BKE_ptcache_get_continue_physics(void);
@@ -112,4 +159,9 @@ struct PointCache *BKE_ptcache_add(void);
void BKE_ptcache_free(struct PointCache *cache);
struct PointCache *BKE_ptcache_copy(struct PointCache *cache);
+/* Baking */
+void BKE_ptcache_autocache_all(struct Scene *scene);
+void BKE_ptcache_make_cache(struct PTCacheBaker* baker);
+void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid);
+
#endif
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 0bed2c095e2..f6c305b202d 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -131,7 +131,7 @@
#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0))
/* this weirdo pops up in two places ... */
-#if !defined(WIN32) && !defined(__BeOS)
+#if !defined(WIN32)
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@ -149,12 +149,6 @@
#define ID_NEW(a) if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid
#define FORM MAKE_ID('F','O','R','M')
-#define DDG1 MAKE_ID('3','D','G','1')
-#define DDG2 MAKE_ID('3','D','G','2')
-#define DDG3 MAKE_ID('3','D','G','3')
-#define DDG4 MAKE_ID('3','D','G','4')
-
-#define GOUR MAKE_ID('G','O','U','R')
#define BLEN MAKE_ID('B','L','E','N')
#define DER_ MAKE_ID('D','E','R','_')
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 5fc7d18689d..d3d21018c1c 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -221,7 +221,6 @@ static void clear_global(void)
{
// extern short winqueue_break; /* screen.c */
-// XXX freeAllRad();
fastshade_free_render(); /* lamps hang otherwise */
free_main(G.main); /* free all lib data */
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 8bb34bde122..b57b8b7a6da 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -1831,7 +1831,7 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime)
}
/* node was checked to have lasttime != curtime , and is of type ID_OB */
-static void flush_pointcache_reset(DagNode *node, int curtime, int reset)
+static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset)
{
DagAdjList *itA;
Object *ob;
@@ -1844,13 +1844,13 @@ static void flush_pointcache_reset(DagNode *node, int curtime, int reset)
ob= (Object*)(node->ob);
if(reset || (ob->recalc & OB_RECALC)) {
- if(BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH))
+ if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
- flush_pointcache_reset(itA->node, curtime, 1);
+ flush_pointcache_reset(scene, itA->node, curtime, 1);
}
else
- flush_pointcache_reset(itA->node, curtime, 0);
+ flush_pointcache_reset(scene, itA->node, curtime, 0);
}
}
}
@@ -1908,13 +1908,13 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
ob= (Object*)(itA->node->ob);
if(ob->recalc & OB_RECALC) {
- if(BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH))
+ if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
- flush_pointcache_reset(itA->node, lasttime, 1);
+ flush_pointcache_reset(sce, itA->node, lasttime, 1);
}
else
- flush_pointcache_reset(itA->node, lasttime, 0);
+ flush_pointcache_reset(sce, itA->node, lasttime, 0);
}
}
}
@@ -2132,7 +2132,7 @@ void DAG_object_flush_update(Scene *sce, Object *ob, short flag)
if(ob==NULL || sce->theDag==NULL) return;
ob->recalc |= flag;
- BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH);
+ BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
/* all users of this ob->data should be checked */
/* BUT! displists for curves are still only on cu */
@@ -2147,7 +2147,7 @@ void DAG_object_flush_update(Scene *sce, Object *ob, short flag)
for (obt=G.main->object.first; obt; obt= obt->id.next) {
if (obt != ob && obt->data==ob->data) {
obt->recalc |= OB_RECALC_DATA;
- BKE_ptcache_object_reset(obt, PTCACHE_RESET_DEPSGRAPH);
+ BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
}
}
}
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index 929d3f942dc..f15e1c24949 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -27,47 +27,7 @@
*
* - Blender Foundation
*
- * ***** END GPL LICENSE BLOCK *****
- *
- * eigen videoscape formaat:
- *
- *
- * lamp:
- * 3DG2
- aantal_lampen
-
- type
- spsi spbl
- r, g, b, energy
- locx, locy, locz
- vecx, vecy, vecz
-
-
- curve / nurbs:
- 3DG3
- 5 of 11 (curve of surf)
- aantal_nurbs
- extr1 extr2
-
- mat[0][0] mat[0][1] mat[0][2] mat[0][3]
- mat[1][0] mat[1][1] mat[1][2] mat[1][3]
- ...
-
- type
- pntsu, pntsv
- resolu, resolv
- orderu, orderv
- flagu, flagv
-
- (als type==nurb) x y z w
- x y z w
- ...
- (als type==bez) xyz xyz xyz h1 h2 h3
- xyz xyz xyz h1 h2 h3
- ...
- *
- *
- */
+ * ***** END GPL LICENSE BLOCK *****/
#include <ctype.h> /* isdigit, isspace */
@@ -482,385 +442,6 @@ static void read_stl_mesh_ascii(Scene *scene, char *str)
#undef STLREADLINE
#undef STLREADVERT
-static void read_videoscape_mesh(Scene *scene, char *str)
-{
- Object *ob;
- Mesh *me;
- MVert *mvert;
- MFace *mface;
- Material *ma;
- FILE *fp;
- float *vertdata, *vd, min[3], max[3], cent[3], ftemp;
- unsigned int color[32], col;
- int totcol, a, b, verts, tottria=0, totquad=0, totedge=0, poly, nr0, nr, first;
- int end;
- char s[50];
-
- fp= fopen(str, "rb");
- if(fp==NULL) {
- //XXX error("Can't read file");
- return;
- }
-
- fscanf(fp, "%40s", s);
-
- fscanf(fp, "%d\n", &verts);
- if(verts<=0) {
- fclose(fp);
- //XXX error("Read error");
- return;
- }
-
- if(verts>MESH_MAX_VERTS) {
- //XXX error("too many vertices");
- fclose(fp);
- return;
- }
-
- INIT_MINMAX(min, max);
- vd= vertdata= MEM_mallocN(sizeof(float)*3*verts, "videoscapelezer");
-
- for(a=0; a<verts; a++) {
- fscanf(fp, "%f %f %f", vd, vd+1, vd+2);
- DO_MINMAX(vd, min, max);
- vd+=3;
- }
-
- /* count faces and colors */
- for(a=0; a<32; a++) color[a]= 0;
- totcol= 0;
- end= 1;
- while(end>0) {
- end= fscanf(fp,"%d", &poly);
- if(end<=0) break;
-
- if(poly==3) tottria++;
- else if(poly==4) totquad++;
- else totedge+= poly;
-
- for(a=0;a<poly;a++) {
- end= fscanf(fp,"%d", &nr);
- if(end<=0) break;
- }
- if(end<=0) break;
-
- end= fscanf(fp,"%i\n", &col);
- col &= 0xF0F0F0;
- for(a=0; a<totcol; a++) {
- if(color[a]==col) break;
- }
- if(a>=totcol && totcol<32) {
- color[totcol]= col;
- totcol++;
- }
- }
-
- /* new object */
- ob= add_object(scene, OB_MESH);
- me= ob->data;
- me->totvert= verts;
- me->totface= totedge+tottria+totquad;
-
- me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC,
- NULL, me->totvert);
- me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC,
- NULL, me->totface);
-
- /* colors */
- if(totcol) {
- ob->mat= MEM_callocN(sizeof(void *)*totcol, "ob->mat");
- me->mat= MEM_callocN(sizeof(void *)*totcol, "me->mat");
- me->totcol= totcol;
- ob->totcol= (unsigned char) me->totcol;
- ob->actcol= 1;
- }
-
- /* materials */
- for(a=0; a<totcol; a++) {
- ma= G.main->mat.first;
- while(ma) {
- if(ma->mtex[0]==0) {
- col= rgb_to_cpack(ma->r, ma->g, ma->b);
- if(color[a]==col) {
- me->mat[a]= ma;
- ma->id.us++;
- break;
- }
- }
- ma= ma->id.next;
- }
- if(ma==0) {
- ma= add_material("ext");
- me->mat[a]= ma;
- cpack_to_rgb(color[a], cent, cent+1, cent+2);
- ma->r= cent[0];
- ma->g= cent[1];
- ma->b= cent[2];
- automatname(ma);
- }
- }
-
- /* verts */
-
- cent[0]= (min[0]+max[0])/2.0f;
- cent[1]= (min[1]+max[1])/2.0f;
- cent[2]= (min[2]+max[2])/2.0f;
- VECCOPY(ob->loc, cent);
-
- a= me->totvert;
- vd= vertdata;
- mvert= me->mvert;
- while(a--) {
- VecSubf(mvert->co, vd, cent);
- mvert++;
- vd+= 3;
- }
-
- /* faces */
- if(me->totface) {
- rewind(fp);
-
- fscanf(fp, "%40s", s);
- fscanf(fp, "%d\n", &verts);
- /* fake read */
- for(a=0;a<verts;a++) {
- fscanf(fp, "%f %f %f", &ftemp, &ftemp, &ftemp);
- }
-
- a= me->totface;
- mface= me->mface;
- while(a--) {
- end= fscanf(fp,"%d", &poly);
- if(end<=0) break;
-
- if(poly==3 || poly==4) {
- fscanf(fp,"%d", &nr);
- mface->v1= MIN2(nr, me->totvert-1);
- fscanf(fp,"%d", &nr);
- mface->v2= MIN2(nr, me->totvert-1);
- fscanf(fp,"%d", &nr);
- mface->v3= MIN2(nr, me->totvert-1);
- if(poly==4) {
- if( fscanf(fp,"%d", &nr) <=0 ) break;
- mface->v4= MIN2(nr, me->totvert-1);
- }
-
- test_index_face(mface, NULL, 0, poly);
-
- mface++;
- }
- else {
- if( fscanf(fp,"%d", &nr0) <=0) break;
- first= nr0;
- for(b=1; b<poly; b++) {
- end= fscanf(fp,"%d", &nr);
- if(end<=0) break;
- nr= MIN2(nr, me->totvert-1);
- mface->v1= nr;
- mface->v2= nr0;
- nr0= nr;
- mface++;
- a--;
- }
- mface->v1= first;
- mface->v2= nr;
- mface++;
- if(end<=0) break;
- }
- end= fscanf(fp,"%i", &col);
- col &= 0xF0F0F0;
- if(end<=0) break;
-
- for(b=0; b<totcol; b++) {
- if(color[b]==col) {
- (mface-1)->mat_nr= b;
- break;
- }
- }
- }
- }
-
- fclose(fp);
- MEM_freeN(vertdata);
-
- mesh_add_normals_flags(me);
- make_edges(me, 0);
-
- //XXX waitcursor(1);
-}
-
-static void read_videoscape_lamp(Scene *scene, char *str)
-{
- Object *ob;
- Lamp *la;
- FILE *fp;
- float vec[3], q1[4];
- int tot, val;
- char s[50];
-
- fp= fopen(str, "rb");
- if(fp==NULL) {
- //XXX error("Can't read file");
- return;
- }
-
- fscanf(fp, "%40s", s);
- fscanf(fp, "%d\n", &tot);
-
- while(tot--) {
- ob= add_object(scene, OB_LAMP);
- la= ob->data;
-
- fscanf(fp, "%d\n", &val);
- la->type= val;
- if(la->type==1) la->type= LA_SPOT;
- else if(la->type==2) la->type= LA_SUN;
-
- fscanf(fp, "%f %f\n", &la->spotsize, &la->spotblend);
-
- fscanf(fp, "%f %f %f %f\n", &la->r, &la->g, &la->b, &la->energy);
-
- fscanf(fp, "%f %f %f\n", ob->loc, ob->loc+1, ob->loc+2);
- val= fscanf(fp, "%f %f %f\n", vec, vec+1, vec+2);
- vectoquat(vec, 5, 2, q1);
- QuatToEul(q1, ob->rot);
-
- if(val<=0) break;
-
- }
- fclose(fp);
-}
-
-static void read_videoscape_nurbs(Scene *scene, char *str)
-{
- Object *ob;
- Curve *cu;
- Nurb *nu;
- BezTriple *bezt;
- BPoint *bp;
- FILE *fp;
- float tmat[4][4], omat[3][3], imat[3][3], mat[3][3];
- int a, tot, type, val;
- char s[50];
-
- fp= fopen(str, "rb");
- if(fp==NULL) {
- //XXX error("Can't read file");
- return;
- }
-
- fscanf(fp, "%40s", s);
- fscanf(fp, "%d\n", &type);
-
- if(type==5) ob= add_object(scene, OB_SURF);
- else ob= add_object(scene, OB_CURVE);
- cu= ob->data;
-
- fscanf(fp, "%d\n", &tot);
- fscanf(fp, "%d %d\n", &type, &val);
-
- cu->ext1= 0.002f*type;
- cu->ext2= 0.002f*val;
-
- for(a=0; a<4; a++) fscanf(fp, "%e %e %e %e\n", tmat[a], tmat[a]+1, tmat[a]+2, tmat[a]+3);
-
- VECCOPY(ob->loc, tmat[3]);
-
- Mat3CpyMat4(omat, tmat);
- Mat3ToEul(omat, ob->rot);
- EulToMat3(ob->rot, mat);
- Mat3Inv(imat, mat);
- Mat3MulMat3((float ( * )[3])tmat, imat, omat);
-
- while(tot--) {
- nu= (Nurb*)MEM_callocN(sizeof(Nurb),"nu from exotic");
- BLI_addtail(&cu->nurb, nu);
-
- fscanf(fp, "%d\n", &type);
- nu->type= type;
-
- fscanf(fp, "%d %d\n", &type, &val);
- nu->pntsu= type; nu->pntsv= val;
- fscanf(fp, "%d %d\n", &type, &val);
- nu->resolu= type; nu->resolv= val;
- fscanf(fp, "%d %d\n", &type, &val);
- nu->orderu= type; nu->orderv= val;
- fscanf(fp, "%d %d\n", &type, &val);
- nu->flagu= type; nu->flagv= val;
-
- if( (nu->type & 7)==CU_BEZIER) {
- a= nu->pntsu;
- nu->bezt= bezt= MEM_callocN(a*sizeof(BezTriple), "bezt from exotic");
- while(a--) {
- fscanf(fp, "%f %f %f ", bezt->vec[0], bezt->vec[0]+1, bezt->vec[0]+2);
- Mat4MulVecfl(tmat, bezt->vec[0]);
- fscanf(fp, "%f %f %f ", bezt->vec[1], bezt->vec[1]+1, bezt->vec[1]+2);
- Mat4MulVecfl(tmat, bezt->vec[1]);
- fscanf(fp, "%f %f %f ", bezt->vec[2], bezt->vec[2]+1, bezt->vec[2]+2);
- Mat4MulVecfl(tmat, bezt->vec[2]);
- fscanf(fp, "%d %d\n", &type, &val);
- bezt->h1= type;
- bezt->h2= val;
- bezt++;
- }
- }
- else {
- a= nu->pntsu*nu->pntsv;
- if(a) {
- nu->bp= bp= MEM_callocN(a*sizeof(BPoint), "bp from exotic");
- while(a--) {
- fscanf(fp, "%f %f %f %f\n", bp->vec, bp->vec+1, bp->vec+2, bp->vec+3);
- Mat4MulVecfl(tmat, bp->vec);
- bp++;
- }
-
- val= KNOTSU(nu);
- nu->knotsu= MEM_mallocN(sizeof(float)*val, "knots");
- for(a=0; a<val; a++) fscanf(fp, "%f\n", nu->knotsu+a);
-
- if(nu->pntsv>1) {
- val= KNOTSV(nu);
- nu->knotsv= MEM_mallocN(sizeof(float)*val, "knots");
- for(a=0; a<val; a++) fscanf(fp, "%f\n", nu->knotsv+a);
- }
- }
- else {
- BLI_remlink(&cu->nurb, nu);
- MEM_freeN(nu);
- }
- }
- }
- fclose(fp);
-}
-
-static void read_videoscape(Scene *scene, char *str)
-{
- int file, type;
- unsigned int val;
- unsigned short numlen;
- char name[FILE_MAXDIR+FILE_MAXFILE], head[FILE_MAXDIR+FILE_MAXFILE], tail[FILE_MAXFILE];
-
- strcpy(name, str);
-
- while( TRUE ) {
- file= open(name, O_BINARY|O_RDONLY);
- if(file<=0) break;
- else {
- read(file, &type, 4);
- close(file);
-
- 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);
- BLI_stringenc(name, head, tail, numlen, val + 1);
-
- }
-}
-
-
/* ***************** INVENTOR ******************* */
@@ -2204,16 +1785,7 @@ int BKE_read_exotic(Scene *scene, char *name)
if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) {
//XXX waitcursor(1);
-
- if(ELEM4(*s0, DDG1, DDG2, DDG3, DDG4)) {
- if(0) { // XXX obedit) {
- //XXX error("Unable to perform function in EditMode");
- } else {
- read_videoscape(scene, name);
- retval = 1;
- }
- }
- else if(strncmp(str, "#Inventor V1.0", 14)==0) {
+ if(strncmp(str, "#Inventor V1.0", 14)==0) {
if( strncmp(str+15, "ascii", 5)==0) {
read_inventor(scene, name, &lbase);
displist_to_objects(scene, &lbase);
@@ -2385,167 +1957,6 @@ void write_stl(Scene *scene, char *str)
//XXX waitcursor(0);
}
-static void write_videoscape_mesh(Scene *scene, Object *ob, char *str)
-{
- Mesh *me= ob->data;
- EditMesh *em = BKE_mesh_get_editmesh(me);
- Material *ma;
- MFace *mface;
- FILE *fp;
- EditVert *eve;
- EditFace *evl;
- unsigned int kleur[32];
- float co[3];
- int a;
- intptr_t tot;
- char *cp;
-
- if(ob && ob->type==OB_MESH);
- else {
- return;
- }
-
- kleur[0]= 0x00C0C0C0;
-
- cp= (char *)kleur;
- for(a=0; a<ob->totcol; a++, cp+=4) {
-
- ma= give_current_material(ob, a+1);
- if(ma) {
- cp[0]= (unsigned char) (255.0*ma->emit);
- cp[1]= (unsigned char) (255.0*ma->b);
- cp[2]= (unsigned char) (255.0*ma->g);
- cp[3]= (unsigned char) (255.0*ma->r);
- if(ENDIAN_ORDER==L_ENDIAN) SWITCH_INT(kleur[a]);
- }
- else kleur[a]= 0x00C0C0C0;
-
- if(a>30) break;
- }
-
- fp= fopen(str, "wb");
- if(fp==NULL) return;
-
- fprintf(fp,"3DG1\n");
-
- if(em) {
-
- fprintf(fp, "%d\n", em->totvert);
-
- tot= 0;
- eve= em->verts.first;
- while(eve) {
- VECCOPY(co, eve->co);
- Mat4MulVecfl(ob->obmat, co);
- fprintf(fp, "%f %f %f\n", co[0], co[1], co[2] );
- eve->tmp.l = tot;
- tot++;
- eve= eve->next;
- }
- evl= em->faces.first;
- while(evl) {
-
- if(evl->v4==0) {
- fprintf(fp, "3 %ld %ld %ld 0x%x\n",
- (intptr_t) evl->v1->tmp.l,
- (intptr_t) evl->v2->tmp.l,
- (intptr_t) evl->v3->tmp.l,
- kleur[evl->mat_nr]);
- }
- else {
- fprintf(fp, "4 %ld %ld %ld %ld 0x%x\n",
- (intptr_t) evl->v1->tmp.l,
- (intptr_t) evl->v2->tmp.l,
- (intptr_t) evl->v3->tmp.l,
- (intptr_t) evl->v4->tmp.l,
- kleur[evl->mat_nr]);
- }
- evl= evl->next;
- }
- }
- else {
- DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
-
- me= ob->data;
-
- fprintf(fp, "%d\n", me->totvert);
-
- mface= me->mface;
- for(a=0; a<me->totvert; a++) {
- dm->getVertCo(dm, a, co);
- Mat4MulVecfl(ob->obmat, co);
- fprintf(fp, "%f %f %f\n", co[0], co[1], co[2] );
- }
- for(a=0; a<me->totface; a++, mface++) {
- if(mface->v4==0) {
- fprintf(fp, "3 %d %d %d 0x%x\n", mface->v1, mface->v2, mface->v3, kleur[(int)mface->mat_nr]);
- }
- else {
- fprintf(fp, "4 %d %d %d %d 0x%x\n", mface->v1, mface->v2, mface->v3, mface->v4, kleur[(int)mface->mat_nr]);
- }
- }
-
- dm->release(dm);
- }
-
- fclose(fp);
-
- if (em) BKE_mesh_end_editmesh(me, em);
-
-}
-
-
-void write_videoscape(Scene *scene, char *str)
-{
- Base *base;
- int file, val, lampdone=0;
- unsigned short numlen;
- char head[FILE_MAXFILE], tail[FILE_MAXFILE];
-
- if(BLI_testextensie(str,".trace")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
- if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
- if(BLI_testextensie(str,".obj")==0) strcat(str, ".obj");
-
- file= open(str,O_BINARY|O_RDONLY);
- close(file);
- //XXX saveover()
- // if(file>-1) if(!during_script() && saveover(str)==0) return;
-
- strcpy(temp_dir, str);
-
- base= scene->base.first;
- while(base) {
- if((base->flag & SELECT) && (base->lay & scene->lay)) {
- if(base->object->type==OB_MESH) {
- write_videoscape_mesh(scene, base->object, str);
- val = BLI_stringdec(str, head, tail, &numlen);
- BLI_stringenc(str, head, tail, numlen, val + 1);
- }
- else if(base->object->type==OB_CURVE || base->object->type==OB_SURF) {
- /* write_videoscape_nurbs(base->object, str); */
- /* val = stringdec(str, head, tail, &numlen); */
- /* stringenc(str, head, tail, numlen, val + 1); */
- }
- else if(lampdone==0 && base->object->type==OB_LAMP) {
- /* lampdone= 1; */
- /* write_videoscape_lamps(str); */
- /* val = stringdec(str, head, tail, &numlen); */
- /* stringenc(str, head, tail, numlen, val + 1); */
- }
- }
- base= base->next;
- }
-
-
- /* remove when higher numbers exist */
- while(remove(str)==0) {
-
- val = BLI_stringdec(str, head, tail, &numlen);
- BLI_stringenc(str, head, tail, numlen, val + 1);
- }
-}
-
/* ******************************* WRITE VRML ***************************** */
static void replace_chars(char *str1, char *str2)
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index b1387281cf5..5def910ddef 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -1270,8 +1270,10 @@ void multires_free(Multires *mr)
if(lvl) {
CustomData_free(&mr->vdata, lvl->totvert);
CustomData_free(&mr->fdata, lvl->totface);
- MEM_freeN(mr->edge_flags);
- MEM_freeN(mr->edge_creases);
+ if(mr->edge_flags)
+ MEM_freeN(mr->edge_flags);
+ if(mr->edge_creases)
+ MEM_freeN(mr->edge_creases);
}
while(lvl) {
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 34e69b2d736..5b3720cd6b0 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -222,6 +222,45 @@ short psys_get_current_num(Object *ob)
return i;
}
+Object *psys_find_object(Scene *scene, ParticleSystem *psys)
+{
+ Base *base = scene->base.first;
+ ParticleSystem *tpsys;
+
+ for(base = scene->base.first; base; base = base->next) {
+ for(tpsys = base->object->particlesystem.first; psys; psys=psys->next) {
+ if(tpsys == psys)
+ return base->object;
+ }
+ }
+
+ return NULL;
+}
+int psys_count_autocache(Scene *scene, ParticleSettings *part)
+{
+ Base *base = scene->base.first;
+ ParticleSystem *psys;
+ PTCacheID pid;
+ int autocache_count= 0;
+
+ for(base = scene->base.first; base; base = base->next) {
+ for(psys = base->object->particlesystem.first; psys; psys=psys->next) {
+ if(part && psys->part != part)
+ continue;
+
+ BKE_ptcache_id_from_particles(&pid, base->object, psys);
+
+ if((psys->pointcache->flag & PTCACHE_BAKED)
+ || (psys->pointcache->flag & PTCACHE_AUTOCACHE)==0)
+ continue;
+
+ if((psys->pointcache->flag & PTCACHE_OUTDATED)
+ || BKE_ptcache_id_exist(&pid, CFRA)==0)
+ autocache_count++;
+ }
+ }
+ return autocache_count;
+}
/* change object's active particle system */
void psys_change_act(void *ob_v, void *act_v)
{
@@ -864,7 +903,7 @@ static void weighted_particle_vector(float *v1, float *v2, float *v3, float *v4,
vec[1]= weights[0]*v1[1] + weights[1]*v2[1] + weights[2]*v3[1] + weights[3]*v4[1];
vec[2]= weights[0]*v1[2] + weights[1]*v2[2] + weights[2]*v3[2] + weights[3]*v4[2];
}
-static void interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, int velocity)
+void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, int velocity)
{
float t[4];
@@ -2569,7 +2608,7 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
}
/* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/
- interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
+ psys_interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
: ((psys->part->flag & PART_HAIR_BSPLINE) ? KEY_BSPLINE : KEY_CARDINAL)
,keys, keytime, &result, 0);
@@ -3062,7 +3101,6 @@ void make_local_particlesettings(ParticleSettings *part)
}
}
}
-
void psys_flush_particle_settings(Scene *scene, ParticleSettings *part, int recalc)
{
Base *base = scene->base.first;
@@ -3495,7 +3533,7 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
QuatInterpol(state->rot,keys[1].rot,keys[2].rot,keytime);
}
- interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
+ psys_interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
: ((psys->part->flag & PART_HAIR_BSPLINE) ? KEY_BSPLINE : KEY_CARDINAL)
,keys, keytime, state, 1);
@@ -3776,7 +3814,7 @@ int psys_get_particle_state(struct Scene *scene, Object *ob, ParticleSystem *psy
VecMulf(keys[1].vel, dfra / frs_sec);
VecMulf(keys[2].vel, dfra / frs_sec);
- interpolate_particle(-1, keys, keytime, state, 1);
+ psys_interpolate_particle(-1, keys, keytime, state, 1);
/* convert back to real velocity */
VecMulf(state->vel, frs_sec / dfra);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 52f13eeadb8..fc6413849d1 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -104,7 +104,8 @@ static int get_current_display_percentage(ParticleSystem *psys)
{
ParticleSettings *part=psys->part;
- if(psys->renderdata || (part->child_nbr && part->childtype))
+ if(psys->renderdata || (part->child_nbr && part->childtype)
+ || (psys->pointcache->flag & PTCACHE_BAKING))
return 100;
if(part->phystype==PART_PHYS_KEYED){
@@ -2195,57 +2196,80 @@ void psys_get_reactor_target(Object *ob, ParticleSystem *psys, Object **target_o
/************************************************/
/* Point Cache */
/************************************************/
-
-static void write_particles_to_cache(Object *ob, ParticleSystem *psys, int cfra)
+void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
{
- PTCacheID pid;
- PTCacheFile *pf;
- ParticleData *pa;
- int i, totpart= psys->totpart;
+ ParticleSettings *part = psys->part;
- if(totpart == 0)
- return;
+ *sfra = MAX2(1, (int)part->sta);
+ *efra = MIN2((int)(part->end + part->lifetime + 1.0), scene->r.efra);
+}
+static float *particle_state_ptr(int index, ParticleSystem *psys)
+{
+ return (float *)(&(psys->particles+index)->state);
+}
+static void particle_read_state(int index, ParticleSystem *psys, float *data)
+{
+ ParticleData *pa = psys->particles + index;
+ ParticleKey *key = (ParticleKey *)data;
- BKE_ptcache_id_from_particles(&pid, ob, psys);
- pf= BKE_ptcache_file_open(&pid, PTCACHE_FILE_WRITE, cfra);
- if(!pf)
- return;
+ if(key->time > pa->state.time)
+ copy_particle_key(&pa->prev_state, &pa->state, 1);
- /* assuming struct consists of tightly packed floats */
- for(i=0, pa=psys->particles; i<totpart; i++, pa++)
- BKE_ptcache_file_write_floats(pf, (float*)&pa->state, sizeof(ParticleKey)/sizeof(float));
-
- BKE_ptcache_file_close(pf);
+ copy_particle_key(&pa->state, key, 1);
}
+static void particle_cache_interpolate(int index, ParticleSystem *psys, float frs_sec, float cfra, int cfra1, int cfra2, float *data1, float *data2)
+{
+ ParticleData *pa = psys->particles + index;
+ ParticleKey keys[4];
+ float dfra;
+
+ keys[1] = *((ParticleKey*)data1);
+ keys[2] = *((ParticleKey*)data2);
+
+ dfra = keys[2].time - keys[1].time;
-static int get_particles_from_cache(Object *ob, ParticleSystem *psys, int cfra)
+ VecMulf(keys[1].vel, dfra / frs_sec);
+ VecMulf(keys[2].vel, dfra / frs_sec);
+
+ psys_interpolate_particle(-1, keys, (keys[1].time - cfra) / dfra, &pa->state, 1);
+
+ VecMulf(pa->state.vel, frs_sec / dfra);
+}
+static void write_particles_to_cache(Object *ob, ParticleSystem *psys, int cfra)
{
+ PTCacheWriter writer;
PTCacheID pid;
- PTCacheFile *pf;
- ParticleData *pa;
- int i, totpart= psys->totpart;
-
- if(totpart == 0)
- return 0;
BKE_ptcache_id_from_particles(&pid, ob, psys);
- pf= BKE_ptcache_file_open(&pid, PTCACHE_FILE_READ, cfra);
- if(!pf)
- return 0;
- /* assuming struct consists of tightly packed floats */
- for(i=0, pa=psys->particles; i<totpart; i++, pa++) {
- if(cfra!=pa->state.time)
- copy_particle_key(&pa->prev_state,&pa->state,1);
- if(!BKE_ptcache_file_read_floats(pf, (float*)&pa->state, sizeof(ParticleKey)/sizeof(float))) {
- BKE_ptcache_file_close(pf);
- return 0;
- }
- }
+ writer.calldata = psys;
+ writer.cfra = cfra;
+ writer.elem_ptr = particle_state_ptr;
+ writer.pid = &pid;
+ writer.totelem = psys->totpart;
- BKE_ptcache_file_close(pf);
+ BKE_ptcache_write_cache(&writer);
+}
- return 1;
+static int get_particles_from_cache(Scene *scene, Object *ob, ParticleSystem *psys, float cfra, int allow_interpolate, int allow_old, int *old_frame)
+{
+ PTCacheReader reader;
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+
+ reader.allow_interpolate = allow_interpolate;
+ reader.allow_old = allow_old;
+ reader.calldata = psys;
+ reader.cfra = cfra;
+ reader.interpolate_elem = particle_cache_interpolate;
+ reader.old_frame = old_frame;
+ reader.pid = &pid;
+ reader.scene = scene;
+ reader.set_elem = particle_read_state;
+ reader.totelem = psys->totpart;
+
+ return BKE_ptcache_read_cache(&reader);
}
/************************************************/
@@ -4085,7 +4109,7 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
/* main loop: calculate physics for all particles */
for(p=0, pa=psys->particles; p<totpart; p++,pa++){
- if(pa->flag & PARS_UNEXIST) continue;
+ if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue;
copy_particle_key(&pa->prev_state,&pa->state,1);
@@ -4110,25 +4134,26 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic
if(pa->alive==PARS_UNBORN
|| pa->alive==PARS_KILLED
|| ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED)
- || birthtime >= cfra){
+ || birthtime >= psys->cfra){
reset_particle(scene, pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
}
pa_dfra = dfra;
pa_dtime = dtime;
- if(birthtime <= cfra && birthtime >= psys->cfra){
+
+ if(dietime <= cfra && psys->cfra < dietime){
+ /* particle dies some time between this and last step */
+ pa_dfra = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra);
+ pa_dtime = pa_dfra * timestep;
+ pa->alive = PARS_DYING;
+ }
+ else if(birthtime <= cfra && birthtime >= psys->cfra){
/* particle is born some time between this and last step*/
pa->alive = PARS_ALIVE;
pa_dfra = cfra - birthtime;
pa_dtime = pa_dfra*timestep;
}
- else if(dietime <= cfra && psys->cfra < dietime){
- /* particle dies some time between this and last step */
- pa_dfra = dietime - psys->cfra;
- pa_dtime = pa_dfra * timestep;
- pa->alive = PARS_DYING;
- }
else if(dietime < cfra){
/* nothing to be done when particle is dead */
}
@@ -4520,7 +4545,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
int totpart, oldtotpart, totchild, oldtotchild, p;
float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0;
int init= 0, distr= 0, alloc= 0, usecache= 0, only_children_changed= 0;
- int framenr, framedelta, startframe, endframe;
+ int framenr, framedelta, startframe, endframe, old_framenr;
part= psys->part;
cache= psys->pointcache;
@@ -4528,6 +4553,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
framenr= (int)scene->r.cfra;
framedelta= framenr - cache->simframe;
+ /* set suitable cache range automatically */
+ if((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0)
+ psys_get_pointcache_start_end(scene, psys, &cache->startframe, &cache->endframe);
+
BKE_ptcache_id_from_particles(&pid, ob, psys);
BKE_ptcache_id_time(&pid, scene, 0.0f, &startframe, &endframe, NULL);
@@ -4600,9 +4629,13 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
if(init) {
if(distr) {
- if(alloc)
+ if(alloc) {
realloc_particles(ob, psys, totpart);
+ if(usecache)
+ BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
+ }
+
distribute_particles(scene, ob, psys, part->from);
if((psys->part->type == PART_HAIR) && !(psys->flag & PSYS_HAIR_DONE))
@@ -4616,9 +4649,11 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
free_keyed_keys(psys);
initialize_all_particles(ob, psys, psmd);
+
- if(alloc)
+ if(alloc) {
reset_all_particles(scene, ob, psys, psmd, 0.0, cfra, oldtotpart);
+ }
}
/* flag for possible explode modifiers after this system */
@@ -4627,25 +4662,47 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
/* try to read from the cache */
if(usecache) {
- if(get_particles_from_cache(ob, psys, framenr)) {
- if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
- psys_count_keyed_targets(ob,psys);
- set_keyed_keys(scene, ob, psys);
- }
+ int result = get_particles_from_cache(scene, ob, psys, (float)framenr, 0, 1, &old_framenr);
+
+ if(result == PTCACHE_READ_EXACT) {
+ //if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
+ // psys_count_keyed_targets(ob,psys);
+ // set_keyed_keys(scene, ob, psys);
+ //}
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(scene, ob, psmd, psys, framenr);
- }
+ //if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
+ // psys_update_path_cache(scene, ob, psmd, psys, framenr);
+ //}
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
+ if(cache->flag & PTCACHE_OUTDATED)
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE);
+
return;
}
+ else if((cache->flag & PTCACHE_AUTOCACHE)==0 && result==PTCACHE_READ_OLD) {
+ /* clear cache after current frame */
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE);
+
+ /* set old cfra */
+ psys->cfra = (float)old_framenr;
+
+ for(p=0, pa=psys->particles; p<totpart; p++, pa++) {
+ /* update alive status */
+ if(pa->time > psys->cfra)
+ pa->alive = PARS_UNBORN;
+ else if(pa->dietime <= psys->cfra)
+ pa->alive = PARS_DEAD;
+ else
+ pa->alive = PARS_ALIVE;
+ }
+ }
else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) {
psys_reset(psys, PSYS_RESET_CACHE_MISS);
psys->cfra=cfra;
@@ -4653,8 +4710,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
return;
}
- if(framenr != startframe && framedelta != 1) {
- psys_reset(psys, PSYS_RESET_CACHE_MISS);
+ if(framenr != startframe && framedelta != 1 && cache->flag & PTCACHE_AUTOCACHE) {
+ //psys_reset(psys, PSYS_RESET_CACHE_MISS);
+ /* make sure cache is recalculated */
+ BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_FRAME, (int)cfra);
psys->cfra = cfra;
psys->recalc = 0;
return;
@@ -4663,10 +4722,11 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
else {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
+ cache->last_exact= 0;
}
/* if on second frame, write cache for first frame */
- if(usecache && framenr == startframe+1)
+ if(usecache && psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
write_particles_to_cache(ob, psys, startframe);
if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED)
@@ -4768,8 +4828,7 @@ static void psys_to_softbody(Scene *scene, Object *ob, ParticleSystem *psys)
static int hair_needs_recalc(ParticleSystem *psys)
{
if((psys->flag & PSYS_EDITED)==0 &&
- ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_REDO)) {
- psys->recalc &= ~PSYS_RECALC_REDO;
+ ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET)) {
return 1;
}
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index b00755f7135..f59336518d7 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -51,9 +51,11 @@
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
+#include "BKE_scene.h"
#include "BKE_softbody.h"
#include "BKE_utildefines.h"
+#include "BLI_blenlib.h"
/* needed for directory lookup */
#ifndef WIN32
@@ -213,21 +215,29 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho
filename[0] = '\0';
newname = filename;
- /*if (!G.relbase_valid) return 0; *//* save blend file before using pointcache */
+ if (!G.relbase_valid) return 0; /* save blend file before using disk pointcache */
/* start with temp dir */
if (do_path) {
len = ptcache_path(pid, filename);
newname += len;
}
- idname = (pid->ob->id.name+2);
- /* convert chars to hex so they are always a valid filename */
- while('\0' != *idname) {
- snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++));
- newname+=2;
- len += 2;
+ if(strcmp(pid->cache->name, "")==0) {
+ idname = (pid->ob->id.name+2);
+ /* convert chars to hex so they are always a valid filename */
+ while('\0' != *idname) {
+ snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++));
+ newname+=2;
+ len += 2;
+ }
}
-
+ else {
+ int temp = strlen(pid->cache->name);
+ strcpy(newname, pid->cache->name);
+ newname+=temp;
+ len += temp;
+ }
+
if (do_ext) {
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
len += 16;
@@ -247,7 +257,7 @@ PTCacheFile *BKE_ptcache_file_open(PTCacheID *pid, int mode, int cfra)
if(pid->ob->id.lib && mode == PTCACHE_FILE_WRITE)
return NULL;
- /*if (!G.relbase_valid) return NULL; *//* save blend file before using pointcache */
+ if (!G.relbase_valid) return NULL; /* save blend file before using disk pointcache */
BKE_ptcache_id_filename(pid, filename, cfra, 1, 1);
@@ -286,6 +296,323 @@ int BKE_ptcache_file_write_floats(PTCacheFile *pf, float *f, int tot)
return (fwrite(f, sizeof(float), tot, pf->fp) == tot);
}
+static int ptcache_pid_elemsize(PTCacheID *pid)
+{
+ if(pid->type==PTCACHE_TYPE_SOFTBODY)
+ return 0; // TODO
+ else if(pid->type==PTCACHE_TYPE_PARTICLES)
+ return sizeof(ParticleKey);
+ else if(pid->type==PTCACHE_TYPE_CLOTH)
+ return 0; // TODO
+
+ return 0;
+}
+static int ptcache_pid_totelem(PTCacheID *pid)
+{
+ if(pid->type==PTCACHE_TYPE_SOFTBODY)
+ return 0; // TODO
+ else if(pid->type==PTCACHE_TYPE_PARTICLES) {
+ ParticleSystem *psys = pid->data;
+ return psys->totpart;
+ }
+ else if(pid->type==PTCACHE_TYPE_CLOTH)
+ return 0; // TODO
+
+ return 0;
+}
+
+void ptcache_update_info(PTCacheID *pid)
+{
+ PointCache *cache = pid->cache;
+ int totframes = 0;
+
+ if(cache->flag & PTCACHE_DISK_CACHE) {
+ int cfra = cache->startframe;
+
+ for(; cfra<=cache->endframe; cfra++) {
+ if(BKE_ptcache_id_exist(pid, cfra))
+ totframes++;
+ }
+
+ sprintf(cache->info, "%i frames on disk.", totframes);
+ }
+ else {
+ PTCacheMem *pm = cache->mem_cache.first;
+ float framesize = 0.0f, bytes = 0.0f;
+ int mb;
+
+ if(pm)
+ framesize = (float)ptcache_pid_elemsize(pid) * (float)pm->totpoint;
+
+ for(; pm; pm=pm->next)
+ totframes++;
+
+ bytes = totframes * framesize;
+
+ mb = (bytes > 1024.0f * 1024.0f);
+
+ sprintf(cache->info, "%i frames in memory (%.1f %s).",
+ totframes,
+ bytes / (mb ? 1024.0f * 1024.0f : 1024.0f),
+ mb ? "Mb" : "kb");
+ }
+}
+/* reads cache from disk or memory */
+/* possible to get old or interpolated result */
+int BKE_ptcache_read_cache(PTCacheReader *reader)
+{
+ PTCacheID *pid = reader->pid;
+ PTCacheFile *pf=NULL, *pf2=NULL;
+ PTCacheMem *pm=NULL, *pm2=NULL;
+ int totelem = reader->totelem;
+ float cfra = reader->cfra;
+ int cfrai = (int)cfra;
+ int elemsize = ptcache_pid_elemsize(pid);
+ int i, incr = elemsize / sizeof(float);
+ float frs_sec = reader->scene->r.frs_sec;
+
+ if(totelem == 0)
+ return 0;
+
+ /* first check if we have the actual frame cached */
+ if(cfra == (float)cfrai) {
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai);
+ }
+ else {
+ pm = pid->cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ if(pm->frame == cfrai)
+ break;
+ }
+ }
+ }
+
+ /* if found, use exact frame */
+ if(pf || pm) {
+ float *data;
+
+ if(pm)
+ data = pm->data;
+ else
+ data = MEM_callocN(elemsize, "pointcache read data");
+
+ for(i=0; i<totelem; i++) {
+ if(pf) {
+ if(!BKE_ptcache_file_read_floats(pf, data, incr)) {
+ BKE_ptcache_file_close(pf);
+ MEM_freeN(data);
+ return 0;
+ }
+
+ reader->set_elem(i, reader->calldata, data);
+ }
+ else {
+ reader->set_elem(i, reader->calldata, data);
+ data += incr;
+ }
+ }
+
+ if(pf) {
+ BKE_ptcache_file_close(pf);
+ MEM_freeN(data);
+ }
+
+ return PTCACHE_READ_EXACT;
+ }
+ /* no exact cache frame found so try to find cached frames around cfra */
+ if(reader->allow_interpolate || reader->allow_old) {
+ int cfra1, cfra2;
+
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ pf=NULL;
+ while(cfrai > pid->cache->startframe && !pf) {
+ cfrai--;
+ pf= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai);
+ cfra1 = cfrai;
+ }
+
+ *(reader->old_frame) = cfrai;
+
+ cfrai = (int)cfra;
+ while(cfrai < pid->cache->endframe && !pf2) {
+ cfrai++;
+ pf2= BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai);
+ cfra2 = cfrai;
+ }
+ }
+ else if(pid->cache->mem_cache.first){
+ pm = pid->cache->mem_cache.first;
+
+ while(pm->next && pm->next->frame < cfra)
+ pm= pm->next;
+
+ if(pm) {
+ *(reader->old_frame) = pm->frame;
+ cfra1 = pm->frame;
+ }
+
+ pm2 = pid->cache->mem_cache.last;
+
+ while(pm2->prev && pm2->frame > cfra)
+ pm2= pm2->prev;
+
+ if(pm2)
+ cfra2 = pm2->frame;
+ }
+
+ if(reader->allow_interpolate && ((pf && pf2) || (pm && pm2))) {
+ /* interpolate from nearest frames */
+ float *data1, *data2;
+
+ if(pm) {
+ data1 = pm->data;
+ data2 = pm2->data;
+ }
+ else {
+ data1 = MEM_callocN(elemsize, "pointcache read data1");
+ data2 = MEM_callocN(elemsize, "pointcache read data2");
+ }
+
+ for(i=0; i<totelem; i++) {
+ if(pf && pf2) {
+ if(!BKE_ptcache_file_read_floats(pf, data1, incr)) {
+ BKE_ptcache_file_close(pf);
+ BKE_ptcache_file_close(pf2);
+ MEM_freeN(data1);
+ MEM_freeN(data2);
+ return 0;
+ }
+ if(!BKE_ptcache_file_read_floats(pf2, data2, incr)) {
+ BKE_ptcache_file_close(pf);
+ BKE_ptcache_file_close(pf2);
+ MEM_freeN(data1);
+ MEM_freeN(data2);
+ return 0;
+ }
+ reader->interpolate_elem(i, reader->calldata, frs_sec, cfra, cfra1, cfra2, data1, data2);
+ }
+ else {
+ reader->interpolate_elem(i, reader->calldata, frs_sec, cfra, cfra1, cfra2, data1, data2);
+ data1 += incr;
+ data2 += incr;
+ }
+ }
+
+ if(pf) {
+ BKE_ptcache_file_close(pf);
+ BKE_ptcache_file_close(pf2);
+ MEM_freeN(data1);
+ MEM_freeN(data2);
+ }
+
+ return PTCACHE_READ_INTERPOLATED;
+ }
+ else if(reader->allow_old && (pf || pm)) {
+ /* use last valid cache frame */
+ float *data;
+
+ if(pm)
+ data = pm->data;
+ else
+ data = MEM_callocN(elemsize, "pointcache read data");
+
+ for(i=0; i<totelem; i++) {
+ if(pf) {
+ if(!BKE_ptcache_file_read_floats(pf, data, incr)) {
+ BKE_ptcache_file_close(pf);
+ if(pf2)
+ BKE_ptcache_file_close(pf2);
+ return 0;
+ }
+ reader->set_elem(i, reader->calldata, data);
+ }
+ else {
+ reader->set_elem(i, reader->calldata, data);
+ data += incr;
+ }
+ }
+
+ if(pf) {
+ BKE_ptcache_file_close(pf);
+ MEM_freeN(data);
+ }
+ if(pf2)
+ BKE_ptcache_file_close(pf2);
+
+ return PTCACHE_READ_OLD;
+ }
+ }
+
+ if(pf)
+ BKE_ptcache_file_close(pf);
+ if(pf2)
+ BKE_ptcache_file_close(pf2);
+
+ return 0;
+}
+/* writes cache to disk or memory */
+int BKE_ptcache_write_cache(PTCacheWriter *writer)
+{
+ PointCache *cache = writer->pid->cache;
+ PTCacheFile *pf= NULL;
+ int elemsize = ptcache_pid_elemsize(writer->pid);
+ int i, incr = elemsize / sizeof(float);
+
+ if(writer->totelem == 0 || writer->cfra <= 0)
+ return 0;
+
+ if(cache->flag & PTCACHE_DISK_CACHE) {
+ pf = BKE_ptcache_file_open(writer->pid, PTCACHE_FILE_WRITE, writer->cfra);
+ if(!pf)
+ return 0;
+
+ for(i=0; i<writer->totelem; i++)
+ BKE_ptcache_file_write_floats(pf, writer->elem_ptr(i, writer->calldata), incr);
+ }
+ else {
+ PTCacheMem *pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
+ PTCacheMem *pm2;
+ float *pmdata;
+
+ pm->data = MEM_callocN(elemsize * writer->totelem, "Pointcache mem data");
+ pmdata = pm->data;
+
+ for(i=0; i<writer->totelem; i++, pmdata+=incr)
+ memcpy(pmdata, writer->elem_ptr(i, writer->calldata), elemsize);
+
+ pm->frame = writer->cfra;
+ pm->totpoint = writer->totelem;
+
+ /* find add location */
+ pm2 = cache->mem_cache.first;
+ if(!pm2)
+ BLI_addtail(&cache->mem_cache, pm);
+ else if(pm2->frame == writer->cfra) {
+ /* overwrite same frame */
+ MEM_freeN(pm2->data);
+ pm2->data = pm->data;
+ MEM_freeN(pm);
+ }
+ else {
+ while(pm2->next && pm2->next->frame < writer->cfra)
+ pm2 = pm2->next;
+
+ BLI_insertlinkafter(&cache->mem_cache, pm2, pm);
+ }
+ }
+
+ if(writer->cfra - cache->last_exact == 1)
+ cache->last_exact = writer->cfra;
+
+ if(pf)
+ BKE_ptcache_file_close(pf);
+
+ ptcache_update_info(writer->pid);
+
+ return 1;
+}
/* youll need to close yourself after!
* mode - PTCACHE_CLEAR_ALL,
@@ -317,62 +644,116 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra)
case PTCACHE_CLEAR_ALL:
case PTCACHE_CLEAR_BEFORE:
case PTCACHE_CLEAR_AFTER:
- ptcache_path(pid, path);
-
- len = BKE_ptcache_id_filename(pid, filename, cfra, 0, 0); /* no path */
-
- dir = opendir(path);
- if (dir==NULL)
- return;
-
- snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
-
- while ((de = readdir(dir)) != NULL) {
- if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
- if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
- if (mode == PTCACHE_CLEAR_ALL) {
- BLI_join_dirfile(path_full, path, de->d_name);
- BLI_delete(path_full, 0, 0);
- } else {
- /* read the number of the file */
- int frame, len2 = strlen(de->d_name);
- char num[7];
-
- if (len2 > 15) { /* could crash if trying to copy a string out of this range*/
- BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
- frame = atoi(num);
-
- if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
- (mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) {
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ ptcache_path(pid, path);
+
+ len = BKE_ptcache_id_filename(pid, filename, cfra, 0, 0); /* no path */
+
+ dir = opendir(path);
+ if (dir==NULL)
+ return;
+
+ snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index);
+
+ while ((de = readdir(dir)) != NULL) {
+ if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
+ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
+ if (mode == PTCACHE_CLEAR_ALL) {
+ pid->cache->last_exact = 0;
+ BLI_join_dirfile(path_full, path, de->d_name);
+ BLI_delete(path_full, 0, 0);
+ } else {
+ /* read the number of the file */
+ int frame, len2 = strlen(de->d_name);
+ char num[7];
+
+ if (len2 > 15) { /* could crash if trying to copy a string out of this range*/
+ BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
+ frame = atoi(num);
- BLI_join_dirfile(path_full, path, de->d_name);
- BLI_delete(path_full, 0, 0);
+ if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
+ (mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) {
+
+ BLI_join_dirfile(path_full, path, de->d_name);
+ BLI_delete(path_full, 0, 0);
+ }
}
}
}
}
}
+ closedir(dir);
+ }
+ else {
+ PTCacheMem *pm= pid->cache->mem_cache.first;
+ PTCacheMem *link= NULL;
+
+ if(mode == PTCACHE_CLEAR_ALL) {
+ pid->cache->last_exact = 0;
+ for(; pm; pm=pm->next)
+ MEM_freeN(pm->data);
+ BLI_freelistN(&pid->cache->mem_cache);
+ } else {
+ while(pm) {
+ if((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) ||
+ (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) {
+ link = pm;
+ pm = pm->next;
+ MEM_freeN(link->data);
+ BLI_freelinkN(&pid->cache->mem_cache, link);
+ }
+ else
+ pm = pm->next;
+ }
+ }
}
- closedir(dir);
break;
case PTCACHE_CLEAR_FRAME:
- len = BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); /* no path */
- BLI_delete(filename, 0, 0);
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ if(BKE_ptcache_id_exist(pid, cfra)) {
+ BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); /* no path */
+ BLI_delete(filename, 0, 0);
+ }
+ }
+ else {
+ PTCacheMem *pm = pid->cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ if(pm->frame == cfra) {
+ MEM_freeN(pm->data);
+ BLI_freelinkN(&pid->cache->mem_cache, pm);
+ break;
+ }
+ }
+ }
break;
}
+
+ ptcache_update_info(pid);
}
int BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
{
- char filename[MAX_PTCACHE_FILE];
-
if(!pid->cache)
return 0;
- BKE_ptcache_id_filename(pid, filename, cfra, 1, 1);
+ if(pid->cache->flag & PTCACHE_DISK_CACHE) {
+ char filename[MAX_PTCACHE_FILE];
+
+ BKE_ptcache_id_filename(pid, filename, cfra, 1, 1);
- return BLI_exists(filename);
+ return BLI_exists(filename);
+ }
+ else {
+ PTCacheMem *pm = pid->cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ if(pm->frame==cfra)
+ return 1;
+ }
+ return 0;
+ }
}
void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startframe, int *endframe, float *timescale)
@@ -414,10 +795,10 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
}
}
-int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
+int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
{
PointCache *cache;
- int reset, clear;
+ int reset, clear, current, after;
if(!pid->cache)
return 0;
@@ -425,11 +806,20 @@ int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
cache= pid->cache;
reset= 0;
clear= 0;
+ current= 0;
+ after= 0;
if(mode == PTCACHE_RESET_DEPSGRAPH) {
if(!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
- reset= 1;
- clear= 1;
+ if(cache->flag & PTCACHE_AUTOCACHE) {
+ reset= 1;
+ clear= 1;
+ }
+ else {
+ current= 1;
+ after= 1;
+ cache->flag |= PTCACHE_OUTDATED;
+ }
}
else
cache->flag |= PTCACHE_OUTDATED;
@@ -449,10 +839,19 @@ int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
if(!(cache->flag & PTCACHE_BAKED))
clear= 1;
}
+ else if(mode == PTCACHE_RESET_FREE) {
+ if(!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) {
+ if((cache->flag & PTCACHE_AUTOCACHE)==0) {
+ current= 1;
+ after= 1;
+ }
+ }
+ }
if(reset) {
cache->flag &= ~(PTCACHE_OUTDATED|PTCACHE_SIMULATION_VALID);
cache->simframe= 0;
+ cache->last_exact= 0;
if(pid->type == PTCACHE_TYPE_CLOTH)
cloth_free_modifier(pid->ob, pid->data);
@@ -463,11 +862,15 @@ int BKE_ptcache_id_reset(PTCacheID *pid, int mode)
}
if(clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ if(after)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, CFRA);
+ if(current)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, CFRA);
- return (reset || clear);
+ return (reset || clear || current || after);
}
-int BKE_ptcache_object_reset(Object *ob, int mode)
+int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
{
PTCacheID pid;
ParticleSystem *psys;
@@ -479,7 +882,7 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
if(ob->soft) {
BKE_ptcache_id_from_softbody(&pid, ob, ob->soft);
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
@@ -488,23 +891,23 @@ int BKE_ptcache_object_reset(Object *ob, int mode)
if(psys->soft) {
BKE_ptcache_id_from_softbody(&pid, ob, psys->soft);
if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
else
skip = 1;
}
- else if((psys->recalc & PSYS_RECALC_RESET)==0)
+ else if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
skip = 1;
if(skip == 0) {
BKE_ptcache_id_from_particles(&pid, ob, psys);
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
for(md=ob->modifiers.first; md; md=md->next) {
if(md->type == eModifierType_Cloth) {
BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md);
- reset |= BKE_ptcache_id_reset(&pid, mode);
+ reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
@@ -564,7 +967,7 @@ void BKE_ptcache_set_continue_physics(Scene *scene, 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))
+ if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED))
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
}
@@ -590,6 +993,14 @@ PointCache *BKE_ptcache_add()
void BKE_ptcache_free(PointCache *cache)
{
+ PTCacheMem *pm = cache->mem_cache.first;
+ if(pm) {
+ for(; pm; pm=pm->next)
+ MEM_freeN(pm->data);
+
+ BLI_freelistN(&cache->mem_cache);
+ }
+
MEM_freeN(cache);
}
@@ -605,3 +1016,231 @@ PointCache *BKE_ptcache_copy(PointCache *cache)
return ncache;
}
+
+
+/* Baking */
+void BKE_ptcache_autocache_all(Scene *scene)
+{
+ PTCacheBaker baker;
+
+ baker.bake=0;
+ baker.break_data=NULL;
+ baker.break_test=NULL;
+ baker.pid=NULL;
+ baker.progressbar=NULL;
+ baker.progresscontext=NULL;
+ baker.render=0;
+ baker.scene=scene;
+
+ if(psys_count_autocache(scene, NULL))
+ BKE_ptcache_make_cache(&baker);
+}
+
+/* if bake is not given run simulations to current frame */
+void BKE_ptcache_make_cache(PTCacheBaker* baker)
+{
+ Scene *scene = baker->scene;
+ Base *base;
+ ListBase pidlist;
+ PTCacheID *pid = baker->pid;
+ PointCache *cache;
+ float frameleno = scene->r.framelen;
+ int cfrao = CFRA;
+ int startframe = MAXFRAME;
+ int endframe = CFRA;
+ int bake = baker->bake;
+ int render = baker->render;
+ int end = 0;
+
+ G.afbreek = 0;
+
+ //printf("Caching physics...");
+
+ /* set caches to baking mode and figure out start frame */
+ if(pid) {
+ /* cache/bake a single object */
+ cache = pid->cache;
+ if((cache->flag & PTCACHE_BAKED)==0) {
+ if(pid->type==PTCACHE_TYPE_PARTICLES)
+ psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe);
+
+ if(bake || cache->flag & PTCACHE_OUTDATED)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ startframe = MAX2(cache->last_exact, cache->startframe);
+
+ if(bake) {
+ endframe = cache->endframe;
+ cache->flag |= PTCACHE_BAKING;
+ }
+ else
+ endframe = MIN2(endframe, cache->endframe);
+
+ cache->flag &= ~PTCACHE_BAKED;
+ }
+ }
+ else for(base=scene->base.first; base; base= base->next) {
+ /* cache/bake everything in the scene */
+ BKE_ptcache_ids_from_object(&pidlist, base->object);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ cache = pid->cache;
+ if((cache->flag & PTCACHE_BAKED)==0) {
+ if(pid->type==PTCACHE_TYPE_PARTICLES)
+ psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe);
+
+ if(cache->flag & PTCACHE_OUTDATED)
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ startframe = MIN2(startframe, cache->startframe);
+
+ if(bake) {
+ endframe = MAX2(endframe, cache->endframe);
+ cache->flag |= PTCACHE_BAKING;
+ }
+ else if(render)
+ cache->flag |= PTCACHE_BAKING;
+
+ cache->flag &= ~PTCACHE_BAKED;
+
+ }
+ }
+
+ BLI_freelistN(&pidlist);
+ }
+
+ CFRA= startframe;
+ scene->r.framelen = 1.0;
+ scene_update_for_newframe(scene, scene->lay);
+
+ for(; CFRA <= endframe; CFRA++) {
+ float prog;
+
+ if(bake)
+ prog = (int)(100.0 * (float)(CFRA - startframe)/(float)(endframe-startframe));
+ else
+ prog = CFRA;
+
+ /* NOTE: baking should not redraw whole ui as this slows things down */
+ if(baker->progressbar)
+ baker->progressbar(baker->progresscontext, prog);
+
+ scene_update_for_newframe(scene, scene->lay);
+
+ /* NOTE: breaking baking should leave calculated frames in cache, not clear it */
+ if(baker->break_test && baker->break_test(baker->break_data))
+ break;
+ }
+
+ /* clear baking flag */
+ if(pid) {
+ cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
+ if(bake)
+ cache->flag |= PTCACHE_BAKED;
+ }
+ else for(base=scene->base.first; base; base= base->next) {
+ BKE_ptcache_ids_from_object(&pidlist, base->object);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
+ if(bake)
+ cache->flag |= PTCACHE_BAKED;
+ }
+ }
+
+ //printf("done!\n");
+
+ scene->r.framelen = frameleno;
+ CFRA = cfrao;
+ scene_update_for_newframe(scene, scene->lay);
+}
+
+void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) {
+ PointCache *cache = pid->cache;
+ PTCacheFile *pf;
+ PTCacheMem *pm;
+ int totelem=0;
+ int float_count=0;
+ int tot;
+ int write_error=0;
+
+ if (!G.relbase_valid){
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+ return;
+ }
+
+ totelem = ptcache_pid_totelem(pid);
+ float_count = ptcache_pid_elemsize(pid) / sizeof(float);
+
+ if(totelem==0 || float_count==0)
+ return;
+
+ tot = totelem*float_count;
+
+ /* MEM -> DISK */
+ if(cache->flag & PTCACHE_DISK_CACHE) {
+ pm = cache->mem_cache.first;
+
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ for(; pm; pm=pm->next) {
+ pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame);
+
+ if(pf) {
+ if(fwrite(pm->data, sizeof(float), tot, pf->fp) != tot) {
+ printf("Error writing to disk cache\n");
+
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+
+ BKE_ptcache_file_close(pf);
+ return;
+ }
+ BKE_ptcache_file_close(pf);
+ }
+ else
+ printf("Error creating disk cache file\n");
+ }
+
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ cache->flag |= PTCACHE_DISK_CACHE;
+ }
+ /* DISK -> MEM */
+ else {
+ int cfra;
+ int sfra = cache->startframe;
+ int efra = cache->endframe;
+
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+
+ for(cfra=sfra; cfra <= efra; cfra++) {
+ pf = BKE_ptcache_file_open(pid, PTCACHE_FILE_READ, cfra);
+
+ if(pf) {
+ pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem");
+ pm->data = MEM_callocN(sizeof(float)*tot, "Pointcache mem data");
+
+ if(fread(pm->data, sizeof(float), tot, pf->fp)!= tot) {
+ printf("Error reading from disk cache\n");
+
+ cache->flag |= PTCACHE_DISK_CACHE;
+
+ MEM_freeN(pm->data);
+ MEM_freeN(pm);
+ BKE_ptcache_file_close(pf);
+ return;
+ }
+
+ pm->frame = cfra;
+
+ BLI_addtail(&pid->cache->mem_cache, pm);
+
+ BKE_ptcache_file_close(pf);
+ }
+ }
+
+ cache->flag |= PTCACHE_DISK_CACHE;
+ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+ }
+} \ No newline at end of file
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 156bdae9b00..3b51af57e0b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -142,8 +142,6 @@ void free_scene(Scene *sce)
BLI_freelistN(&sce->base);
seq_free_editing(sce->ed);
- if(sce->radio) MEM_freeN(sce->radio);
- sce->radio= 0;
#ifndef DISABLE_PYTHON
BPY_free_scriptlink(&sce->scriptlink);
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 688a4ab901b..0ae17a13e43 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -62,13 +62,6 @@
#include <sys/vfs.h>
#endif
-#ifdef __BeOS
-struct statfs {
- int f_bsize;
- int f_bfree;
-};
-#endif
-
#ifdef __APPLE__
/* For statfs */
#include <sys/param.h>
@@ -77,7 +70,7 @@ struct statfs {
#include <fcntl.h>
-#if !defined(__BeOS) && !defined(WIN32)
+#if !defined(WIN32)
#include <sys/mtio.h> /* tape comando's */
#endif
#include <string.h> /* strcpy etc.. */
@@ -201,9 +194,6 @@ double BLI_diskfree(char *dir)
#if defined (__FreeBSD__) || defined (linux) || defined (__OpenBSD__) || defined (__APPLE__)
if (statfs(name, &disk)) return(-1);
#endif
-#ifdef __BeOS
- return -1;
-#endif
#if defined (__sun__) || defined (__sun) || defined (__sgi)
if (statvfs(name, &disk)) return(-1);
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c
index df4ad4e7c75..26f4c2dd415 100644
--- a/source/blender/blenlib/intern/util.c
+++ b/source/blender/blenlib/intern/util.c
@@ -737,10 +737,7 @@ void BLI_splitdirstring(char *di, char *fi)
}
char *BLI_gethome(void) {
- #ifdef __BeOS
- return "/boot/home/"; /* BeOS 4.5: doubleclick at icon doesnt give home env */
-
- #elif !defined(WIN32)
+ #if !defined(WIN32)
return getenv("HOME");
#else /* Windows */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 74226cabba6..af4f61fccc4 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2932,6 +2932,16 @@ static void direct_link_material(FileData *fd, Material *ma)
static void direct_link_pointcache(FileData *fd, PointCache *cache)
{
+ if((cache->flag & PTCACHE_DISK_CACHE)==0) {
+ PTCacheMem *pm;
+
+ link_list(fd, &cache->mem_cache);
+
+ pm = cache->mem_cache.first;
+
+ for(; pm; pm=pm->next)
+ pm->data = newdataadr(fd, pm->data);
+ }
cache->flag &= ~(PTCACHE_SIMULATION_VALID|PTCACHE_BAKE_EDIT_ACTIVE);
cache->simframe= 0;
}
@@ -3196,10 +3206,8 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
direct_link_dverts(fd, lvl->totvert, CustomData_get(&mesh->mr->vdata, 0, CD_MDEFORMVERT));
direct_link_customdata(fd, &mesh->mr->fdata, lvl->totface);
- if(!mesh->mr->edge_flags)
- mesh->mr->edge_flags= MEM_callocN(sizeof(short)*lvl->totedge, "Multires Edge Flags");
- if(!mesh->mr->edge_creases)
- mesh->mr->edge_creases= MEM_callocN(sizeof(char)*lvl->totedge, "Multires Edge Creases");
+ mesh->mr->edge_flags= newdataadr(fd, mesh->mr->edge_flags);
+ mesh->mr->edge_creases= newdataadr(fd, mesh->mr->edge_creases);
mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
@@ -3987,8 +3995,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
direct_link_keyingsets(fd, &sce->keyingsets);
sce->basact= newdataadr(fd, sce->basact);
-
- sce->radio= newdataadr(fd, sce->radio);
sce->toolsettings= newdataadr(fd, sce->toolsettings);
if(sce->toolsettings) {
@@ -9057,6 +9063,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
Scene *sce;
Tex *tx;
ParticleSettings *part;
+ Object *ob;
for(screen= main->screen.first; screen; screen= screen->id.next) {
do_versions_windowmanager_2_50(screen);
@@ -9099,7 +9106,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES;
}
- /* particle settings conversion */
+ /* particle draw and render types */
for(part= main->particle.first; part; part= part->id.next) {
if(part->draw_as) {
if(part->draw_as == PART_DRAW_DOT) {
@@ -9115,6 +9122,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
+ /* set old pointcaches to have disk cache flag */
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ ParticleSystem *psys = ob->particlesystem.first;
+
+ for(; psys; psys=psys->next) {
+ if(psys->pointcache)
+ psys->pointcache->flag |= PTCACHE_DISK_CACHE;
+ }
+
+ /* TODO: softbody & cloth caches */
+ }
}
/* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 0c385911721..3f591c62dee 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -549,6 +549,22 @@ static void write_userdef(WriteData *wd)
}
}
+/* TODO: replace *cache with *cachelist once it's coded */
+#define PTCACHE_WRITE_PSYS 0
+static void write_pointcaches(WriteData *wd, PointCache *cache, int type)
+{
+ writestruct(wd, DATA, "PointCache", 1, cache);
+
+ if((cache->flag & PTCACHE_DISK_CACHE)==0) {
+ PTCacheMem *pm = cache->mem_cache.first;
+
+ for(; pm; pm=pm->next) {
+ writestruct(wd, DATA, "PTCacheMem", 1, pm);
+ if(type==PTCACHE_WRITE_PSYS)
+ writestruct(wd, DATA, "ParticleKey", pm->totpoint, pm->data);
+ }
+ }
+}
static void write_particlesettings(WriteData *wd, ListBase *idbase)
{
ParticleSettings *part;
@@ -585,8 +601,8 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
}
if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child);
writestruct(wd, DATA, "SoftBody", 1, psys->soft);
- if(psys->soft) writestruct(wd, DATA, "PointCache", 1, psys->soft->pointcache);
- writestruct(wd, DATA, "PointCache", 1, psys->pointcache);
+ if(psys->soft) write_pointcaches(wd, psys->soft->pointcache, PTCACHE_WRITE_PSYS);
+ write_pointcaches(wd, psys->pointcache, PTCACHE_WRITE_PSYS);
}
}
@@ -1617,7 +1633,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
base= base->next;
}
- writestruct(wd, DATA, "Radio", 1, sce->radio);
writestruct(wd, DATA, "ToolSettings", 1, sce->toolsettings);
if(sce->toolsettings->vpaint)
writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->vpaint);
diff --git a/source/blender/blenpluginapi/intern/Makefile b/source/blender/blenpluginapi/intern/Makefile
index 51905cad8ec..20a61e9a25c 100644
--- a/source/blender/blenpluginapi/intern/Makefile
+++ b/source/blender/blenpluginapi/intern/Makefile
@@ -33,10 +33,6 @@ DIR = $(OCGDIR)/blender/$(LIBNAME)
include nan_compile.mk
-ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris"))
- CFLAGS += -shared
-endif
-
CFLAGS += $(LEVEL_1_C_WARNINGS)
# path to our own external headerfiles. On win2k this needs to be
diff --git a/source/blender/makesdna/DNA_radio_types.h b/source/blender/editors/include/ED_pointcache.h
index 4219bf59b93..7bf51d9d53d 100644
--- a/source/blender/makesdna/DNA_radio_types.h
+++ b/source/blender/editors/include/ED_pointcache.h
@@ -1,9 +1,5 @@
-/**
- * radio_types.h dec 2000 Nzc
- *
- * All type defs for the Blender core.
- *
- * $Id$
+/*
+ * $Id: ED_editparticle.h $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -21,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * The Original Code is Copyright (C) 2007 by Janne Karhu.
* All rights reserved.
*
* The Original Code is: all of this file.
@@ -29,34 +25,14 @@
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
- *
*/
-#ifndef DNA_RADIO_TYPES_H
-#define DNA_RADIO_TYPES_H
-
-typedef struct Radio {
- short hemires, maxiter;
- short drawtype, flag; /* bit 0 and 1: show limits */
- short subshootp, subshoote, nodelim, maxsublamp;
- short pama, pami, elma, elmi; /* patch and elem limits */
- int maxnode;
- float convergence;
- float radfac, gamma; /* for display */
-
-} Radio;
-
-
-/* **************** RADIOSITY ********************* */
-
-/* draw type */
-#define RAD_WIREFRAME 0
-#define RAD_SOLID 1
-#define RAD_GOURAUD 2
+#ifndef ED_PHYSICS_H
+#define ED_PHYSICS_H
-/* flag */
-#define RAD_SHOWLIMITS 1
-#define RAD_SHOWZ 2
+/* operators */
+void ED_operatortypes_pointcache(void);
+//void ED_keymap_pointcache(struct wmWindowManager *wm);
-#endif
+#endif /* ED_PHYSICS_H */
diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c
new file mode 100644
index 00000000000..e47f44c5c1a
--- /dev/null
+++ b/source/blender/editors/physics/ed_pointcache.c
@@ -0,0 +1,270 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 by Janne Karhu.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_object_force.h"
+
+#include "BKE_context.h"
+#include "BKE_particle.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+#include "BKE_utildefines.h"
+#include "BKE_pointcache.h"
+#include "BKE_global.h"
+#include "BKE_multires.h"
+
+#include "BLI_blenlib.h"
+
+#include "ED_screen.h"
+#include "ED_pointcache.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "physics_intern.h"
+
+static int cache_break_test(void *cbd) {
+ return G.afbreek==1;
+}
+/**************************** general **********************************/
+static int ptcache_bake_all_poll(bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+
+ if(!scene)
+ return 0;
+
+ return 1;
+}
+
+static int ptcache_bake_all_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PTCacheBaker baker;
+
+
+ baker.scene = scene;
+ baker.pid = NULL;
+ baker.bake = RNA_boolean_get(op->ptr, "bake");
+ baker.render = 0;
+ baker.break_test = cache_break_test;
+ baker.break_data = NULL;
+ baker.progressbar = WM_timecursor;
+ baker.progresscontext = CTX_wm_window(C);
+
+ BKE_ptcache_make_cache(&baker);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+static int ptcache_free_bake_all_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Base *base;
+ PTCacheID *pid;
+ ListBase pidlist;
+
+ for(base=scene->base.first; base; base= base->next) {
+ BKE_ptcache_ids_from_object(&pidlist, base->object);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ pid->cache->flag &= ~PTCACHE_BAKED;
+ BKE_ptcache_id_reset(scene, pid, PTCACHE_RESET_OUTDATED);
+ }
+ }
+
+ BLI_freelistN(&pidlist);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void PTCACHE_OT_bake_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake All Physics";
+ ot->idname= "PTCACHE_OT_bake_all";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_all_exec;
+ ot->poll= ptcache_bake_all_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Free All Physics Bakes";
+ ot->idname= "PTCACHE_OT_free_bake_all";
+
+ /* api callbacks */
+ ot->exec= ptcache_free_bake_all_exec;
+ ot->poll= ptcache_bake_all_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/**************************** particles **********************************/
+static int ptcache_bake_particle_system_poll(bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+
+ if(!scene || !ob || ob->id.lib)
+ return 0;
+
+ return (ob->particlesystem.first != NULL);
+}
+
+static int ptcache_bake_particle_system_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ ParticleSystem *psys =psys_get_current(ob);
+ PTCacheID pid;
+ PTCacheBaker baker;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+
+ baker.scene = scene;
+ baker.pid = &pid;
+ baker.bake = RNA_boolean_get(op->ptr, "bake");
+ baker.render = 0;
+ baker.break_test = cache_break_test;
+ baker.break_data = NULL;
+ baker.progressbar = WM_timecursor;
+ baker.progresscontext = CTX_wm_window(C);
+
+ BKE_ptcache_make_cache(&baker);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+static int ptcache_free_bake_particle_system_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ ParticleSystem *psys= psys_get_current(ob);
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+ psys->pointcache->flag &= ~PTCACHE_BAKED;
+ BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+
+ return OPERATOR_FINISHED;
+}
+void PTCACHE_OT_cache_particle_system(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake Particles";
+ ot->idname= "PTCACHE_OT_cache_particle_system";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_particle_system_exec;
+ ot->poll= ptcache_bake_particle_system_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "bake", 0, "Bake", "");
+}
+void PTCACHE_OT_free_bake_particle_system(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Free Particles Bake";
+ ot->idname= "PTCACHE_OT_free_bake_particle_system";
+
+ /* api callbacks */
+ ot->exec= ptcache_free_bake_particle_system_exec;
+ ot->poll= ptcache_bake_particle_system_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+static int ptcache_bake_from_particles_cache_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ ParticleSystem *psys= psys_get_current(ob);
+ PTCacheID pid;
+
+ BKE_ptcache_id_from_particles(&pid, ob, psys);
+ psys->pointcache->flag |= PTCACHE_BAKED;
+
+ return OPERATOR_FINISHED;
+}
+void PTCACHE_OT_bake_from_particles_cache(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Bake From Cache";
+ ot->idname= "PTCACHE_OT_bake_from_particles_cache";
+
+ /* api callbacks */
+ ot->exec= ptcache_bake_from_particles_cache_exec;
+ ot->poll= ptcache_bake_particle_system_poll;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/**************************** registration **********************************/
+
+void ED_operatortypes_pointcache(void)
+{
+ WM_operatortype_append(PTCACHE_OT_bake_all);
+ WM_operatortype_append(PTCACHE_OT_free_bake_all);
+ WM_operatortype_append(PTCACHE_OT_cache_particle_system);
+ WM_operatortype_append(PTCACHE_OT_free_bake_particle_system);
+ WM_operatortype_append(PTCACHE_OT_bake_from_particles_cache);
+}
+
+//void ED_keymap_pointcache(wmWindowManager *wm)
+//{
+// ListBase *keymap= WM_keymap_listbase(wm, "Pointcache", 0, 0);
+//
+// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
+// WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
+// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0);
+// WM_keymap_add_item(keymap, "PHYSICS_OT_free_particle_system", LKEY, KM_PRESS, 0, 0);
+//}
+
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index fa33e214737..ac86e2ed962 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -148,6 +148,7 @@ typedef struct StrokeCache {
float *layer_disps; /* Displacements for each vertex */
float (*mesh_store)[3]; /* Copy of the mesh vertices' locations */
short (*orig_norms)[3]; /* Copy of the mesh vertices' normals */
+ float (*face_norms)[3]; /* Copy of the mesh faces' normals */
float rotation; /* Texture rotation (radians) for anchored and rake modes */
int pixel_radius, previous_pixel_radius;
ListBase grab_active_verts[8]; /* The same list of verts is used throught grab stroke */
@@ -240,7 +241,6 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache)
float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1;
float pressure= 1;
float flip= cache->flip ? -1:1;
- float anchored = sd->brush->flag & BRUSH_ANCHORED ? 25 : 1;
if(sd->brush->flag & BRUSH_ALPHA_PRESSURE)
pressure *= cache->pressure;
@@ -250,6 +250,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache)
case SCULPT_TOOL_INFLATE:
case SCULPT_TOOL_CLAY:
case SCULPT_TOOL_FLATTEN:
+ case SCULPT_TOOL_LAYER:
return alpha * dir * pressure * flip; /*XXX: not sure why? was multiplied by G.vd->grid */;
case SCULPT_TOOL_SMOOTH:
return alpha * 4 * pressure;
@@ -257,46 +258,27 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache)
return alpha / 2 * dir * pressure * flip;
case SCULPT_TOOL_GRAB:
return 1;
- case SCULPT_TOOL_LAYER:
- return sd->brush->alpha / 50.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */;
default:
return 0;
}
}
-/* For clipping against a mirror modifier */
-static void sculpt_clip(StrokeCache *cache, float *co, const float val[3])
+/* Handles clipping against a mirror modifier and SCULPT_LOCK axis flags */
+static void sculpt_clip(Sculpt *sd, float *co, const float val[3])
{
int i;
+
for(i=0; i<3; ++i) {
- if((cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= cache->clip_tolerance[i]))
+ if(sd->flags & (SCULPT_LOCK_X << i))
+ continue;
+
+ if((sd->session->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= sd->session->cache->clip_tolerance[i]))
co[i]= 0.0f;
else
co[i]= val[i];
}
}
-static void sculpt_axislock(Sculpt *sd, float *co)
-{
- if(sd->flags == (SCULPT_LOCK_X|SCULPT_LOCK_Y|SCULPT_LOCK_Z))
- return;
-
- if(sd->session->cache->vc.v3d->twmode == V3D_MANIP_LOCAL) {
- float mat[3][3], imat[3][3];
- Mat3CpyMat4(mat, sd->session->cache->vc.obact->obmat);
- Mat3Inv(imat, mat);
- Mat3MulVecfl(mat, co);
- if (sd->flags & SCULPT_LOCK_X) co[0] = 0.0;
- if (sd->flags & SCULPT_LOCK_Y) co[1] = 0.0;
- if (sd->flags & SCULPT_LOCK_Z) co[2] = 0.0;
- Mat3MulVecfl(imat, co);
- } else {
- if (sd->flags & SCULPT_LOCK_X) co[0] = 0.0;
- if (sd->flags & SCULPT_LOCK_Y) co[1] = 0.0;
- if (sd->flags & SCULPT_LOCK_Z) co[2] = 0.0;
- }
-}
-
static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], const short no[3])
{
float fno[3] = {no[0], no[1], no[2]};
@@ -353,8 +335,6 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_
calc_area_normal(sd, area_normal, active_verts);
- sculpt_axislock(sd, area_normal);
-
while(node){
float *co= ss->mvert[node->Index].co;
@@ -362,7 +342,7 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_
co[1]+area_normal[1]*ss->cache->radius*node->Fade*ss->cache->scale[1],
co[2]+area_normal[2]*ss->cache->radius*node->Fade*ss->cache->scale[2]};
- sculpt_clip(ss->cache, co, val);
+ sculpt_clip(sd, co, val);
node= node->next;
}
@@ -412,37 +392,37 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert)
VecCopyf(avg, ss->mvert[vert].co);
}
-static void do_smooth_brush(SculptSession *ss, const ListBase* active_verts)
+static void do_smooth_brush(Sculpt *s, const ListBase* active_verts)
{
ActiveData *node= active_verts->first;
int i;
for(i = 0; i < 2; ++i) {
while(node){
- float *co= ss->mvert[node->Index].co;
+ float *co= s->session->mvert[node->Index].co;
float avg[3], val[3];
- neighbor_average(ss, avg, node->Index);
+ neighbor_average(s->session, avg, node->Index);
val[0] = co[0]+(avg[0]-co[0])*node->Fade;
val[1] = co[1]+(avg[1]-co[1])*node->Fade;
val[2] = co[2]+(avg[2]-co[2])*node->Fade;
- sculpt_clip(ss->cache, co, val);
+ sculpt_clip(s, co, val);
node= node->next;
}
}
}
-static void do_pinch_brush(SculptSession *ss, const ListBase* active_verts)
+static void do_pinch_brush(Sculpt *s, const ListBase* active_verts)
{
ActiveData *node= active_verts->first;
while(node) {
- float *co= ss->mvert[node->Index].co;
- const float val[3]= {co[0]+(ss->cache->location[0]-co[0])*node->Fade,
- co[1]+(ss->cache->location[1]-co[1])*node->Fade,
- co[2]+(ss->cache->location[2]-co[2])*node->Fade};
- sculpt_clip(ss->cache, co, val);
+ float *co= s->session->mvert[node->Index].co;
+ const float val[3]= {co[0]+(s->session->cache->location[0]-co[0])*node->Fade,
+ co[1]+(s->session->cache->location[1]-co[1])*node->Fade,
+ co[2]+(s->session->cache->location[2]-co[2])*node->Fade};
+ sculpt_clip(s, co, val);
node= node->next;
}
}
@@ -454,7 +434,6 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss)
float grab_delta[3];
VecCopyf(grab_delta, ss->cache->grab_delta_symmetry);
- sculpt_axislock(sd, grab_delta);
while(node) {
float *co= ss->mvert[node->Index].co;
@@ -462,7 +441,7 @@ static void do_grab_brush(Sculpt *sd, SculptSession *ss)
VecCopyf(add, grab_delta);
VecMulf(add, node->Fade);
VecAddf(add, add, co);
- sculpt_clip(ss->cache, co, add);
+ sculpt_clip(sd, co, add);
node= node->next;
}
@@ -473,42 +452,38 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active
{
float area_normal[3];
ActiveData *node= active_verts->first;
- float lim= brush_strength(sd, ss->cache);
+ float lim= ss->cache->radius / 4;
- if(sd->brush->flag & BRUSH_DIR_IN)
+ if(ss->cache->flip)
lim = -lim;
calc_area_normal(sd, area_normal, active_verts);
while(node){
float *disp= &ss->cache->layer_disps[node->Index];
+ float *co= ss->mvert[node->Index].co;
+ float val[3];
- if((lim > 0 && *disp < lim) ||
- (lim < 0 && *disp > lim)) {
- float *co= ss->mvert[node->Index].co;
- float val[3];
-
- *disp+= node->Fade;
-
- if(lim < 0 && *disp < lim)
- *disp = lim;
- else if(lim > 0 && *disp > lim)
- *disp = lim;
-
- val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0];
- val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1];
- val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2];
- //VecMulf(val, ss->cache->radius);
- sculpt_clip(ss->cache, co, val);
- }
+ *disp+= node->Fade;
+
+ /* Don't let the displacement go past the limit */
+ if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim))
+ *disp = lim;
+
+ val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0];
+ val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1];
+ val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2];
+
+ sculpt_clip(sd, co, val);
node= node->next;
}
}
-static void do_inflate_brush(SculptSession *ss, const ListBase *active_verts)
+static void do_inflate_brush(Sculpt *s, const ListBase *active_verts)
{
ActiveData *node= active_verts->first;
+ SculptSession *ss = s->session;
float add[3];
while(node) {
@@ -524,7 +499,7 @@ static void do_inflate_brush(SculptSession *ss, const ListBase *active_verts)
add[2]*= ss->cache->scale[2];
VecAddf(add, add, co);
- sculpt_clip(ss->cache, co, add);
+ sculpt_clip(s, co, add);
node= node->next;
}
@@ -587,7 +562,7 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, const ListBase
VecAddf(val, val, tmp);
}
- sculpt_clip(ss->cache, co, val);
+ sculpt_clip(sd, co, val);
node= node->next;
}
@@ -845,13 +820,13 @@ static void do_brush_action(Sculpt *sd, StrokeCache *cache)
do_draw_brush(sd, ss, &active_verts);
break;
case SCULPT_TOOL_SMOOTH:
- do_smooth_brush(ss, &active_verts);
+ do_smooth_brush(sd, &active_verts);
break;
case SCULPT_TOOL_PINCH:
- do_pinch_brush(ss, &active_verts);
+ do_pinch_brush(sd, &active_verts);
break;
case SCULPT_TOOL_INFLATE:
- do_inflate_brush(ss, &active_verts);
+ do_inflate_brush(sd, &active_verts);
break;
case SCULPT_TOOL_GRAB:
do_grab_brush(sd, ss);
@@ -1192,6 +1167,11 @@ void sculptmode_draw_mesh(int only_damaged)
}
#endif
+static int sculpt_mode_poll(bContext *C)
+{
+ return G.f & G_SCULPTMODE;
+}
+
static int sculpt_poll(bContext *C)
{
return G.f & G_SCULPTMODE && CTX_wm_area(C)->spacetype == SPACE_VIEW3D &&
@@ -1269,7 +1249,7 @@ static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot)
ot->idname= "SCULPT_OT_brush_curve_preset";
ot->exec= sculpt_brush_curve_preset_exec;
- ot->poll= sculpt_poll;
+ ot->poll= sculpt_mode_poll;
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1334,6 +1314,8 @@ static void sculpt_cache_free(StrokeCache *cache)
MEM_freeN(cache->mesh_store);
if(cache->orig_norms)
MEM_freeN(cache->orig_norms);
+ if(cache->face_norms)
+ MEM_freeN(cache->face_norms);
if(cache->mats)
MEM_freeN(cache->mats);
MEM_freeN(cache);
@@ -1362,9 +1344,11 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *
sculpt_update_mesh_elements(C);
+ if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER)
+ cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements");
+
/* Make copies of the mesh vertex locations and normals for some tools */
if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER || (sd->brush->flag & BRUSH_ANCHORED)) {
- cache->layer_disps = MEM_callocN(sizeof(float) * sd->session->totvert, "layer brush displacements");
cache->mesh_store= MEM_mallocN(sizeof(float) * 3 * sd->session->totvert, "sculpt mesh vertices copy");
for(i = 0; i < sd->session->totvert; ++i)
VecCopyf(cache->mesh_store[i], sd->session->mvert[i].co);
@@ -1376,6 +1360,13 @@ static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *
cache->orig_norms[i][1] = sd->session->mvert[i].no[1];
cache->orig_norms[i][2] = sd->session->mvert[i].no[2];
}
+
+ if(sd->session->face_normals) {
+ float *fn = sd->session->face_normals;
+ cache->face_norms= MEM_mallocN(sizeof(float) * 3 * sd->session->totface, "Sculpt face norms");
+ for(i = 0; i < sd->session->totface; ++i, fn += 3)
+ VecCopyf(cache->face_norms[i], fn);
+ }
}
}
@@ -1502,17 +1493,27 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
static void sculpt_restore_mesh(Sculpt *sd)
{
- StrokeCache *cache = sd->session->cache;
+ SculptSession *ss = sd->session;
+ StrokeCache *cache = ss->cache;
int i;
/* Restore the mesh before continuing with anchored stroke */
if((sd->brush->flag & BRUSH_ANCHORED) && cache->mesh_store) {
- for(i = 0; i < sd->session->totvert; ++i) {
- VecCopyf(sd->session->mvert[i].co, cache->mesh_store[i]);
- sd->session->mvert[i].no[0] = cache->orig_norms[i][0];
- sd->session->mvert[i].no[1] = cache->orig_norms[i][1];
- sd->session->mvert[i].no[2] = cache->orig_norms[i][2];
+ for(i = 0; i < ss->totvert; ++i) {
+ VecCopyf(ss->mvert[i].co, cache->mesh_store[i]);
+ ss->mvert[i].no[0] = cache->orig_norms[i][0];
+ ss->mvert[i].no[1] = cache->orig_norms[i][1];
+ ss->mvert[i].no[2] = cache->orig_norms[i][2];
+ }
+
+ if(ss->face_normals) {
+ float *fn = ss->face_normals;
+ for(i = 0; i < ss->totface; ++i, fn += 3)
+ VecCopyf(fn, cache->face_norms[i]);
}
+
+ if(sd->brush->sculpt_tool == SCULPT_TOOL_LAYER)
+ memset(cache->layer_disps, 0, sizeof(float) * ss->totvert);
}
}
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 4f9c1f4b7a7..510103895f4 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -50,6 +50,7 @@
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_uvedit.h"
+#include "ED_pointcache.h"
/* only call once on startup, storage is global in BKE kernel listbase */
void ED_spacetypes_init(void)
@@ -89,6 +90,7 @@ void ED_spacetypes_init(void)
ED_operatortypes_curve();
ED_operatortypes_armature();
ED_marker_operatortypes();
+ ED_operatortypes_pointcache();
ui_view2d_operatortypes();
diff --git a/source/blender/editors/space_buttons/SConscript b/source/blender/editors/space_buttons/SConscript
index 541da52f7f9..a0a7dad4077 100644
--- a/source/blender/editors/space_buttons/SConscript
+++ b/source/blender/editors/space_buttons/SConscript
@@ -12,7 +12,4 @@ defs = []
if env['WITH_BF_GAMEENGINE']:
defs.append('GAMEBLENDER=1')
- if env['WITH_BF_SOLID']:
- defs.append('USE_SUMO_SOLID')
-
env.BlenderLib ( 'bf_editors_space_buttons', sources, Split(incs), defs, libtype=['core'], priority=[120] )
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 38ce88019ed..e5d2215be29 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -220,14 +220,23 @@ void buttons_keymap(struct wmWindowManager *wm)
}
+//#define PY_HEADER
/* add handlers, stuff you only do once or on area/region changes */
static void buttons_header_area_init(wmWindowManager *wm, ARegion *ar)
{
+#ifdef PY_HEADER
+ ED_region_header_init(ar);
+#else
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+#endif
}
static void buttons_header_area_draw(const bContext *C, ARegion *ar)
{
+#ifdef PY_HEADER
+ ED_region_header(C, ar);
+#else
+
float col[3];
/* clear */
@@ -243,7 +252,8 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(C, &ar->v2d);
buttons_header_buttons(C, ar);
-
+#endif
+
/* restore view matrix? */
UI_view2d_view_restore(C);
}
diff --git a/source/blender/editors/space_info/SConscript b/source/blender/editors/space_info/SConscript
index 05afcae162e..01268115687 100644
--- a/source/blender/editors/space_info/SConscript
+++ b/source/blender/editors/space_info/SConscript
@@ -11,7 +11,4 @@ defs = []
if env['WITH_BF_GAMEENGINE']:
defs.append('GAMEBLENDER=1')
- if env['WITH_BF_SOLID']:
- defs.append('USE_SUMO_SOLID')
-
env.BlenderLib ( 'bf_editors_space_info', sources, Split(incs), defs, libtype=['core'], priority=[70] )
diff --git a/source/blender/editors/space_logic/SConscript b/source/blender/editors/space_logic/SConscript
index 46a9858a836..e32fcc1b535 100644
--- a/source/blender/editors/space_logic/SConscript
+++ b/source/blender/editors/space_logic/SConscript
@@ -12,7 +12,4 @@ defs = []
if env['WITH_BF_GAMEENGINE']:
defs.append('GAMEBLENDER=1')
- if env['WITH_BF_SOLID']:
- defs.append('USE_SUMO_SOLID')
-
env.BlenderLib ( 'bf_editors_space_game', sources, Split(incs), defs, libtype=['core'], priority=[120] )
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index a67e8c8a1c3..42da6775d5f 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3239,6 +3239,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
if(draw_as!=PART_DRAW_PATH){
state.time=cfra;
if(psys_get_particle_state(scene,ob,psys,a,&state,0)){
+ if(psys->parent)
+ Mat4MulVecfl(psys->parent->obmat, state.co);
+
/* create actiual particle data */
switch(draw_as){
case PART_DRAW_DOT:
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index fb7d9c57eaf..cb210a37bf4 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -4809,7 +4809,7 @@ void special_aftertrans_update(TransInfo *t)
if (base->flag & SELECT && (t->mode != TFM_DUMMY)) {
/* pointcache refresh */
- if (BKE_ptcache_object_reset(ob, PTCACHE_RESET_DEPSGRAPH))
+ if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
ob->recalc |= OB_RECALC_DATA;
/* Set autokey if necessary */
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 4d721a83c78..76b3f58f75c 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -26,6 +26,7 @@
#include <math.h>
#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
#include "BLI_arithb.h"
diff --git a/source/blender/editors/transform/transform_ndofinput.c b/source/blender/editors/transform/transform_ndofinput.c
index c52492ebd6b..9c2a1a7db6d 100644
--- a/source/blender/editors/transform/transform_ndofinput.c
+++ b/source/blender/editors/transform/transform_ndofinput.c
@@ -31,6 +31,7 @@
#include "BKE_utildefines.h" /* ABS */
#include "DNA_view3d_types.h" /* for G.vd (view3d) */
+#include "DNA_windowmanager_types.h" /* for G.vd (view3d) */
#include "WM_types.h"
diff --git a/source/blender/editors/transform/transform_numinput.c b/source/blender/editors/transform/transform_numinput.c
index 34976105db3..f5f1d5fac9e 100644
--- a/source/blender/editors/transform/transform_numinput.c
+++ b/source/blender/editors/transform/transform_numinput.c
@@ -34,6 +34,7 @@
#include "BKE_utildefines.h" /* ABS */
#include "WM_types.h"
+#include "DNA_windowmanager_types.h"
#include "transform.h"
diff --git a/source/blender/gpu/intern/Makefile b/source/blender/gpu/intern/Makefile
index 733ee3f764c..3a3ac20ff6c 100644
--- a/source/blender/gpu/intern/Makefile
+++ b/source/blender/gpu/intern/Makefile
@@ -35,7 +35,7 @@ DIR = $(OCGDIR)/blender/$(LIBNAME)
include nan_compile.mk
-ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris windows"))
+ifeq ($(OS),$(findstring $(OS), "darwin freebsd linux openbsd solaris windows"))
CFLAGS += -funsigned-char
endif
diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h
index bd2a0d3082f..7b5d668ce2b 100644
--- a/source/blender/imbuf/intern/imbuf.h
+++ b/source/blender/imbuf/intern/imbuf.h
@@ -51,7 +51,7 @@
#include <sys/mman.h>
#endif
-#if !defined(WIN32) && !defined(__BeOS)
+#if !defined(WIN32)
#define O_BINARY 0
#endif
diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c
index 6df92f69fff..1a6ab104bcf 100644
--- a/source/blender/imbuf/intern/readimage.c
+++ b/source/blender/imbuf/intern/readimage.c
@@ -244,26 +244,6 @@ struct ImBuf *IMB_loadifffile(int file, int flags) {
size = BLI_filesize(file);
-#if defined(AMIGA) || defined(__BeOS)
- mem= (int *)malloc(size);
- if (mem==0) {
- printf("Out of mem\n");
- return (0);
- }
-
- if (read(file, mem, size)!=size){
- printf("Read Error\n");
- free(mem);
- return (0);
- }
-
- ibuf = IMB_ibImageFromMemory(mem, size, flags);
- free(mem);
-
- /* for jpeg read */
- lseek(file, 0L, SEEK_SET);
-
-#else
mem= (int *)mmap(0,size,PROT_READ,MAP_SHARED,file,0);
if (mem==(int *)-1){
printf("Couldn't get mapping\n");
@@ -275,7 +255,6 @@ struct ImBuf *IMB_loadifffile(int file, int flags) {
if (munmap( (void *) mem, size)){
printf("Couldn't unmap file.\n");
}
-#endif
return(ibuf);
}
diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h
index 718d1a17834..a8d402fc503 100644
--- a/source/blender/makesdna/DNA_object_force.h
+++ b/source/blender/makesdna/DNA_object_force.h
@@ -33,6 +33,8 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+#include "DNA_listBase.h"
typedef struct PartDeflect {
short deflect; /* Deflection flag - does mesh deflect particles*/
@@ -72,12 +74,25 @@ typedef struct PartDeflect {
int seed; /* wind noise random seed */
} PartDeflect;
+typedef struct PTCacheMem {
+ struct PTCacheMem *next, *prev;
+ int frame, totpoint;
+ float *data; /* data points */
+ void *xdata; /* extra data */
+} PTCacheMem;
+
typedef struct PointCache {
- int flag; /* generic flag */
+ int flag, rt; /* generic flag */
int simframe; /* current frame of simulation (only if SIMULATION_VALID) */
int startframe; /* simulation start frame */
int endframe; /* simulation end frame */
int editframe; /* frame being edited (runtime only) */
+ int last_exact; /* last exact frame that's cached */
+ int xdata_type; /* type of extra data */
+ char name[64];
+ char prev_name[64];
+ char info[64];
+ struct ListBase mem_cache;
} PointCache;
typedef struct SBVertex {
@@ -247,6 +262,8 @@ typedef struct SoftBody {
#define PTCACHE_BAKING 8
#define PTCACHE_BAKE_EDIT 16
#define PTCACHE_BAKE_EDIT_ACTIVE 32
+#define PTCACHE_DISK_CACHE 64
+#define PTCACHE_AUTOCACHE 128
/* ob->softflag */
#define OB_SB_ENABLE 1
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 6805082d094..b10f35b9091 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -192,6 +192,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in
struct Object *target_ob;
struct Object *keyed_ob;
struct Object *lattice;
+ struct Object *parent; /* particles from global space -> parent space */
struct ListBase effectors, reactevents; /* runtime */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 2219535bfd3..89db9ae3ee8 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -39,7 +39,6 @@ extern "C" {
#include "DNA_scriptlink_types.h"
#include "DNA_ID.h"
-struct Radio;
struct Object;
struct World;
struct Scene;
@@ -158,7 +157,7 @@ typedef struct SceneRenderLayer {
#define SCE_PASS_REFRACT 1024
#define SCE_PASS_INDEXOB 2048
#define SCE_PASS_UV 4096
-#define SCE_PASS_RADIO 8192
+#define SCE_PASS_RADIO 8192 /* Radio removed, can use for new GI? */
#define SCE_PASS_MIST 16384
/* note, srl->passflag is treestore element 'nr' in outliner, short still... */
@@ -570,7 +569,6 @@ typedef struct Scene {
struct bNodeTree *nodetree;
void *ed; /* sequence editor data is allocated here */
- struct Radio *radio;
struct GameFraming framing;
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 7d6b5ec8764..e02d2984771 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -222,5 +222,36 @@ typedef enum wmRadialControlMode {
WM_RADIALCONTROL_ANGLE
} wmRadialControlMode;
+/* ************** wmEvent ************************ */
+/* for read-only rna access, dont save this */
+
+/* each event should have full modifier state */
+/* event comes from eventmanager and from keymap */
+typedef struct wmEvent {
+ struct wmEvent *next, *prev;
+
+ short type; /* event code itself (short, is also in keymap) */
+ short val; /* press, release, scrollvalue */
+ short x, y; /* mouse pointer position, screen coord */
+ short mval[2]; /* region mouse position, name convention pre 2.5 :) */
+ short prevx, prevy; /* previous mouse pointer position */
+ short unicode; /* future, ghost? */
+ char ascii; /* from ghost */
+ char pad;
+
+ /* modifier states */
+ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
+ short keymodifier; /* rawkey modifier */
+
+ /* keymap item, set by handler (weak?) */
+ const char *keymap_idname;
+
+ /* custom data */
+ short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
+ void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
+ short customdatafree;
+
+} wmEvent;
+
#endif /* DNA_WINDOWMANAGER_TYPES_H */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index bf2f0f3900e..91e9e617ea9 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -98,7 +98,6 @@ char *includefiles[] = {
"DNA_object_force.h",
"DNA_object_fluidsim.h",
"DNA_world_types.h",
- "DNA_radio_types.h",
"DNA_scene_types.h",
"DNA_view3d_types.h",
"DNA_view2d_types.h",
@@ -1124,7 +1123,6 @@ int main(int argc, char ** argv)
#include "DNA_object_force.h"
#include "DNA_object_fluidsim.h"
#include "DNA_world_types.h"
-#include "DNA_radio_types.h"
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
#include "DNA_view2d_types.h"
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 01abc5450aa..af64daa3293 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -172,6 +172,7 @@ extern StructRNA RNA_EnvironmentMap;
extern StructRNA RNA_EnvironmentMapTexture;
extern StructRNA RNA_ExplodeModifier;
extern StructRNA RNA_ExpressionController;
+extern StructRNA RNA_Event;
extern StructRNA RNA_FCurve;
extern StructRNA RNA_FModifier;
extern StructRNA RNA_FModifierCycles;
@@ -546,6 +547,9 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin,
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax);
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision);
+int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier);
+int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name);
+
void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem);
int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value);
int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index c679d9fc544..276f421c586 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -40,6 +40,9 @@ extern EnumPropertyItem beztriple_interpolation_mode_items[];
extern EnumPropertyItem fmodifier_type_items[];
+extern EnumPropertyItem event_value_items[];
+extern EnumPropertyItem event_type_items[];
+
#endif /* RNA_ENUM_TYPES */
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 18734fbcb18..9ece6684cd8 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1854,7 +1854,6 @@ RNAProcessItem PROCESS_ITEMS[]= {
{"rna_particle.c", NULL, RNA_def_particle},
{"rna_pose.c", NULL, RNA_def_pose},
{"rna_property.c", NULL, RNA_def_gameproperty},
- {"rna_radio.c", NULL, RNA_def_radio},
{"rna_scene.c", NULL, RNA_def_scene},
{"rna_screen.c", NULL, RNA_def_screen},
{"rna_scriptlink.c", NULL, RNA_def_scriptlink},
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index ba893319ce9..13686809cd2 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -669,6 +669,28 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden
return 0;
}
+int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier)
+{
+ for (; item->identifier; item++) {
+ if(item->value==value) {
+ *identifier = item->identifier;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name)
+{
+ for (; item->identifier; item++) {
+ if(item->value==value) {
+ *name = item->name;
+ return 1;
+ }
+ }
+ return 0;
+}
+
int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
{
const EnumPropertyItem *item;
@@ -676,14 +698,7 @@ int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int v
RNA_property_enum_items(ptr, prop, &item, &totitem);
- for(i=0; i<totitem; i++) {
- if(item[i].value==value) {
- *identifier = item[i].identifier;
- return 1;
- }
- }
-
- return 0;
+ return RNA_enum_identifier(item, value, identifier);
}
const char *RNA_property_ui_name(PropertyRNA *prop)
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index a3d5c4fe388..c2f2e1d519f 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -146,7 +146,6 @@ void RNA_def_object_force(struct BlenderRNA *brna);
void RNA_def_packedfile(struct BlenderRNA *brna);
void RNA_def_particle(struct BlenderRNA *brna);
void RNA_def_pose(struct BlenderRNA *brna);
-void RNA_def_radio(struct BlenderRNA *brna);
void RNA_def_rna(struct BlenderRNA *brna);
void RNA_def_scene(struct BlenderRNA *brna);
void RNA_def_screen(struct BlenderRNA *brna);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index d144ed5f28b..bc3f0733a0d 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -32,8 +32,87 @@
#include "DNA_object_types.h"
#include "DNA_object_force.h"
+#include "WM_types.h"
+
#ifdef RNA_RUNTIME
+#include "MEM_guardedalloc.h"
+
+#include "BKE_context.h"
+#include "BKE_pointcache.h"
+
+#include "BLI_blenlib.h"
+
+static void rna_Cache_toggle_disk_cache(bContext *C, PointerRNA *ptr)
+{
+ Object *ob = CTX_data_active_object(C);
+ PointCache *cache = (PointCache*)ptr->data;
+ PTCacheID *pid = NULL;
+ ListBase pidlist;
+
+ if(!ob)
+ return;
+
+ BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ if(pid->cache==cache)
+ break;
+ }
+
+ if(pid)
+ BKE_ptcache_toggle_disk_cache(pid);
+
+ BLI_freelistN(&pidlist);
+}
+
+static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr)
+{
+ Object *ob = CTX_data_active_object(C);
+ PointCache *cache = (PointCache*)ptr->data;
+ PTCacheID *pid = NULL, *pid2;
+ ListBase pidlist;
+ int new_name = 1;
+ char name[80];
+
+ if(!ob)
+ return;
+
+ /* TODO: check for proper characters */
+
+ BKE_ptcache_ids_from_object(&pidlist, ob);
+
+ for(pid=pidlist.first; pid; pid=pid->next) {
+ if(pid->cache==cache)
+ pid2 = pid;
+ else if(strcmp(cache->name, "") && strcmp(cache->name,pid->cache->name)==0) {
+ /*TODO: report "name exists" to user */
+ strcpy(cache->name, cache->prev_name);
+ new_name = 0;
+ }
+ }
+
+ if(new_name) {
+ if(pid2 && cache->flag & PTCACHE_DISK_CACHE) {
+ strcpy(name, cache->name);
+ strcpy(cache->name, cache->prev_name);
+
+ cache->flag &= ~PTCACHE_DISK_CACHE;
+
+ BKE_ptcache_toggle_disk_cache(pid2);
+
+ strcpy(cache->name, name);
+
+ cache->flag |= PTCACHE_DISK_CACHE;
+
+ BKE_ptcache_toggle_disk_cache(pid2);
+ }
+
+ strcpy(cache->prev_name, cache->name);
+ }
+
+ BLI_freelistN(&pidlist);
+}
#else
static void rna_def_pointcache(BlenderRNA *brna)
@@ -60,6 +139,32 @@ static void rna_def_pointcache(BlenderRNA *brna)
prop= RNA_def_property(srna, "baking", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKING);
+
+ prop= RNA_def_property(srna, "disk_cache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_DISK_CACHE);
+ RNA_def_property_ui_text(prop, "Disk Cache", "Save cache files to disk");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache");
+
+ prop= RNA_def_property(srna, "outdated", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_OUTDATED);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Cache is outdated", "");
+
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Name", "Cache name");
+ RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
+
+ prop= RNA_def_property(srna, "autocache", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_AUTOCACHE);
+ RNA_def_property_ui_text(prop, "Auto Cache", "Cache changes automatically");
+ //RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_autocache");
+
+ prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "info");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Cache Info", "Info on current cache status.");
+
}
static void rna_def_collision(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 8ee71b6fd9e..c48c1006588 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -38,6 +38,7 @@
#include "DNA_scene_types.h"
#include "WM_types.h"
+#include "WM_api.h"
#ifdef RNA_RUNTIME
@@ -45,48 +46,93 @@
#include "BKE_depsgraph.h"
#include "BKE_particle.h"
+#include "BLI_arithb.h"
+
+/* property update functions */
static void rna_Particle_redo(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_REDO;
+
+ if(ob)
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ }
+ else {
part = ptr->id.data;
-
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_REDO);
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_REDO);
+ }
}
static void rna_Particle_reset(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
- part = ptr->id.data;
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_REDO);
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_RESET;
+
+ if(ob) {
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
+ }
+ else {
+ part = ptr->id.data;
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_RESET);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
}
static void rna_Particle_change_type(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
- part = ptr->id.data;
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_TYPE|PSYS_RECALC_REDO);
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_RESET|PSYS_RECALC_TYPE;
+
+ if(ob) {
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
+ }
+ else {
+ part = ptr->id.data;
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_RESET|PSYS_RECALC_TYPE);
+ //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene);
+ }
}
static void rna_Particle_redo_child(bContext *C, PointerRNA *ptr)
{
+ Scene *scene = CTX_data_scene(C);
ParticleSettings *part;
- if(ptr->type==&RNA_ParticleSystem)
- part = ((ParticleSystem*)ptr->data)->part;
- else
+
+ if(ptr->type==&RNA_ParticleSystem) {
+ ParticleSystem *psys = (ParticleSystem*)ptr->data;
+ Object *ob = psys_find_object(scene, psys);
+
+ psys->recalc = PSYS_RECALC_CHILD;
+
+ if(ob)
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ }
+ else {
part = ptr->id.data;
- psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_CHILD);
+ psys_flush_particle_settings(scene, part, PSYS_RECALC_CHILD);
+ }
}
static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value)
{
@@ -887,7 +933,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "disp");
RNA_def_property_range(prop, 0, 100);
RNA_def_property_ui_text(prop, "Display", "Percentage of particles to display in 3d view");
- RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
+ RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset");
prop= RNA_def_property(srna, "material", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "omat");
@@ -1669,6 +1715,14 @@ static void rna_def_particle_system(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
RNA_def_property_struct_type(prop, "PointCache");
RNA_def_property_ui_text(prop, "Point Cache", "");
+
+ /* offset ob */
+ prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "parent");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Parent", "Use this object's coordinate system instead of global coordinate system.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
+
}
void RNA_def_particle(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_radio.c b/source/blender/makesrna/intern/rna_radio.c
deleted file mode 100644
index 8b862b4c535..00000000000
--- a/source/blender/makesrna/intern/rna_radio.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Contributor(s): Blender Foundation (2008).
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <stdlib.h>
-
-#include "RNA_define.h"
-#include "RNA_types.h"
-
-#include "rna_internal.h"
-
-#include "DNA_radio_types.h"
-
-#ifdef RNA_RUNTIME
-
-#else
-
-void RNA_def_radio(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- static EnumPropertyItem prop_drawtype_items[] = {
- {RAD_WIREFRAME, "WIREFRAME", 0, "Wireframe", "Enables Wireframe draw mode"},
- {RAD_SOLID, "SOLID", 0, "Solid", "Enables Solid draw mode"},
- {RAD_GOURAUD, "GOURAUD", 0, "Gouraud", "Enables Gouraud draw mode"},
- {0, NULL, 0, NULL, NULL}};
-
- srna= RNA_def_struct(brna, "Radiosity", NULL);
- RNA_def_struct_ui_text(srna, "Radiosity", "Settings for radiosity simulation of indirect diffuse lighting.");
- RNA_def_struct_sdna(srna, "Radio");
-
- /* Enums */
- prop= RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "drawtype");
- RNA_def_property_enum_items(prop, prop_drawtype_items);
- RNA_def_property_ui_text(prop, "Draw Mode", "Radiosity draw modes.");
-
- /* Number values */
- prop= RNA_def_property(srna, "hemi_resolution", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "hemires");
- RNA_def_property_range(prop, 100, 1000);
- RNA_def_property_ui_text(prop, "Hemi Resolution", "Sets the size of a hemicube.");
-
- prop= RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxiter");
- RNA_def_property_range(prop, 0, 10000);
- RNA_def_property_ui_text(prop, "Max Iterations", "Limits the maximum number of radiosity rounds.");
-
- prop= RNA_def_property(srna, "multiplier", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "radfac");
- RNA_def_property_range(prop, 0.001f, 250.0f);
- RNA_def_property_ui_text(prop, "Multiplier", "Multiplies the energy values.");
-
- prop= RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "gamma");
- RNA_def_property_range(prop, 0.2f, 10.0f);
- RNA_def_property_ui_text(prop, "Gamma", "Changes the contrast of the energy values.");
-
- prop= RNA_def_property(srna, "convergence", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "convergence");
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Convergence", "Sets the lower threshold of unshot energy.");
-
- prop= RNA_def_property(srna, "element_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "elma");
- RNA_def_property_range(prop, 1, 500);
- RNA_def_property_ui_text(prop, "Element Max", "Sets maximum size of an element");
-
- prop= RNA_def_property(srna, "element_min", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "elmi");
- RNA_def_property_range(prop, 1, 100);
- RNA_def_property_ui_text(prop, "Element Min", "Sets minimum size of an element");
-
- prop= RNA_def_property(srna, "patch_max", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "pama");
- RNA_def_property_range(prop, 10, 1000);
- RNA_def_property_ui_text(prop, "Patch Max", "Sets maximum size of a patch.");
-
- prop= RNA_def_property(srna, "patch_min", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "pami");
- RNA_def_property_range(prop, 10, 1000);
- RNA_def_property_ui_text(prop, "Patch Min", "Sets minimum size of a patch.");
-
- prop= RNA_def_property(srna, "subshoot_patch", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "subshootp");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "SubShoot Patch", "Sets the number of times the environment is tested to detect paths.");
-
- prop= RNA_def_property(srna, "subshoot_element", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "subshoote");
- RNA_def_property_range(prop, 0, 10);
- RNA_def_property_ui_text(prop, "SubShoot Element", "Sets the number of times the environment is tested to detect elements.");
-
- prop= RNA_def_property(srna, "max_elements", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxnode");
- RNA_def_property_range(prop, 1, 250000);
- RNA_def_property_ui_text(prop, "Max Elements", "Sets the maximum allowed number of elements.");
-
- prop= RNA_def_property(srna, "max_subdiv_shoot", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "maxsublamp");
- RNA_def_property_range(prop, 1, 250);
- RNA_def_property_ui_text(prop, "Max Subdiv Shoot", "Sets the maximum number of initial shoot patches that are evaluated");
-
- prop= RNA_def_property(srna, "remove_doubles_limit", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "nodelim");
- RNA_def_property_range(prop, 0, 50);
- RNA_def_property_ui_text(prop, "Remove Doubles Limit", "Sets the range for removing doubles");
-
- /* flag */
- prop= RNA_def_property(srna, "show_limits", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", RAD_SHOWLIMITS);
- RNA_def_property_ui_text(prop, "Show Limits", "Draws patch and element limits");
-
- prop= RNA_def_property(srna, "show_z", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", RAD_SHOWZ);
- RNA_def_property_ui_text(prop, "Show Z", "Draws limits differently");
-}
-
-#endif
-
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 1365ab75fc7..5d4916bb3c6 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -923,10 +923,6 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "ed");
RNA_def_property_struct_type(prop, "SequenceEditor");
RNA_def_property_ui_text(prop, "Sequence Editor", "");
-
- prop= RNA_def_property(srna, "radiosity", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "radio");
- RNA_def_property_ui_text(prop, "Radiosity", "");
prop= RNA_def_property(srna, "keyingsets", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index d4f7c5b0bd1..ce31cb27c9a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -575,18 +575,17 @@ static void rna_def_space_buttons(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem buttons_context_items[] = {
- {BCONTEXT_SCENE, "SCENE", 0, "Scene", ""},
- {BCONTEXT_WORLD, "WORLD", 0, "World", ""},
- {BCONTEXT_OBJECT, "OBJECT", 0, "Object", ""},
- {BCONTEXT_DATA, "DATA", 0, "Data", ""},
- {BCONTEXT_MATERIAL, "MATERIAL", 0, "Material", ""},
- {BCONTEXT_TEXTURE, "TEXTURE", 0, "Texture", ""},
- {BCONTEXT_PARTICLE, "PARTICLE", 0, "Particle", ""},
- {BCONTEXT_PHYSICS, "PHYSICS", 0, "Physics", ""},
- {BCONTEXT_GAME, "GAME", 0, "Game", ""},
- {BCONTEXT_BONE, "BONE", 0, "Bone", ""},
- {BCONTEXT_MODIFIER, "MODIFIER", 0, "Modifier", ""},
- {BCONTEXT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""},
+ {BCONTEXT_SCENE, "SCENE", ICON_SCENE, "Scene", "Scene"},
+ {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"},
+ {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"},
+ {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraint", "Constraint"},
+ {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifier", "Modifier"},
+ {BCONTEXT_DATA, "DATA", 0, "Data", "Data"},
+ {BCONTEXT_BONE, "BONE", ICON_BONE_DATA, "Bone", "Bone"},
+ {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
+ {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"},
+ {BCONTEXT_PARTICLE, "PARTICLE", ICON_PARTICLES, "Particle", "Particle"},
+ {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem panel_alignment_items[] = {
@@ -602,11 +601,13 @@ static void rna_def_space_buttons(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "mainb");
RNA_def_property_enum_items(prop, buttons_context_items);
RNA_def_property_ui_text(prop, "Buttons Context", "The type of active data to display and edit in the buttons window");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
prop= RNA_def_property(srna, "panel_alignment", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "align");
RNA_def_property_enum_items(prop, panel_alignment_items);
RNA_def_property_ui_text(prop, "Panel Alignment", "Arrangement of the panels within the buttons window");
+ RNA_def_property_update(prop, NC_WINDOW, NULL);
/* pinned data */
prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index df07e03850a..a1b51084fca 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -30,6 +30,120 @@
#include "rna_internal.h"
#include "DNA_windowmanager_types.h"
+#include "WM_types.h" /* wmEvent */
+
+
+EnumPropertyItem event_value_items[] = {
+ {KM_ANY, "ANY", 0, "Any", ""},
+ {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
+ {KM_PRESS, "PRESS", 0, "Press", ""},
+ {KM_RELEASE, "RELEASE", 0, "Release", ""},
+ {0, NULL, 0, NULL, NULL}};
+
+/* not returned: CAPSLOCKKEY, UNKNOWNKEY, COMMANDKEY, GRLESSKEY */
+EnumPropertyItem event_type_items[] = {
+ {AKEY, "A", 0, "A", ""},
+ {BKEY, "B", 0, "B", ""},
+ {CKEY, "C", 0, "C", ""},
+ {DKEY, "D", 0, "D", ""},
+ {EKEY, "E", 0, "E", ""},
+ {FKEY, "F", 0, "F", ""},
+ {GKEY, "G", 0, "G", ""},
+ {HKEY, "H", 0, "H", ""},
+ {IKEY, "I", 0, "I", ""},
+ {JKEY, "J", 0, "J", ""},
+ {KKEY, "K", 0, "K", ""},
+ {LKEY, "L", 0, "L", ""},
+ {MKEY, "M", 0, "M", ""},
+ {NKEY, "N", 0, "N", ""},
+ {OKEY, "O", 0, "O", ""},
+ {PKEY, "P", 0, "P", ""},
+ {QKEY, "Q", 0, "Q", ""},
+ {RKEY, "R", 0, "R", ""},
+ {SKEY, "S", 0, "S", ""},
+ {TKEY, "T", 0, "T", ""},
+ {UKEY, "U", 0, "U", ""},
+ {VKEY, "V", 0, "V", ""},
+ {WKEY, "W", 0, "W", ""},
+ {XKEY, "X", 0, "X", ""},
+ {YKEY, "Y", 0, "Y", ""},
+ {ZKEY, "Z", 0, "Z", ""},
+
+ {ZEROKEY, "ZERO", 0, "Zero Key", ""},
+ {ONEKEY, "ONE", 0, "One Key", ""},
+ {TWOKEY, "TWO", 0, "Two Key", ""},
+ {THREEKEY, "THREE", 0, "Three Key", ""},
+ {FOURKEY, "FOUR", 0, "Four Key", ""},
+ {FIVEKEY, "FIVE", 0, "Five Key", ""},
+ {SIXKEY, "SIX", 0, "Six Key", ""},
+ {SEVENKEY, "SEVEN", 0, "Seven Key", ""},
+ {EIGHTKEY, "EIGHT", 0, "Eight Key", ""},
+ {NINEKEY, "NINE", 0, "Nine Key", ""},
+
+ {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", ""},
+ {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", ""},
+ {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", ""},
+ {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Rightctrl", ""},
+ {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Rightshift", ""},
+ {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Leftshift", ""},
+
+ {ESCKEY, "ESC", 0, "Esc", ""},
+ {TABKEY, "TAB", 0, "Tab", ""},
+ {RETKEY, "RET", 0, "Return", ""},
+ {SPACEKEY, "SPACE", 0, "Spacebar", ""},
+ {LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
+ {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", ""},
+ {DELKEY, "DEL", 0, "Delete", ""},
+ {SEMICOLONKEY, "SEMI_COLON", 0, "Semicolon", ""},
+ {PERIODKEY, "PERIOD", 0, "Period", ""},
+ {COMMAKEY, "COMMA", 0, "Comma", ""},
+ {QUOTEKEY, "QUOTE", 0, "Quote", ""},
+ {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "Accentgrave", ""},
+ {MINUSKEY, "MINUS", 0, "Minus", ""},
+ {SLASHKEY, "SLASH", 0, "Slash", ""},
+ {BACKSLASHKEY, "BACK_SLASH", 0, "Backslash", ""},
+ {EQUALKEY, "EQUAL", 0, "Equal", ""},
+ {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "Leftbracket", ""},
+ {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "Rightbracket", ""},
+ {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", ""},
+ {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", ""},
+ {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", ""},
+ {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", ""},
+ {PAD2, "NUMPAD_2", 0, "Numpad 2", ""},
+ {PAD4, "NUMPAD_4", 0, "Numpad 4", ""},
+ {PAD6, "NUMPAD_6", 0, "Numpad 6", ""},
+ {PAD8, "NUMPAD_8", 0, "Numpad 8", ""},
+ {PAD1, "NUMPAD_1", 0, "Numpad 1", ""},
+ {PAD3, "NUMPAD_3", 0, "Numpad 3", ""},
+ {PAD5, "NUMPAD_5", 0, "Numpad 5", ""},
+ {PAD7, "NUMPAD_7", 0, "Numpad 7", ""},
+ {PAD9, "NUMPAD_9", 0, "Numpad 9", ""},
+ {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", ""},
+ {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", ""},
+ {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", ""},
+ {PAD0, "NUMPAD_0", 0, "Numpad 0", ""},
+ {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", ""},
+ {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", ""},
+ {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", ""},
+ {F1KEY, "F1", 0, "F1", ""},
+ {F2KEY, "F2", 0, "F2", ""},
+ {F3KEY, "F3", 0, "F3", ""},
+ {F4KEY, "F4", 0, "F4", ""},
+ {F5KEY, "F5", 0, "F5", ""},
+ {F6KEY, "F6", 0, "F6", ""},
+ {F7KEY, "F7", 0, "F7", ""},
+ {F8KEY, "F8", 0, "F8", ""},
+ {F9KEY, "F9", 0, "F9", ""},
+ {F10KEY, "F10", 0, "F10", ""},
+ {F11KEY, "F11", 0, "F11", ""},
+ {F12KEY, "F12", 0, "F12", ""},
+ {PAUSEKEY, "PAUSE", 0, "Pause", ""},
+ {INSERTKEY, "INSERT", 0, "Insert", ""},
+ {HOMEKEY, "HOME", 0, "Home", ""},
+ {PAGEUPKEY, "PAGE_UP", 0, "Page Up", ""},
+ {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""},
+ {ENDKEY, "END", 0, "End", ""},
+ {0, NULL, 0, NULL, NULL}};
#ifdef RNA_RUNTIME
@@ -87,6 +201,20 @@ static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties);
}
+
+static int rna_Event_ascii_get(PointerRNA *ptr, char *value)
+{
+ wmEvent *event= (wmEvent*)ptr->id.data;
+ value[0]= event->ascii;
+ value[1]= '\0';
+}
+
+static int rna_Event_ascii_length(PointerRNA *ptr)
+{
+ wmEvent *event= (wmEvent*)ptr->id.data;
+ return (event->ascii)? 1 : 0;
+}
+
#else
static void rna_def_operator(BlenderRNA *brna)
@@ -146,7 +274,80 @@ static void rna_def_operator_filelist_element(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_IDPROPERTY);
RNA_def_property_ui_text(prop, "Name", "the name of a file or directory within a file list");
}
+
+static void rna_def_event(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna= RNA_def_struct(brna, "Event", NULL);
+ RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
+ RNA_def_struct_sdna(srna, "wmEvent");
+
+ /* strings */
+ prop= RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
+ RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event.");
+
+
+ /* enums */
+ prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "val");
+ RNA_def_property_enum_items(prop, event_value_items);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some.");
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type");
+ RNA_def_property_enum_items(prop, event_type_items);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Type", "");
+
+
+ /* mouse */
+ prop= RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "x");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative vertical location of the mouse.");
+
+ prop= RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "y");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative horizontal location of the mouse.");
+
+ prop= RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "prevx");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative vertical location of the mouse.");
+
+ prop= RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "prevy");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative horizontal location of the mouse.");
+
+ /* modifiers */
+ prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Shift", "True when the shift key is held.");
+
+ prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Ctrl", "True when the shift key is held.");
+
+ prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Alt", "True when the shift key is held.");
+
+ prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "OS Key", "True when the shift key is held.");
+}
static void rna_def_windowmanager(BlenderRNA *brna)
{
@@ -169,6 +370,7 @@ void RNA_def_wm(BlenderRNA *brna)
rna_def_operator(brna);
rna_def_operator_utils(brna);
rna_def_operator_filelist_element(brna);
+ rna_def_event(brna);
rna_def_windowmanager(brna);
}
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index 4dba61411f0..f5eb81e3cea 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -337,7 +337,7 @@ void RNA_def_world(BlenderRNA *brna)
static EnumPropertyItem physics_engine_items[] = {
{WOPHY_NONE, "NONE", 0, "None", ""},
//{WOPHY_ENJI, "ENJI", 0, "Enji", ""},
- {WOPHY_SUMO, "SUMO", 0, "Sumo (Deprecated)", ""},
+ //{WOPHY_SUMO, "SUMO", 0, "Sumo (Deprecated)", ""},
//{WOPHY_DYNAMO, "DYNAMO", 0, "Dynamo", ""},
//{WOPHY_ODE, "ODE", 0, "ODE", ""},
{WOPHY_BULLET, "BULLET", 0, "Bullet", ""},
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index f4fdd0c6194..542de6bd9b8 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -47,98 +47,6 @@
#define PYOP_ATTR_IDNAME "__name__" /* use pythons class name */
#define PYOP_ATTR_DESCRIPTION "__doc__" /* use pythons docstring */
-static PyObject *pyop_dict_from_event(wmEvent *event)
-{
- PyObject *dict= PyDict_New();
- PyObject *item;
- char *cstring, ascii[2];
-
- /* type */
- item= PyUnicode_FromString(WM_key_event_string(event->type));
- PyDict_SetItemString(dict, "type", item); Py_DECREF(item);
-
- /* val */
- switch(event->val) {
- case KM_ANY:
- cstring = "ANY";
- break;
- case KM_RELEASE:
- cstring = "RELEASE";
- break;
- case KM_PRESS:
- cstring = "PRESS";
- break;
- default:
- cstring = "UNKNOWN";
- break;
- }
-
- item= PyUnicode_FromString(cstring);
- PyDict_SetItemString(dict, "val", item); Py_DECREF(item);
-
- /* x, y (mouse) */
- item= PyLong_FromLong(event->x);
- PyDict_SetItemString(dict, "x", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->y);
- PyDict_SetItemString(dict, "y", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->prevx);
- PyDict_SetItemString(dict, "prevx", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->prevy);
- PyDict_SetItemString(dict, "prevy", item); Py_DECREF(item);
-
- /* ascii */
- ascii[0]= event->ascii;
- ascii[1]= '\0';
- item= PyUnicode_FromString(ascii);
- PyDict_SetItemString(dict, "ascii", item); Py_DECREF(item);
-
- /* modifier keys */
- item= PyLong_FromLong(event->shift);
- PyDict_SetItemString(dict, "shift", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->ctrl);
- PyDict_SetItemString(dict, "ctrl", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->alt);
- PyDict_SetItemString(dict, "alt", item); Py_DECREF(item);
-
- item= PyLong_FromLong(event->oskey);
- PyDict_SetItemString(dict, "oskey", item); Py_DECREF(item);
-
-
-
- /* modifier */
-#if 0
- item= PyTuple_New(0);
- if(event->keymodifier & KM_SHIFT) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("SHIFT"));
- size++;
- }
- if(event->keymodifier & KM_CTRL) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("CTRL"));
- size++;
- }
- if(event->keymodifier & KM_ALT) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("ALT"));
- size++;
- }
- if(event->keymodifier & KM_OSKEY) {
- _PyTuple_Resize(&item, size+1);
- PyTuple_SET_ITEM(item, size, _PyUnicode_AsString("OSKEY"));
- size++;
- }
- PyDict_SetItemString(dict, "keymodifier", item); Py_DECREF(item);
-#endif
-
- return dict;
-}
-
static struct BPY_flag_def pyop_ret_flags[] = {
{"RUNNING_MODAL", OPERATOR_RUNNING_MODAL},
{"CANCELLED", OPERATOR_CANCELLED},
@@ -180,6 +88,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
int ret_flag= (mode==PYOP_POLL ? 0:OPERATOR_CANCELLED);
PointerRNA ptr_context;
PointerRNA ptr_operator;
+ PointerRNA ptr_event;
PyObject *py_operator;
PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -230,11 +139,13 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
if (mode==PYOP_INVOKE) {
item= PyObject_GetAttrString(py_class, "invoke");
args = PyTuple_New(3);
+
+ RNA_pointer_create(NULL, &RNA_Event, event, &ptr_event);
// PyTuple_SET_ITEM "steals" object reference, it is
// an object passed shouldn't be DECREF'ed
PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context));
- PyTuple_SET_ITEM(args, 2, pyop_dict_from_event(event));
+ PyTuple_SET_ITEM(args, 2, pyrna_struct_CreatePyObject(&ptr_event));
}
else if (mode==PYOP_EXEC) {
item= PyObject_GetAttrString(py_class, "execute");
diff --git a/source/blender/radiosity/CMakeLists.txt b/source/blender/radiosity/CMakeLists.txt
deleted file mode 100644
index e76f7409f99..00000000000
--- a/source/blender/radiosity/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# $Id$
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# The Original Code is Copyright (C) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-FILE(GLOB SRC intern/source/*.c)
-
-SET(INC
- extern/include ../blenlib ../blenkernel ../makesdna ../editors/include
- ../../../intern/guardedalloc ../render/extern/include
- ../render/intern/include ../blenloader ../../../extern/glew/include
-)
-
-BLENDERLIB_NOLIST(blender_radiosity "${SRC}" "${INC}")
-#env.BlenderLib ( 'blender_radiosity', sources, Split(incs), [], libtype='core', priority=50 )
diff --git a/source/blender/radiosity/Makefile b/source/blender/radiosity/Makefile
deleted file mode 100644
index 91a13e2fd57..00000000000
--- a/source/blender/radiosity/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# Makes module object directory and bounces make to subdirectories.
-
-SOURCEDIR = source/blender/radiosity
-DIRS = intern
-
-include nan_subdirs.mk
diff --git a/source/blender/radiosity/SConscript b/source/blender/radiosity/SConscript
deleted file mode 100644
index 29854d2ee83..00000000000
--- a/source/blender/radiosity/SConscript
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/python
-Import ('env')
-
-sources = env.Glob('intern/source/*.c')
-
-incs = 'extern/include ../blenlib ../blenkernel ../makesdna ../editors/include'
-incs += ' #/intern/guardedalloc ../render/extern/include'
-incs += ' ../render/intern/include ../blenloader #/extern/glew/include'
-
-incs += ' ' + env['BF_OPENGL_INC']
-
-env.BlenderLib ( 'bf_radiosity', sources, Split(incs), [], libtype='core', priority=150 )
diff --git a/source/blender/radiosity/extern/include/radio.h b/source/blender/radiosity/extern/include/radio.h
deleted file mode 100644
index e7f23302880..00000000000
--- a/source/blender/radiosity/extern/include/radio.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/* ***************************************
-
-
-
- radio.h nov/dec 1992
- revised for Blender may 1999
-
- $Id$
-
- ***** BEGIN GPL LICENSE BLOCK *****
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- 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.
-
- ***** END GPL LICENSE BLOCK *****
- */
-
-#ifndef RADIO_H
-#define RADIO_H
-#define RADIO_H
-
-/* type include */
-#include "radio_types.h"
-
-extern RadGlobal RG;
-struct View3D;
-struct Scene;
-
-/* radfactors.c */
-extern float calcStokefactor(RPatch *shoot, RPatch *rp, RNode *rn, float *area);
-extern void calcTopfactors(void);
-void calcSidefactors(void);
-extern void initradiosity(void);
-extern void rad_make_hocos(RadView *vw);
-extern void hemizbuf(RadView *vw);
-extern int makeformfactors(RPatch *shoot);
-extern void applyformfactors(RPatch *shoot);
-extern RPatch *findshootpatch(void);
-extern void setnodeflags(RNode *rn, int flag, int set);
-extern void backface_test(RPatch *shoot);
-extern void clear_backface_test(void);
-extern void progressiverad(void);
-extern void minmaxradelem(RNode *rn, float *min, float *max);
-extern void minmaxradelemfilt(RNode *rn, float *min, float *max, float *errmin, float *errmax);
-extern void subdivideshootElements(int it);
-extern void subdivideshootPatches(int it);
-extern void inithemiwindows(void);
-extern void closehemiwindows(void);
-void rad_init_energy(void);
-
-/* radio.c */
-void freeAllRad(struct Scene *scene);
-int rad_phase(void);
-void rad_status_str(char *str);
-void rad_printstatus(void);
-void rad_setlimits(struct Scene *scene);
-void set_radglobal(struct Scene *scene);
-void add_radio(struct Scene *scene);
-void delete_radio(struct Scene *scene);
-int rad_go(struct Scene *scene);
-void rad_subdivshootpatch(struct Scene *scene);
-void rad_subdivshootelem(struct Scene *scene);
-void rad_limit_subdivide(struct Scene *scene);
-
-/* radnode.c */
-extern void setnodelimit(float limit);
-extern float *mallocVert(void);
-extern float *callocVert(void);
-extern void freeVert(float *vert);
-extern int totalRadVert(void);
-extern RNode *mallocNode(void);
-extern RNode *callocNode(void);
-extern void freeNode(RNode *node);
-extern void freeNode_recurs(RNode *node);
-extern RPatch *mallocPatch(void);
-extern RPatch *callocPatch(void);
-extern void freePatch(RPatch *patch);
-extern void replaceAllNode(RNode *, RNode *);
-extern void replaceAllNodeInv(RNode *neighb, RNode *old);
-extern void replaceAllNodeUp(RNode *neighb, RNode *old);
-extern void replaceTestNode(RNode *, RNode **, RNode *, int , float *);
-extern void free_fastAll(void);
-
-/* radnode.c */
-extern void start_fastmalloc(char *str);
-extern int setvertexpointersNode(RNode *neighb, RNode *node, int level, float **v1, float **v2);
-extern float edlen(float *v1, float *v2);
-extern void deleteNodes(RNode *node);
-extern void subdivideTriNode(RNode *node, RNode *edge);
-extern void subdivideNode(RNode *node, RNode *edge);
-extern int comparelevel(RNode *node, RNode *nb, int level);
-
-/* radpreprocess.c */
-extern void splitconnected(void);
-extern int vergedge(const void *v1,const void *v2);
-extern void addedge(float *v1, float *v2, EdSort *es);
-extern void setedgepointers(void);
-extern void rad_collect_meshes(struct Scene *scene, struct View3D *v3d);
-extern void countelem(RNode *rn);
-extern void countglobaldata(void);
-extern void addelem(RNode ***el, RNode *rn, RPatch *rp);
-extern void makeGlobalElemArray(void);
-extern void remakeGlobaldata(void);
-extern void splitpatch(RPatch *old);
-extern void addpatch(RPatch *old, RNode *rn);
-extern void converttopatches(void);
-extern void make_elements(void);
-extern void subdividelamps(void);
-extern void maxsizePatches(void);
-extern void subdiv_elements(void);
-
-/* radpostprocess.c */
-void addaccu(register char *z, register char *t);
-void addaccuweight(register char *z, register char *t, int w);
-void triaweight(Face *face, int *w1, int *w2, int *w3);
-void init_face_tab(void);
-Face *addface(void);
-Face *makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn);
-void anchorQuadface(RNode *rn, float *v1, float *v2, float *v3, float *v4, int flag);
-void anchorTriface(RNode *rn, float *v1, float *v2, float *v3, int flag);
-float *findmiddlevertex(RNode *node, RNode *nb, float *v1, float *v2);
-void make_face_tab(void);
-void filterFaces(void);
-void calcfiltrad(RNode *rn, float *cd);
-void filterNodes(void);
-void removeEqualNodes(short limit);
-void rad_addmesh(struct Scene *scene);
-void rad_replacemesh(struct Scene *scene);
-
-/* raddisplay.c */
-extern char calculatecolor(float col);
-extern void make_node_display(void);
-extern void drawnodeWire(RNode *rn);
-extern void drawsingnodeWire(RNode *rn);
-extern void drawnodeSolid(RNode *rn);
-extern void drawnodeGour(RNode *rn);
-extern void drawpatch(RPatch *patch, unsigned int col);
-extern void drawfaceGour(Face *face);
-extern void drawfaceSolid(Face *face);
-extern void drawfaceWire(Face *face);
-extern void drawsquare(float *cent, float size, short cox, short coy);
-extern void drawlimits(void);
-extern void setcolNode(RNode *rn, unsigned int *col);
-extern void pseudoAmb(void);
-extern void rad_forcedraw(void);
-extern void drawpatch_ext(RPatch *patch, unsigned int col);
-extern void RAD_drawall(int depth_is_on);
-
-/* radrender.c */
-struct Render;
-extern void do_radio_render(struct Render *re);
-void end_radio_render(void);
-
-#endif /* RADIO_H */
-
diff --git a/source/blender/radiosity/extern/include/radio_types.h b/source/blender/radiosity/extern/include/radio_types.h
deleted file mode 100644
index 5a218ee71be..00000000000
--- a/source/blender/radiosity/extern/include/radio_types.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * radio_types.h
- *
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/* #include "misc_util.h" */ /* for listbase...*/
-
-
-#ifndef RADIO_TYPES_H
-#define RADIO_TYPES_H
-
-#include "DNA_listBase.h"
-#include "DNA_material_types.h"
-
-struct Render;
-struct CustomData;
-
-#define PI M_PI
-#define RAD_MAXFACETAB 1024
-#define RAD_NEXTFACE(a) if( ((a) & 1023)==0 ) face= RG.facebase[(a)>>10]; else face++;
-
-/* RG.phase */
-#define RAD_SHOOTE 1
-#define RAD_SHOOTP 2
-#define RAD_SOLVE 3
-
-typedef struct RadView {
- float cam[3], tar[3], up[3];
- float wx1, wx2, wy1, wy2;
- float mynear, myfar;
- float viewmat[4][4], winmat[4][4];
- unsigned int *rect, *rectz;
- short rectx, recty;
- int wid;
-
-} RadView;
-
-/* rn->f */
-#define RAD_PATCH 1
-#define RAD_SHOOT 2
-#define RAD_SUBDIV 4
-#define RAD_BACKFACE 8
-#define RAD_TWOSIDED 16
-
-
-typedef struct RNode { /* length: 104 */
- struct RNode *down1, *down2, *up;
- struct RNode *ed1, *ed2, *ed3, *ed4;
- struct RPatch *par;
-
- char lev1, lev2, lev3, lev4; /* edgelevels */
- short type; /* type: 4==QUAD, 3==TRIA */
- short f;
- float *v1, *v2, *v3, *v4;
- float totrad[3], area;
-
- unsigned int col;
- int orig; /* index in custom face data */
-} RNode;
-
-
-typedef struct Face { /* length: 52 */
- float *v1, *v2, *v3, *v4;
- unsigned int col, matindex;
- int orig; /* index in custom face data */
-} Face;
-
-/* rp->f1 */
-#define RAD_NO_SPLIT 1
-
-typedef struct RPatch {
- struct RPatch *next, *prev;
- RNode *first; /* first node==patch */
-
- struct Object *from;
-
- int type; /* 3: TRIA, 4: QUAD */
- short f, f1; /* flags f: if node, only for subdiv */
-
- float ref[3], emit[3], unshot[3];
- float cent[3], norm[3];
- float area;
- int matindex;
-
-} RPatch;
-
-
-typedef struct VeNoCo { /* needed for splitconnected */
- struct VeNoCo *next;
- float *v;
- float *n;
- float *col;
- int flag;
-} VeNoCo;
-
-
-typedef struct EdSort { /* sort edges */
- float *v1, *v2;
- RNode *node;
- int nr;
-} EdSort;
-
-typedef struct {
- struct Radio *radio;
- unsigned int *hemibuf;
- struct ListBase patchbase;
- int totpatch, totelem, totvert, totlamp;
- RNode **elem; /* global array with all pointers */
- VeNoCo *verts; /* temporal vertices from patches */
- float *formfactors; /* 1 factor per element */
- float *topfactors, *sidefactors; /* LUT for delta's */
- int *index; /* LUT for above LUT */
- Face **facebase;
- int totface;
- float min[3], max[3], size[3], cent[3]; /* world */
- float maxsize, totenergy;
- float patchmin, patchmax;
- float elemmin, elemmax;
- float radfactor, lostenergy, igamma; /* radfac is in button, radfactor is calculated */
- int phase;
- struct Render *re; /* for calling hemizbuf correctly */
- /* to preserve materials as used before, max 16 */
- Material *matar[MAXMAT];
- int totmat;
-
- /* for preserving face data */
- int mfdatatot;
- struct CustomData *mfdata;
- struct RNode **mfdatanodes;
-
- /* this part is a copy of struct Radio */
- short hemires, maxiter;
- short drawtype, flag; /* bit 0 en 1: show limits */
- short subshootp, subshoote, nodelim, maxsublamp;
- int maxnode;
- float convergence;
- float radfac, gamma; /* for display */
-
-} RadGlobal;
-
-#endif /* radio_types.h */
-
diff --git a/source/blender/radiosity/intern/Makefile b/source/blender/radiosity/intern/Makefile
deleted file mode 100644
index 456b51cc56e..00000000000
--- a/source/blender/radiosity/intern/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# Makes module object directory and bounces make to subdirectories.
-
-SOURCEDIR = source/blender/radiosity/intern
-DIRS = source
-
-include nan_subdirs.mk
diff --git a/source/blender/radiosity/intern/source/Makefile b/source/blender/radiosity/intern/source/Makefile
deleted file mode 100644
index 44b38de9bae..00000000000
--- a/source/blender/radiosity/intern/source/Makefile
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# radiosity uses the render lib
-#
-
-LIBNAME = radiosity
-DIR = $(OCGDIR)/blender/$(LIBNAME)
-
-include nan_compile.mk
-
-CFLAGS += $(LEVEL_1_C_WARNINGS)
-
-CPPFLAGS += -I$(NAN_GLEW)/include
-CPPFLAGS += -I$(OPENGL_HEADERS)
-
-# not very neat....
-CPPFLAGS += -I../../../blenkernel
-CPPFLAGS += -I../../../blenlib
-CPPFLAGS += -I../../../makesdna
-CPPFLAGS += -I../../../imbuf
-CPPFLAGS += -I../../../
-CPPFLAGS += -I../../../blenloader
-CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
-
-# first /include is my own includes, second are the external includes
-# third is the external interface. there should be a nicer way to say this
-CPPFLAGS += -I../include -I../../../editors/include -I../../extern/include
-CPPFLAGS += -I../../../render/extern/include
-CPPFLAGS += -I../../../render/intern/include
diff --git a/source/blender/radiosity/intern/source/raddisplay.c b/source/blender/radiosity/intern/source/raddisplay.c
deleted file mode 100644
index ab9e8eedc28..00000000000
--- a/source/blender/radiosity/intern/source/raddisplay.c
+++ /dev/null
@@ -1,477 +0,0 @@
-/* ***************************************
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- raddisplay.c nov/dec 1992
- may 1999
-
- - drawing
- - color calculation for display during solving
-
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <math.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BLI_blenlib.h"
-
-#include "DNA_radio_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
-#include "DNA_view3d_types.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "BIF_gl.h"
-
-#include "radio.h"
-
-/* cpack has to be endian-insensitive! (old irisgl function) */
-#define cpack(x) glColor3ub( ((x)&0xFF), (((x)>>8)&0xFF), (((x)>>16)&0xFF) )
-
-char calculatecolor(float col)
-{
- int b;
-
- if(RG.gamma==1.0) {
- b= RG.radfactor*col;
- }
- else if(RG.gamma==2.0) {
- b= RG.radfactor*sqrt(col);
- }
- else {
- b= RG.radfactor*pow(col, RG.igamma);
- }
-
- if(b>255) b=255;
- return b;
-}
-
-void make_node_display()
-{
- RNode *rn, **el;
- int a;
- char *charcol;
-
- RG.igamma= 1.0/RG.gamma;
- RG.radfactor= RG.radfac*pow(64*64, RG.igamma);
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- charcol= (char *)&( rn->col );
-
- charcol[3]= calculatecolor(rn->totrad[0]);
- charcol[2]= calculatecolor(rn->totrad[1]);
- charcol[1]= calculatecolor(rn->totrad[2]);
-
- /* gouraudcolor */
- *(rn->v1+3)= 0;
- *(rn->v2+3)= 0;
- *(rn->v3+3)= 0;
- if(rn->v4) *(rn->v4+3)= 0;
- }
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- addaccuweight( (char *)&(rn->col), (char *)(rn->v1+3), 16 );
- addaccuweight( (char *)&(rn->col), (char *)(rn->v2+3), 16 );
- addaccuweight( (char *)&(rn->col), (char *)(rn->v3+3), 16 );
- if(rn->v4) addaccuweight( (char *)&(rn->col), (char *)(rn->v4+3), 16 );
- }
-}
-
-void drawnodeWire(RNode *rn)
-{
-
- if(rn->down1) {
- drawnodeWire(rn->down1);
- drawnodeWire(rn->down2);
- }
- else {
- glBegin(GL_LINE_LOOP);
- glVertex3fv(rn->v1);
- glVertex3fv(rn->v2);
- glVertex3fv(rn->v3);
- if(rn->type==4) glVertex3fv(rn->v4);
- glEnd();
- }
-}
-
-void drawsingnodeWire(RNode *rn)
-{
-
- glBegin(GL_LINE_LOOP);
- glVertex3fv(rn->v1);
- glVertex3fv(rn->v2);
- glVertex3fv(rn->v3);
- if(rn->type==4) glVertex3fv(rn->v4);
- glEnd();
-}
-
-void drawnodeSolid(RNode *rn)
-{
- char *cp;
-
- if(rn->down1) {
- drawnodeSolid(rn->down1);
- drawnodeSolid(rn->down2);
- }
- else {
- cp= (char *)&rn->col;
- glColor3ub(cp[3], cp[2], cp[1]);
- glBegin(GL_POLYGON);
- glVertex3fv(rn->v1);
- glVertex3fv(rn->v2);
- glVertex3fv(rn->v3);
- if(rn->type==4) glVertex3fv(rn->v4);
- glEnd();
- }
-}
-
-void drawnodeGour(RNode *rn)
-{
- char *cp;
-
- if(rn->down1) {
- drawnodeGour(rn->down1);
- drawnodeGour(rn->down2);
- }
- else {
- glBegin(GL_POLYGON);
- cp= (char *)(rn->v1+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v1);
-
- cp= (char *)(rn->v2+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v2);
-
- cp= (char *)(rn->v3+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v3);
-
- if(rn->type==4) {
- cp= (char *)(rn->v4+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(rn->v4);
- }
- glEnd();
- }
-}
-
-void drawpatch_ext(RPatch *patch, unsigned int col)
-{
- ScrArea *sa, *oldsa;
- View3D *v3d;
- glDrawBuffer(GL_FRONT);
-
- return; // XXX
-
- cpack(col);
-
- oldsa= NULL; // XXX curarea;
-
-// sa= G.curscreen->areabase.first;
- while(sa) {
- if (sa->spacetype==SPACE_VIEW3D) {
- v3d= sa->spacedata.first;
-
- /* use mywinget() here: otherwise it draws in header */
-// XXX if(sa->win != mywinget()) areawinset(sa->win);
-// XXX persp(PERSP_VIEW);
- if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
- drawnodeWire(patch->first);
- if(v3d->zbuf) glEnable(GL_DEPTH_TEST); // pretty useless?
- }
- sa= sa->next;
- }
-
-// XXX if(oldsa && oldsa!=curarea) areawinset(oldsa->win);
-
- glFlush();
- glDrawBuffer(GL_BACK);
-}
-
-
-void drawfaceGour(Face *face)
-{
- char *cp;
-
- glBegin(GL_POLYGON);
- cp= (char *)(face->v1+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v1);
-
- cp= (char *)(face->v2+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v2);
-
- cp= (char *)(face->v3+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v3);
-
- if(face->v4) {
- cp= (char *)(face->v4+3);
- glColor3ub(cp[3], cp[2], cp[1]);
- glVertex3fv(face->v4);
- }
- glEnd();
-
-}
-
-void drawfaceSolid(Face *face)
-{
- char *cp;
-
- cp= (char *)&face->col;
- glColor3ub(cp[3], cp[2], cp[1]);
-
- glBegin(GL_POLYGON);
- glVertex3fv(face->v1);
- glVertex3fv(face->v2);
- glVertex3fv(face->v3);
- if(face->v4) {
- glVertex3fv(face->v4);
- }
- glEnd();
-
-}
-
-void drawfaceWire(Face *face)
-{
- char *cp;
-
- cp= (char *)&face->col;
- glColor3ub(cp[3], cp[2], cp[1]);
-
- glBegin(GL_LINE_LOOP);
- glVertex3fv(face->v1);
- glVertex3fv(face->v2);
- glVertex3fv(face->v3);
- if(face->v4) {
- glVertex3fv(face->v4);
- }
- glEnd();
-
-}
-
-void drawsquare(float *cent, float size, short cox, short coy)
-{
- float vec[3];
-
- vec[0]= cent[0];
- vec[1]= cent[1];
- vec[2]= cent[2];
-
- glBegin(GL_LINE_LOOP);
- vec[cox]+= .5*size;
- vec[coy]+= .5*size;
- glVertex3fv(vec);
- vec[coy]-= size;
- glVertex3fv(vec);
- vec[cox]-= size;
- glVertex3fv(vec);
- vec[coy]+= size;
- glVertex3fv(vec);
- glEnd();
-}
-
-void drawlimits()
-{
- /* center around cent */
- short cox=0, coy=1;
-
- if((RG.flag & (RAD_SHOWLIMITS|RAD_SHOWZ))==RAD_SHOWZ) coy= 2;
- if((RG.flag & (RAD_SHOWLIMITS|RAD_SHOWZ))==(RAD_SHOWLIMITS|RAD_SHOWZ)) {
- cox= 1;
- coy= 2;
- }
-
- cpack(0);
- drawsquare(RG.cent, sqrt(RG.patchmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.patchmin), cox, coy);
-
- drawsquare(RG.cent, sqrt(RG.elemmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.elemmin), cox, coy);
-
- cpack(0xFFFFFF);
- drawsquare(RG.cent, sqrt(RG.patchmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.patchmin), cox, coy);
- cpack(0xFFFF00);
- drawsquare(RG.cent, sqrt(RG.elemmax), cox, coy);
- drawsquare(RG.cent, sqrt(RG.elemmin), cox, coy);
-
-}
-
-void setcolNode(RNode *rn, unsigned int *col)
-{
-
- if(rn->down1) {
- setcolNode(rn->down1, col);
- setcolNode(rn->down2, col);
- }
- rn->col= *col;
-
- *((unsigned int *)rn->v1+3)= *col;
- *((unsigned int *)rn->v2+3)= *col;
- *((unsigned int *)rn->v3+3)= *col;
- if(rn->v4) *((unsigned int *)rn->v4+3)= *col;
-}
-
-void pseudoAmb()
-{
- RPatch *rp;
- float fac;
- char col[4];
-
- /* sets pseudo ambient color in the nodes */
-
- rp= RG.patchbase.first;
- while(rp) {
-
- if(rp->emit[0]!=0.0 || rp->emit[1]!=0.0 || rp->emit[2]!=0.0) {
- col[1]= col[2]= col[3]= 255;
- }
- else {
- fac= rp->norm[0]+ rp->norm[1]+ rp->norm[2];
- fac= 225.0*(3+fac)/6.0;
-
- col[3]= fac*rp->ref[0];
- col[2]= fac*rp->ref[1];
- col[1]= fac*rp->ref[2];
- }
-
- setcolNode(rp->first, (unsigned int *)col);
-
- rp= rp->next;
- }
-}
-
-void RAD_drawall(int depth_is_on)
-{
- /* displays elements or faces */
- Face *face = NULL;
- RNode **el;
- RPatch *rp;
- int a;
-
- if(!depth_is_on) {
- glEnable(GL_DEPTH_TEST);
- glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT);
- }
-
- if(RG.totface) {
- if(RG.drawtype==RAD_GOURAUD) {
- glShadeModel(GL_SMOOTH);
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
-
- drawfaceGour(face);
- }
- }
- else if(RG.drawtype==RAD_SOLID) {
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
-
- drawfaceSolid(face);
- }
- }
- else {
- cpack(0);
- rp= RG.patchbase.first;
- while(rp) {
- drawsingnodeWire(rp->first);
- rp= rp->next;
- }
- }
- }
- else {
- el= RG.elem;
- if(RG.drawtype==RAD_GOURAUD) {
- glShadeModel(GL_SMOOTH);
- for(a=RG.totelem; a>0; a--, el++) {
- drawnodeGour(*el);
- }
- }
- else if(RG.drawtype==RAD_SOLID) {
- for(a=RG.totelem; a>0; a--, el++) {
- drawnodeSolid(*el);
- }
- }
- else {
- cpack(0);
- for(a=RG.totelem; a>0; a--, el++) {
- drawnodeWire(*el);
- }
- }
- }
- glShadeModel(GL_FLAT);
-
- if(RG.totpatch) {
- if(RG.flag & (RAD_SHOWLIMITS|RAD_SHOWZ)) {
- if(depth_is_on) glDisable(GL_DEPTH_TEST);
- drawlimits();
- if(depth_is_on) glEnable(GL_DEPTH_TEST);
- }
- }
- if(!depth_is_on) {
- glDisable(GL_DEPTH_TEST);
- }
-}
-
-void rad_forcedraw()
-{
- ScrArea *sa, *oldsa;
-
- return; // XXX
-
- oldsa= NULL; // XXX curarea;
-
-/// sa= G.curscreen->areabase.first;
- while(sa) {
- if (sa->spacetype==SPACE_VIEW3D) {
- /* use mywinget() here: othwerwise it draws in header */
-// XXX if(sa->win != mywinget()) areawinset(sa->win);
-// XXX scrarea_do_windraw(sa);
- }
- sa= sa->next;
- }
-// XXX screen_swapbuffers();
-
-// XXX if(oldsa && oldsa!=curarea) areawinset(oldsa->win);
-}
-
diff --git a/source/blender/radiosity/intern/source/radfactors.c b/source/blender/radiosity/intern/source/radfactors.c
deleted file mode 100644
index b87473dd811..00000000000
--- a/source/blender/radiosity/intern/source/radfactors.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/* ***************************************
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- formfactors.c nov/dec 1992
-
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_rand.h"
-
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-#include "RE_render_ext.h" /* for `RE_zbufferall_radio and RE_zbufferall_radio */
-
-/* locals */
-static void rad_setmatrices(RadView *vw);
-static void clearsubflagelem(RNode *rn);
-static void setsubflagelem(RNode *rn);
-
-RadView hemitop, hemiside;
-
-float calcStokefactor(RPatch *shoot, RPatch *rp, RNode *rn, float *area)
-{
- float tvec[3], fac;
- float vec[4][3]; /* vectors of shoot->cent to vertices rp */
- float cross[4][3]; /* cross products of this */
- float rad[4]; /* anlgles between vecs */
-
- /* test for direction */
- VecSubf(tvec, shoot->cent, rp->cent);
- if( tvec[0]*shoot->norm[0]+ tvec[1]*shoot->norm[1]+ tvec[2]*shoot->norm[2]>0.0)
- return 0.0;
-
- if(rp->type==4) {
-
- /* corner vectors */
- VecSubf(vec[0], shoot->cent, rn->v1);
- VecSubf(vec[1], shoot->cent, rn->v2);
- VecSubf(vec[2], shoot->cent, rn->v3);
- VecSubf(vec[3], shoot->cent, rn->v4);
-
- Normalize(vec[0]);
- Normalize(vec[1]);
- Normalize(vec[2]);
- Normalize(vec[3]);
-
- /* cross product */
- Crossf(cross[0], vec[0], vec[1]);
- Crossf(cross[1], vec[1], vec[2]);
- Crossf(cross[2], vec[2], vec[3]);
- Crossf(cross[3], vec[3], vec[0]);
- Normalize(cross[0]);
- Normalize(cross[1]);
- Normalize(cross[2]);
- Normalize(cross[3]);
-
- /* angles */
- rad[0]= vec[0][0]*vec[1][0]+ vec[0][1]*vec[1][1]+ vec[0][2]*vec[1][2];
- rad[1]= vec[1][0]*vec[2][0]+ vec[1][1]*vec[2][1]+ vec[1][2]*vec[2][2];
- rad[2]= vec[2][0]*vec[3][0]+ vec[2][1]*vec[3][1]+ vec[2][2]*vec[3][2];
- rad[3]= vec[3][0]*vec[0][0]+ vec[3][1]*vec[0][1]+ vec[3][2]*vec[0][2];
-
- rad[0]= acos(rad[0]);
- rad[1]= acos(rad[1]);
- rad[2]= acos(rad[2]);
- rad[3]= acos(rad[3]);
-
- /* Stoke formula */
- VecMulf(cross[0], rad[0]);
- VecMulf(cross[1], rad[1]);
- VecMulf(cross[2], rad[2]);
- VecMulf(cross[3], rad[3]);
-
- VECCOPY(tvec, shoot->norm);
- fac= tvec[0]*cross[0][0]+ tvec[1]*cross[0][1]+ tvec[2]*cross[0][2];
- fac+= tvec[0]*cross[1][0]+ tvec[1]*cross[1][1]+ tvec[2]*cross[1][2];
- fac+= tvec[0]*cross[2][0]+ tvec[1]*cross[2][1]+ tvec[2]*cross[2][2];
- fac+= tvec[0]*cross[3][0]+ tvec[1]*cross[3][1]+ tvec[2]*cross[3][2];
- }
- else {
- /* corner vectors */
- VecSubf(vec[0], shoot->cent, rn->v1);
- VecSubf(vec[1], shoot->cent, rn->v2);
- VecSubf(vec[2], shoot->cent, rn->v3);
-
- Normalize(vec[0]);
- Normalize(vec[1]);
- Normalize(vec[2]);
-
- /* cross product */
- Crossf(cross[0], vec[0], vec[1]);
- Crossf(cross[1], vec[1], vec[2]);
- Crossf(cross[2], vec[2], vec[0]);
- Normalize(cross[0]);
- Normalize(cross[1]);
- Normalize(cross[2]);
-
- /* angles */
- rad[0]= vec[0][0]*vec[1][0]+ vec[0][1]*vec[1][1]+ vec[0][2]*vec[1][2];
- rad[1]= vec[1][0]*vec[2][0]+ vec[1][1]*vec[2][1]+ vec[1][2]*vec[2][2];
- rad[2]= vec[2][0]*vec[0][0]+ vec[2][1]*vec[0][1]+ vec[2][2]*vec[0][2];
-
- rad[0]= acos(rad[0]);
- rad[1]= acos(rad[1]);
- rad[2]= acos(rad[2]);
-
- /* Stoke formula */
- VecMulf(cross[0], rad[0]);
- VecMulf(cross[1], rad[1]);
- VecMulf(cross[2], rad[2]);
-
- VECCOPY(tvec, shoot->norm);
- fac= tvec[0]*cross[0][0]+ tvec[1]*cross[0][1]+ tvec[2]*cross[0][2];
- fac+= tvec[0]*cross[1][0]+ tvec[1]*cross[1][1]+ tvec[2]*cross[1][2];
- fac+= tvec[0]*cross[2][0]+ tvec[1]*cross[2][1]+ tvec[2]*cross[2][2];
- }
-
- *area= -fac/(2.0*PI);
- return (*area * (shoot->area/rn->area));
-}
-
-
-void calcTopfactors()
-{
- float xsq , ysq, xysq;
- float n;
- float *fp;
- int a, b, hres;
-
- fp = RG.topfactors;
- hres= RG.hemires/2;
- n= hres;
-
- for (a=0; a<hres; a++) {
-
- ysq= (n- ((float)a+0.5))/n;
- ysq*= ysq;
-
- for ( b=0 ; b<hres ; b++ ) {
-
- xsq= ( n-((float)b+ 0.5) )/n;
- xsq*= xsq;
- xysq= xsq+ ysq+ 1.0 ;
- xysq*= xysq;
-
- *fp++ = 1.0/(xysq* PI* n*n);
- }
- }
-
-}
-
-void calcSidefactors()
-{
- float xsq , ysq, xysq;
- float n, y;
- float *fp;
- int a, b, hres;
-
- fp = RG.sidefactors;
- hres= RG.hemires/2;
- n= hres;
-
- for (a=0; a<hres; a++) {
-
- y= (n- ((float)a+0.5))/n;
- ysq= y*y;
-
- for ( b=0 ; b<hres ; b++ ) {
-
- xsq= ( n-((float)b+ 0.5) )/n;
- xsq*= xsq;
- xysq= xsq+ ysq+ 1.0 ;
- xysq*= xysq;
-
- *fp++ = y/(xysq* PI* n*n);
- }
- }
-
-}
-
-
-void initradiosity()
-{
- /* allocates and makes LUTs for top/side factors */
- /* allocates and makes index array */
- int a, hres2;
-
- if(RG.topfactors) MEM_freeN(RG.topfactors);
- if(RG.sidefactors) MEM_freeN(RG.sidefactors);
- if(RG.index) MEM_freeN(RG.index);
-
- RG.topfactors= MEM_callocN(RG.hemires*RG.hemires, "initradiosity");
- calcTopfactors();
- RG.sidefactors= MEM_callocN(RG.hemires*RG.hemires, "initradiosity1");
- calcSidefactors();
-
- RG.index= MEM_callocN(4*RG.hemires, "initradiosity3");
- hres2= RG.hemires/2;
- for(a=0; a<RG.hemires; a++) {
- RG.index[a]= a<hres2 ? a: (hres2-1-( a % hres2 ));
- }
-
-}
-
-void rad_make_hocos(RadView *vw)
-{
- /* float hoco[4]; */
- /* int a; */
-
- /* for(a=0; a< R.totvert;a++) { */
- /* projectvert(vec, ver->ho); */
- /* ver->clip = testclip(ver->ho); */
-/* */
- /* } */
-}
-
-static void rad_setmatrices(RadView *vw) /* for hemi's */
-{
- float up1[3], len, twist;
-
- i_lookat(vw->cam[0], vw->cam[1], vw->cam[2], vw->tar[0], vw->tar[1], vw->tar[2], 0, vw->viewmat);
- up1[0] = vw->viewmat[0][0]*vw->up[0] + vw->viewmat[1][0]*vw->up[1] + vw->viewmat[2][0]*vw->up[2];
- up1[1] = vw->viewmat[0][1]*vw->up[0] + vw->viewmat[1][1]*vw->up[1] + vw->viewmat[2][1]*vw->up[2];
- up1[2] = vw->viewmat[0][2]*vw->up[0] + vw->viewmat[1][2]*vw->up[1] + vw->viewmat[2][2]*vw->up[2];
-
- len= up1[0]*up1[0]+up1[1]*up1[1];
- if(len>0.0) {
- twist= -atan2(up1[0], up1[1]);
- }
- else twist= 0.0;
-
- i_lookat(vw->cam[0], vw->cam[1], vw->cam[2], vw->tar[0], vw->tar[1], vw->tar[2], (180.0*twist/M_PI), vw->viewmat);
-
- /* window matrix was set in inithemiwindows */
-
-}
-
-
-void hemizbuf(RadView *vw)
-{
- float *factors;
- unsigned int *rz;
- int a, b, inda, hres;
-
- rad_setmatrices(vw);
- RE_zbufferall_radio(vw, RG.elem, RG.totelem, RG.re); /* Render for when we got renderfaces */
-
- /* count factors */
- if(vw->recty==vw->rectx) factors= RG.topfactors;
- else factors= RG.sidefactors;
- hres= RG.hemires/2;
-
- rz= vw->rect;
- for(a=0; a<vw->recty; a++) {
- inda= hres*RG.index[a];
- for(b=0; b<vw->rectx; b++, rz++) {
- if(*rz<RG.totelem) {
- RG.formfactors[*rz]+= factors[inda+RG.index[b]];
- }
- }
- }
-}
-
-int makeformfactors(RPatch *shoot)
-{
- RNode **re;
- float len, vec[3], up[3], side[3], tar[5][3], *fp;
- int a=0, overfl;
-
- if(RG.totelem==0) return 0;
-
- memset(RG.formfactors, 0, 4*RG.totelem);
-
- /* set up hemiview */
- /* first: random upvector */
- do {
- a++;
- vec[0]= (float)BLI_drand();
- vec[1]= (float)BLI_drand();
- vec[2]= (float)BLI_drand();
- Crossf(up, shoot->norm, vec);
- len= Normalize(up);
- /* this safety for input normals that are zero or illegal sized */
- if(a>3) return 0;
- } while(len==0.0 || len>1.0);
-
- VECCOPY(hemitop.up, up);
- VECCOPY(hemiside.up, shoot->norm);
-
- Crossf(side, shoot->norm, up);
-
- /* five targets */
- VecAddf(tar[0], shoot->cent, shoot->norm);
- VecAddf(tar[1], shoot->cent, up);
- VecSubf(tar[2], shoot->cent, up);
- VecAddf(tar[3], shoot->cent, side);
- VecSubf(tar[4], shoot->cent, side);
-
- /* camera */
- VECCOPY(hemiside.cam, shoot->cent);
- VECCOPY(hemitop.cam, shoot->cent);
-
- /* do it! */
- VECCOPY(hemitop.tar, tar[0]);
- hemizbuf(&hemitop);
-
- for(a=1; a<5; a++) {
- VECCOPY(hemiside.tar, tar[a]);
- hemizbuf(&hemiside);
- }
-
- /* convert factors to real radiosity */
- re= RG.elem;
- fp= RG.formfactors;
-
- overfl= 0;
- for(a= RG.totelem; a>0; a--, re++, fp++) {
-
- if(*fp!=0.0) {
-
- *fp *= shoot->area/(*re)->area;
-
- if(*fp>1.0) {
- overfl= 1;
- *fp= 1.0001;
- }
- }
- }
-
- if(overfl) {
- if(shoot->first->down1) {
- splitpatch(shoot);
- return 0;
- }
- }
-
- return 1;
-}
-
-void applyformfactors(RPatch *shoot)
-{
- RPatch *rp;
- RNode **el, *rn;
- float *fp, *ref, unr, ung, unb, r, g, b, w;
- int a;
-
- unr= shoot->unshot[0];
- ung= shoot->unshot[1];
- unb= shoot->unshot[2];
-
- fp= RG.formfactors;
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++, fp++) {
- rn= *el;
- if(*fp!= 0.0) {
- rp= rn->par;
- ref= rp->ref;
-
- r= (*fp)*unr*ref[0];
- g= (*fp)*ung*ref[1];
- b= (*fp)*unb*ref[2];
-
- w= rn->area/rp->area;
- rn->totrad[0]+= r;
- rn->totrad[1]+= g;
- rn->totrad[2]+= b;
-
- rp->unshot[0]+= w*r;
- rp->unshot[1]+= w*g;
- rp->unshot[2]+= w*b;
- }
- }
-
- shoot->unshot[0]= shoot->unshot[1]= shoot->unshot[2]= 0.0;
-}
-
-RPatch *findshootpatch()
-{
- RPatch *rp, *shoot;
- float energy, maxenergy;
-
- shoot= 0;
- maxenergy= 0.0;
- rp= RG.patchbase.first;
- while(rp) {
- energy= rp->unshot[0]*rp->area;
- energy+= rp->unshot[1]*rp->area;
- energy+= rp->unshot[2]*rp->area;
-
- if(energy>maxenergy) {
- shoot= rp;
- maxenergy= energy;
- }
- rp= rp->next;
- }
-
- if(shoot) {
- maxenergy/= RG.totenergy;
- if(maxenergy<RG.convergence) return 0;
- }
-
- return shoot;
-}
-
-void setnodeflags(RNode *rn, int flag, int set)
-{
-
- if(rn->down1) {
- setnodeflags(rn->down1, flag, set);
- setnodeflags(rn->down2, flag, set);
- }
- else {
- if(set) rn->f |= flag;
- else rn->f &= ~flag;
- }
-}
-
-void backface_test(RPatch *shoot)
-{
- RPatch *rp;
- float tvec[3];
-
- rp= RG.patchbase.first;
- while(rp) {
- if(rp!=shoot) {
-
- VecSubf(tvec, shoot->cent, rp->cent);
- if( tvec[0]*rp->norm[0]+ tvec[1]*rp->norm[1]+ tvec[2]*rp->norm[2]<0.0) {
- setnodeflags(rp->first, RAD_BACKFACE, 1);
- }
- }
- rp= rp->next;
- }
-}
-
-void clear_backface_test()
-{
- RNode **re;
- int a;
-
- re= RG.elem;
- for(a= RG.totelem-1; a>=0; a--, re++) {
- (*re)->f &= ~RAD_BACKFACE;
- }
-
-}
-
-void rad_init_energy()
-{
- /* call before shooting */
- /* keep patches and elements, clear all data */
- RNode **el, *rn;
- RPatch *rp;
- int a;
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- VECCOPY(rn->totrad, rn->par->emit);
- }
-
- RG.totenergy= 0.0;
- rp= RG.patchbase.first;
- while(rp) {
- VECCOPY(rp->unshot, rp->emit);
-
- RG.totenergy+= rp->unshot[0]*rp->area;
- RG.totenergy+= rp->unshot[1]*rp->area;
- RG.totenergy+= rp->unshot[2]*rp->area;
-
- rp->f= 0;
-
- rp= rp->next;
- }
-}
-
-void progressiverad()
-{
- RPatch *shoot;
- float unshot[3];
- int it= 0;
-
- rad_printstatus();
- rad_init_energy();
-
- shoot=findshootpatch();
-
- while( shoot ) {
-
- setnodeflags(shoot->first, RAD_SHOOT, 1);
-
- backface_test(shoot);
-
- drawpatch_ext(shoot, 0x88FF00);
-
- if(shoot->first->f & RAD_TWOSIDED) {
- VECCOPY(unshot, shoot->unshot);
- VecNegf(shoot->norm);
- if(makeformfactors(shoot))
- applyformfactors(shoot);
- VecNegf(shoot->norm);
- VECCOPY(shoot->unshot, unshot);
- }
-
- if( makeformfactors(shoot) ) {
- applyformfactors(shoot);
-
- it++;
- //XXX set_timecursor(it);
- if( (it & 3)==1 ) {
- make_node_display();
- rad_forcedraw();
- }
- setnodeflags(shoot->first, RAD_SHOOT, 0);
- }
-
- clear_backface_test();
-
- //XXX if(blender_test_break()) break;
- if(RG.maxiter && RG.maxiter<=it) break;
-
- shoot=findshootpatch();
-
- }
-
-}
-
-
-/* ************* subdivideshoot *********** */
-
-void minmaxradelem(RNode *rn, float *min, float *max)
-{
- int c;
-
- if(rn->down1) {
- minmaxradelem(rn->down1, min, max);
- minmaxradelem(rn->down2, min, max);
- }
- else {
- for(c=0; c<3; c++) {
- min[c]= MIN2(min[c], rn->totrad[c]);
- max[c]= MAX2(max[c], rn->totrad[c]);
- }
- }
-}
-
-void minmaxradelemfilt(RNode *rn, float *min, float *max, float *errmin, float *errmax)
-{
- float col[3], area;
- int c;
-
- if(rn->down1) {
- minmaxradelemfilt(rn->down1, min, max, errmin, errmax);
- minmaxradelemfilt(rn->down2, min, max, errmin, errmax);
- }
- else {
- VECCOPY(col, rn->totrad);
-
- for(c=0; c<3; c++) {
- min[c]= MIN2(min[c], col[c]);
- max[c]= MAX2(max[c], col[c]);
- }
-
- VecMulf(col, 2.0);
- area= 2.0;
- if(rn->ed1) {
- VecAddf(col, rn->ed1->totrad, col);
- area+= 1.0;
- }
- if(rn->ed2) {
- VecAddf(col, rn->ed2->totrad, col);
- area+= 1.0;
- }
- if(rn->ed3) {
- VecAddf(col, rn->ed3->totrad, col);
- area+= 1.0;
- }
- if(rn->ed4) {
- VecAddf(col, rn->ed4->totrad, col);
- area+= 1.0;
- }
- VecMulf(col, 1.0/area);
-
- for(c=0; c<3; c++) {
- errmin[c]= MIN2(errmin[c], col[c]);
- errmax[c]= MAX2(errmax[c], col[c]);
- }
- }
-}
-
-static void setsubflagelem(RNode *rn)
-{
-
- if(rn->down1) {
- setsubflagelem(rn->down1);
- setsubflagelem(rn->down2);
- }
- else {
- rn->f |= RAD_SUBDIV;
- }
-}
-
-static void clearsubflagelem(RNode *rn)
-{
-
- if(rn->down1) {
- setsubflagelem(rn->down1);
- setsubflagelem(rn->down2);
- }
- else {
- rn->f &= ~RAD_SUBDIV;
- }
-}
-
-void subdivideshootElements(int it)
-{
- RPatch *rp, *shoot;
- RNode **el, *rn;
- float *fp, err, stoke, area, min[3], max[3], errmin[3], errmax[3];
- int a, b, c, d, e, f, contin;
- int maxlamp;
-
- if(RG.maxsublamp==0) maxlamp= RG.totlamp;
- else maxlamp= RG.maxsublamp;
-
- while(it) {
- rad_printstatus();
- rad_init_energy();
- it--;
-
- for(a=0; a<maxlamp; a++) {
- shoot= findshootpatch();
- if(shoot==0) break;
-
- //XXX set_timecursor(a);
- drawpatch_ext(shoot, 0x88FF00);
-
- setnodeflags(shoot->first, RAD_SHOOT, 1);
- if( makeformfactors(shoot) ) {
-
- fp= RG.formfactors;
- el= RG.elem;
- for(b=RG.totelem; b>0; b--, el++) {
- rn= *el;
-
- if( (rn->f & RAD_SUBDIV)==0 && *fp!=0.0) {
- if(rn->par->emit[0]+rn->par->emit[1]+rn->par->emit[2]==0.0) {
-
- stoke= calcStokefactor(shoot, rn->par, rn, &area);
- if(stoke!= 0.0) {
-
- err= *fp/stoke;
-
- /* area error */
- area*=(0.5*RG.hemires*RG.hemires);
-
- if(area>35.0) {
- if(err<0.95 || err>1.05) {
- if(err>0.05) {
- rn->f |= RAD_SUBDIV;
- rn->par->f |= RAD_SUBDIV;
- }
- }
- }
- }
-
- }
- }
-
- fp++;
-
- }
-
- applyformfactors(shoot);
-
- if( (a & 3)==1 ) {
- make_node_display();
- rad_forcedraw();
- }
-
- setnodeflags(shoot->first, RAD_SHOOT, 0);
- }
- else a--;
-
- //XXX if(blender_test_break()) break;
- }
-
- /* test for extreme small color change within a patch with subdivflag */
-
- rp= RG.patchbase.first;
-
- while(rp) {
- if(rp->f & RAD_SUBDIV) { /* rp has elems that need subdiv */
- /* at least 4 levels deep */
- rn= rp->first->down1;
- if(rn) {
- rn= rn->down1;
- if(rn) {
- rn= rn->down1;
- if(rn) rn= rn->down1;
- }
- }
- if(rn) {
- INIT_MINMAX(min, max);
- /* errmin and max are the filtered colors */
- INIT_MINMAX(errmin, errmax);
- minmaxradelemfilt(rp->first, min, max, errmin, errmax);
-
- /* if small difference between colors: no subdiv */
- /* also test for the filtered ones: but with higher critical level */
-
- contin= 0;
- a= abs( calculatecolor(min[0])-calculatecolor(max[0]));
- b= abs( calculatecolor(errmin[0])-calculatecolor(errmax[0]));
- if(a<15 || b<7) {
- c= abs( calculatecolor(min[1])-calculatecolor(max[1]));
- d= abs( calculatecolor(errmin[1])-calculatecolor(errmax[1]));
- if(c<15 || d<7) {
- e= abs( calculatecolor(min[2])-calculatecolor(max[2]));
- f= abs( calculatecolor(errmin[2])-calculatecolor(errmax[2]));
- if(e<15 || f<7) {
- contin= 1;
- clearsubflagelem(rp->first);
- /* printf("%d %d %d %d %d %d\n", a, b, c, d, e, f); */
- }
- }
- }
- if(contin) {
- drawpatch_ext(rp, 0xFFFF);
- }
- }
- }
- rp->f &= ~RAD_SUBDIV;
- rp= rp->next;
- }
-
- contin= 0;
-
- el= RG.elem;
- for(b=RG.totelem; b>0; b--, el++) {
- rn= *el;
- if(rn->f & RAD_SUBDIV) {
- rn->f-= RAD_SUBDIV;
- subdivideNode(rn, 0);
- if(rn->down1) {
- subdivideNode(rn->down1, 0);
- subdivideNode(rn->down2, 0);
- contin= 1;
- }
- }
- }
- makeGlobalElemArray();
-
- //XXX if(contin==0 || blender_test_break()) break;
- }
-
- make_node_display();
-}
-
-void subdivideshootPatches(int it)
-{
- RPatch *rp, *shoot, *next;
- float *fp, err, stoke, area;
- int a, contin;
- int maxlamp;
-
- if(RG.maxsublamp==0) maxlamp= RG.totlamp;
- else maxlamp= RG.maxsublamp;
-
- while(it) {
- rad_printstatus();
- rad_init_energy();
- it--;
-
- for(a=0; a<maxlamp; a++) {
- shoot= findshootpatch();
- if(shoot==0) break;
-
- //XXX set_timecursor(a);
- drawpatch_ext(shoot, 0x88FF00);
-
- setnodeflags(shoot->first, RAD_SHOOT, 1);
-
- if( makeformfactors(shoot) ) {
-
- fp= RG.formfactors;
- rp= RG.patchbase.first;
- while(rp) {
- if(*fp!=0.0 && rp!=shoot) {
-
- stoke= calcStokefactor(shoot, rp, rp->first, &area);
- if(stoke!= 0.0) {
- if(area>.1) { /* does patch receive more than (about)10% of energy? */
- rp->f= RAD_SUBDIV;
- }
- else {
-
- err= *fp/stoke;
-
- /* area error */
- area*=(0.5*RG.hemires*RG.hemires);
-
- if(area>45.0) {
- if(err<0.95 || err>1.05) {
- if(err>0.05) {
-
- rp->f= RAD_SUBDIV;
-
- }
- }
- }
- }
- }
- }
- fp++;
-
- rp= rp->next;
- }
-
- applyformfactors(shoot);
-
- if( (a & 3)==1 ) {
- make_node_display();
- rad_forcedraw();
- }
-
- setnodeflags(shoot->first, RAD_SHOOT, 0);
-
- //XXX if(blender_test_break()) break;
- }
- else a--;
-
- }
-
- contin= 0;
-
- rp= RG.patchbase.first;
- while(rp) {
- next= rp->next;
- if(rp->f & RAD_SUBDIV) {
- if(rp->emit[0]+rp->emit[1]+rp->emit[2]==0.0) {
- contin= 1;
- subdivideNode(rp->first, 0);
- if(rp->first->down1) {
- subdivideNode(rp->first->down1, 0);
- subdivideNode(rp->first->down2, 0);
- }
- }
- }
- rp= next;
- }
-
- converttopatches();
- makeGlobalElemArray();
-
- //XXX if(contin==0 || blender_test_break()) break;
- }
- make_node_display();
-}
-
-void inithemiwindows()
-{
- RadView *vw;
-
- /* the hemiwindows */
- vw= &(hemitop);
- memset(vw, 0, sizeof(RadView));
- vw->rectx= RG.hemires;
- vw->recty= RG.hemires;
- vw->rectz= MEM_mallocN(sizeof(int)*vw->rectx*vw->recty, "initwindows");
- vw->rect= MEM_mallocN(sizeof(int)*vw->rectx*vw->recty, "initwindows");
- vw->mynear= RG.maxsize/2000.0;
- vw->myfar= 2.0*RG.maxsize;
- vw->wx1= -vw->mynear;
- vw->wx2= vw->mynear;
- vw->wy1= -vw->mynear;
- vw->wy2= vw->mynear;
-
- i_window(vw->wx1, vw->wx2, vw->wy1, vw->wy2, vw->mynear, vw->myfar, vw->winmat);
-
- hemiside= hemitop;
-
- vw= &(hemiside);
- vw->recty/= 2;
- vw->wy1= vw->wy2;
- vw->wy2= 0.0;
-
- i_window(vw->wx1, vw->wx2, vw->wy1, vw->wy2, vw->mynear, vw->myfar, vw->winmat);
-
-}
-
-void closehemiwindows()
-{
-
- if(hemiside.rect) MEM_freeN(hemiside.rect);
- if(hemiside.rectz) MEM_freeN(hemiside.rectz);
- hemiside.rectz= 0;
- hemiside.rect= 0;
- hemitop.rectz= 0;
- hemitop.rect= 0;
-}
diff --git a/source/blender/radiosity/intern/source/radio.c b/source/blender/radiosity/intern/source/radio.c
deleted file mode 100644
index 63032b2d603..00000000000
--- a/source/blender/radiosity/intern/source/radio.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/* ***************************************
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- radio.c nov/dec 1992
- may 1999
-
- $Id$
-
- - mainloop
- - interactivity
-
-
- - PREPROCES
- - collect meshes
- - spitconnected (all faces with different color and normals)
- - setedgepointers (nodes pointing to neighbours)
-
- - EDITING
- - min-max patch en min-max element size
- - using this info patches subdividing
- - lamp subdivide
-
- - if there are too many lamps for subdivide shooting:
- - temporal join patches
-
- - SUBDIVIDE SHOOTING
- - except for last shooting, this defines patch subdivide
- - if subdivided patches still > 2*minsize : continue
- - at the end create as many elements as possible
- - als store if lamp (can still) cause subdivide.
-
- - REFINEMENT SHOOTING
- - test for overflows (shootpatch subdivide)
- - testen for extreme color transitions:
- - if possible: shootpatch subdivide
- - elements subdivide = start over ?
- - continue itterate until ?
-
- - DEFINITIVE SHOOTING
- - user indicates how many faces maximum and duration of itteration.
-
- - POST PROCESS
- - join element- nodes when nothing happens in it (filter nodes, filter faces)
- - define gamma & mul
-
- *************************************** */
-
-#include <math.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-#include "PIL_time.h"
-
-#include "BLI_blenlib.h"
-
-#include "DNA_object_types.h"
-#include "DNA_radio_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* locals? This one was already done in radio.h... */
-/* void rad_status_str(char *str); */
-
-RadGlobal RG= {0, 0};
-
-void freeAllRad(Scene *scene)
-{
- Base *base;
- extern int Ntotvert, Ntotnode, Ntotpatch;
-
- /* clear flag that disables drawing the meshes */
- if(scene) {
- base= (scene->base.first);
- while(base) {
- if(base->object->type==OB_MESH) {
- base->flag &= ~OB_RADIO;
- }
- base= base->next;
- }
- }
-
- free_fastAll(); /* verts, nodes, patches */
- RG.patchbase.first= RG.patchbase.last= 0;
- Ntotvert= Ntotnode= Ntotpatch= 0;
-
- closehemiwindows(); /* not real windows anymore... */
- if(RG.elem) MEM_freeN(RG.elem);
- RG.elem= 0;
- if(RG.verts) MEM_freeN(RG.verts);
- RG.verts= 0;
- if(RG.topfactors) MEM_freeN(RG.topfactors);
- RG.topfactors= 0;
- if(RG.sidefactors) MEM_freeN(RG.sidefactors);
- RG.sidefactors= 0;
- if(RG.formfactors) MEM_freeN(RG.formfactors);
- RG.formfactors= 0;
- if(RG.index) MEM_freeN(RG.index);
- RG.index= 0;
- if(RG.facebase) {
- init_face_tab(); /* frees all tables */
- MEM_freeN(RG.facebase);
- RG.facebase= 0;
- }
-
- if(RG.mfdata) {
- CustomData_free(RG.mfdata, RG.mfdatatot);
- MEM_freeN(RG.mfdata);
- MEM_freeN(RG.mfdatanodes);
- RG.mfdatanodes= NULL;
- RG.mfdata= NULL;
- RG.mfdatatot= 0;
- }
- RG.totelem= RG.totpatch= RG.totvert= RG.totface= RG.totlamp= RG.totmat= 0;
-}
-
-int rad_phase()
-{
- int flag= 0;
-
- if(RG.totpatch) flag |= RAD_PHASE_PATCHES;
- if(RG.totface) flag |= RAD_PHASE_FACES;
-
- return flag;
-}
-
-void rad_status_str(char *str)
-{
- extern int totfastmem;
- int tot;
- char *phase;
-
- tot= (RG.totface*sizeof(Face))/1024;
- tot+= totfastmem/1024;
-
- if(RG.phase==RAD_SHOOTE) phase= "Phase: ELEMENT SUBD, ";
- else if(RG.phase==RAD_SHOOTP) phase= "Phase: PATCH SUBD, ";
- else if(RG.phase==RAD_SOLVE) phase= "Phase: SOLVE, ";
- else if(RG.totpatch==0) phase= "Phase: COLLECT MESHES ";
- else if(RG.totface) phase= "Phase: FINISHED, ";
- else phase= "Phase: INIT, ";
-
- if(RG.totpatch==0) strcpy(str, phase);
- else sprintf(str, "%s TotPatch: %d TotElem: %d Emit: %d Faces %d Mem: %d k ", phase, RG.totpatch, RG.totelem, RG.totlamp, RG.totface, tot);
-
- if(RG.phase==RAD_SOLVE) strcat(str, "(press ESC to stop)");
-}
-
-void rad_printstatus()
-{
- /* actions always are started from a buttonswindow */
-// XX if(curarea) {
-// scrarea_do_windraw(curarea);
-// screen_swapbuffers();
-// }
-}
-
-void rad_setlimits(Scene *scene)
-{
- Radio *rad= scene->radio;
- float fac;
-
- fac= 0.0005*rad->pama;
- RG.patchmax= RG.maxsize*fac;
- RG.patchmax*= RG.patchmax;
- fac= 0.0005*rad->pami;
- RG.patchmin= RG.maxsize*fac;
- RG.patchmin*= RG.patchmin;
-
- fac= 0.0005*rad->elma;
- RG.elemmax= RG.maxsize*fac;
- RG.elemmax*= RG.elemmax;
- fac= 0.0005*rad->elmi;
- RG.elemmin= RG.maxsize*fac;
- RG.elemmin*= RG.elemmin;
-}
-
-void set_radglobal(Scene *scene)
-{
- /* always call before any action is performed */
- Radio *rad= scene->radio;
-
- if(RG.radio==0) {
- /* firsttime and to be sure */
- memset(&RG, 0, sizeof(RadGlobal));
- }
-
- if(rad==0) return;
-
- if(rad != RG.radio) {
- if(RG.radio) freeAllRad(scene);
- memset(&RG, 0, sizeof(RadGlobal));
- RG.radio= rad;
- }
-
- RG.hemires= rad->hemires & 0xFFF0;
- RG.drawtype= rad->drawtype;
- RG.flag= rad->flag;
- RG.subshootp= rad->subshootp;
- RG.subshoote= rad->subshoote;
- RG.nodelim= rad->nodelim;
- RG.maxsublamp= rad->maxsublamp;
- RG.maxnode= 2*rad->maxnode; /* in button:max elem, subdividing! */
- RG.convergence= rad->convergence/1000.0;
- RG.radfac= rad->radfac;
- RG.gamma= rad->gamma;
- RG.maxiter= rad->maxiter;
-
- RG.re= NULL; /* struct render, for when call it from render engine */
-
- rad_setlimits(scene);
-}
-
-/* called from buttons.c */
-void add_radio(Scene *scene)
-{
- Radio *rad;
-
- if(scene->radio) MEM_freeN(scene->radio);
- rad= scene->radio= MEM_callocN(sizeof(Radio), "radio");
-
- rad->hemires= 300;
- rad->convergence= 0.1;
- rad->radfac= 30.0;
- rad->gamma= 2.0;
- rad->drawtype= RAD_SOLID;
- rad->subshootp= 1;
- rad->subshoote= 2;
- rad->maxsublamp= 0;
-
- rad->pama= 500;
- rad->pami= 200;
- rad->elma= 100;
- rad->elmi= 20;
- rad->nodelim= 0;
- rad->maxnode= 10000;
- rad->maxiter= 120; // arbitrary
- rad->flag= 2;
- set_radglobal(scene);
-}
-
-void delete_radio(Scene *scene)
-{
- freeAllRad(scene);
- if(scene->radio) MEM_freeN(scene->radio);
- scene->radio= 0;
-
- RG.radio= 0;
-}
-
-int rad_go(Scene *scene) /* return 0 when user escapes */
-{
- double stime= PIL_check_seconds_timer();
- int retval;
-
- if(RG.totface) return 0;
-
- G.afbreek= 0;
-
- set_radglobal(scene);
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views */
-
- maxsizePatches();
-
- setnodelimit(RG.patchmin);
- RG.phase= RAD_SHOOTP;
- subdivideshootPatches(RG.subshootp);
-
- setnodelimit(RG.elemmin);
- RG.phase= RAD_SHOOTE;
- subdivideshootElements(RG.subshoote);
-
- setnodelimit(RG.patchmin);
- subdividelamps();
-
- setnodelimit(RG.elemmin);
-
- RG.phase= RAD_SOLVE;
- subdiv_elements();
-
- progressiverad();
-
- removeEqualNodes(RG.nodelim);
-
- make_face_tab(); /* now anchored */
-
- closehemiwindows();
- RG.phase= 0;
-
- stime= PIL_check_seconds_timer()-stime;
- printf("Radiosity solving time: %dms\n", (int) (stime*1000));
-
- if(G.afbreek==1) retval= 1;
- else retval= 0;
-
- G.afbreek= 0;
-
- return retval;
-}
-
-void rad_subdivshootpatch(Scene *scene)
-{
-
- if(RG.totface) return;
-
- G.afbreek= 0;
-
- set_radglobal(scene);
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views */
-
- subdivideshootPatches(1);
-
- removeEqualNodes(RG.nodelim);
- closehemiwindows();
-
-// XXX allqueue(REDRAWVIEW3D, 1);
-}
-
-void rad_subdivshootelem(Scene *scene)
-{
-
- if(RG.totface) return;
-
- G.afbreek= 0;
-
- set_radglobal(scene);
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views */
-
- subdivideshootElements(1);
-
- removeEqualNodes(RG.nodelim);
- closehemiwindows();
-
-// XXX allqueue(REDRAWVIEW3D, 1);
-}
-
-void rad_limit_subdivide(Scene *scene)
-{
-
- if(scene->radio==0) return;
-
- set_radglobal(scene);
-
- if(RG.totpatch==0) {
- /* printf("exit: no relevant data\n"); */
- return;
- }
-
- maxsizePatches();
-
- init_face_tab(); /* free faces */
-}
diff --git a/source/blender/radiosity/intern/source/radnode.c b/source/blender/radiosity/intern/source/radnode.c
deleted file mode 100644
index fa23ca5da57..00000000000
--- a/source/blender/radiosity/intern/source/radnode.c
+++ /dev/null
@@ -1,1103 +0,0 @@
-/* ***************************************
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- node.c nov/dec 1992
- may 1999
-
- $Id$
-
- *************************************** */
-
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-
-#include "BLO_sys_types.h" // for intptr_t support
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* locals */
-static void *malloc_fast(int size);
-static void *calloc_fast(int size);
-static void free_fast(void *poin, int siz);
-static void deleteTriNodes(RNode *node);
-/* lower because of local type define */
-/* void check_mallocgroup(MallocGroup *mg); */
-
-
-/* ********** fastmalloc ************** */
-
-#define MAL_GROUPSIZE 256
-#define MAL_AVAILABLE 1
-#define MAL_FULL 2
-
-
-
-
-ListBase MallocBase= {0, 0};
-int totfastmem= 0;
-
-typedef struct MallocGroup {
- struct MallocGroup *next, *prev;
- short size, flag;
- short curfree, tot;
- char flags[MAL_GROUPSIZE];
- char *data;
-} MallocGroup;
-
-/* one more local */
-void check_mallocgroup(MallocGroup *mg);
-
-void check_mallocgroup(MallocGroup *mg)
-{
- int a;
- char *cp;
-
- if(mg->tot==MAL_GROUPSIZE) {
- mg->flag= MAL_FULL;
- return;
- }
-
- cp= mg->flags;
-
- if(mg->curfree<MAL_GROUPSIZE-1) {
- if(cp[mg->curfree+1]==0) {
- mg->curfree++;
- return;
- }
- }
- if(mg->curfree>0) {
- if(cp[mg->curfree-1]==0) {
- mg->curfree--;
- return;
- }
- }
-
- for(a=0; a<MAL_GROUPSIZE; a++) {
- if(cp[a]==0) {
- mg->curfree= a;
- return;
- }
- }
- printf("fastmalloc: shouldnt be here\n");
-}
-
-static void *malloc_fast(int size)
-{
- MallocGroup *mg;
- void *retval;
-
- mg= MallocBase.last;
- while(mg) {
- if(mg->size==size) {
- if(mg->flag & MAL_AVAILABLE) {
- mg->flags[mg->curfree]= 1;
- mg->tot++;
- retval= mg->data+mg->curfree*mg->size;
- check_mallocgroup(mg);
- return retval;
- }
- }
- mg= mg->prev;
- }
-
- /* no free block found */
- mg= MEM_callocN(sizeof(MallocGroup), "mallocgroup");
- BLI_addtail(&MallocBase, mg);
- mg->data= MEM_mallocN(MAL_GROUPSIZE*size, "mallocgroupdata");
- mg->flag= MAL_AVAILABLE;
- mg->flags[0]= 1;
- mg->curfree= 1;
- mg->size= size;
- mg->tot= 1;
-
- totfastmem+= sizeof(MallocGroup)+MAL_GROUPSIZE*size;
-
- return mg->data;
-}
-
-static void *calloc_fast(int size)
-{
- void *poin;
-
- poin= malloc_fast(size);
- memset(poin, 0, size);
-
- return poin;
-}
-
-static void free_fast(void *poin, int size)
-{
- MallocGroup *mg;
- intptr_t val;
-
- mg= MallocBase.last;
- while(mg) {
- if(mg->size==size) {
- if( ((intptr_t)poin) >= ((intptr_t)mg->data) ) {
- if( ((intptr_t)poin) < ((intptr_t)(mg->data+MAL_GROUPSIZE*size)) ) {
- val= ((intptr_t)poin) - ((intptr_t)mg->data);
- val/= size;
- mg->curfree= val;
- mg->flags[val]= 0;
- mg->flag= MAL_AVAILABLE;
-
- mg->tot--;
- if(mg->tot==0) {
- BLI_remlink(&MallocBase, mg);
- MEM_freeN(mg->data);
- MEM_freeN(mg);
- totfastmem-= sizeof(MallocGroup)+MAL_GROUPSIZE*size;
- }
- return;
- }
- }
- }
- mg= mg->prev;
- }
- printf("fast free: pointer not in memlist %p size %d\n",
- poin, size);
-}
-
-/* security: only one function in a time can use it */
-static char *fastmallocstr= 0;
-
-void free_fastAll()
-{
- MallocGroup *mg;
-
- mg= MallocBase.first;
- while(mg) {
- BLI_remlink(&MallocBase, mg);
- MEM_freeN(mg->data);
- MEM_freeN(mg);
- mg= MallocBase.first;
- }
- totfastmem= 0;
- fastmallocstr= 0;
-}
-
-void start_fastmalloc(char *str)
-{
- if(fastmallocstr) {
-// XXX error("Fastmalloc in use: %s", fastmallocstr);
- return;
- }
- fastmallocstr= str;
-}
-
-/* **************************************** */
-
-float nodelimit;
-
-void setnodelimit(float limit)
-{
- nodelimit= limit;
-
-}
-
-/* ************ memory management *********** */
-
-int Ntotvert=0, Ntotnode=0, Ntotpatch=0;
-
-float *mallocVert()
-{
- Ntotvert++;
- return (float *)malloc_fast(16);
-}
-
-float *callocVert()
-{
- Ntotvert++;
- return (float *)calloc_fast(16);
-}
-
-void freeVert(float *vert)
-{
- free_fast(vert, 16);
- Ntotvert--;
-}
-
-int totalRadVert()
-{
- return Ntotvert;
-}
-
-RNode *mallocNode()
-{
- Ntotnode++;
- return (RNode *)malloc_fast(sizeof(RNode));
-}
-
-RNode *callocNode()
-{
- Ntotnode++;
- return (RNode *)calloc_fast(sizeof(RNode));
-}
-
-void freeNode(RNode *node)
-{
- free_fast(node, sizeof(RNode));
- Ntotnode--;
-}
-
-void freeNode_recurs(RNode *node)
-{
-
- if(node->down1) {
- freeNode_recurs(node->down1);
- freeNode_recurs(node->down2);
- }
-
- node->down1= node->down2= 0;
- freeNode(node);
-
-}
-
-RPatch *mallocPatch()
-{
- Ntotpatch++;
- return (RPatch *)malloc_fast(sizeof(RPatch));
-}
-
-RPatch *callocPatch()
-{
- Ntotpatch++;
- return (RPatch *)calloc_fast(sizeof(RPatch));
-}
-
-void freePatch(RPatch *patch)
-{
- free_fast(patch, sizeof(RPatch));
- Ntotpatch--;
-}
-
-/* ************ SUBDIVIDE *********** */
-
-
-void replaceAllNode(RNode *neighb, RNode *newn)
-{
- /* changes from all neighbours the edgepointers that point to newn->up in new */
- int ok= 0;
-
-
- if(neighb==0) return;
- if(newn->up==0) return;
-
- if(neighb->ed1==newn->up) {
- neighb->ed1= newn;
- ok= 1;
- }
- else if(neighb->ed2==newn->up) {
- neighb->ed2= newn;
- ok= 1;
- }
- else if(neighb->ed3==newn->up) {
- neighb->ed3= newn;
- ok= 1;
- }
- else if(neighb->ed4==newn->up) {
- neighb->ed4= newn;
- ok= 1;
- }
-
- if(ok && neighb->down1) {
- replaceAllNode(neighb->down1, newn);
- replaceAllNode(neighb->down2, newn);
- }
-}
-
-void replaceAllNodeInv(RNode *neighb, RNode *old)
-{
- /* changes from all neighbours the edgepointers that point to old in old->up */
- if(neighb==0) return;
- if(old->up==0) return;
-
- if(neighb->ed1==old) {
- neighb->ed1= old->up;
- }
- else if(neighb->ed2==old) {
- neighb->ed2= old->up;
- }
- else if(neighb->ed3==old) {
- neighb->ed3= old->up;
- }
- else if(neighb->ed4==old) {
- neighb->ed4= old->up;
- }
-
- if(neighb->down1) {
- replaceAllNodeInv(neighb->down1, old);
- replaceAllNodeInv(neighb->down2, old);
- }
-}
-
-void replaceAllNodeUp(RNode *neighb, RNode *old)
-{
- /* changes from all neighbours the edgepointers that point to old in old->up */
- if(neighb==0) return;
- if(old->up==0) return;
- neighb= neighb->up;
- if(neighb==0) return;
-
- if(neighb->ed1==old) {
- neighb->ed1= old->up;
- }
- else if(neighb->ed2==old) {
- neighb->ed2= old->up;
- }
- else if(neighb->ed3==old) {
- neighb->ed3= old->up;
- }
- else if(neighb->ed4==old) {
- neighb->ed4= old->up;
- }
-
- if(neighb->up) {
- replaceAllNodeUp(neighb, old);
- }
-}
-
-
-void replaceTestNode(RNode *neighb, RNode **edpp, RNode *newn, int level, float *vert)
-{
- /* IF neighb->ed points to newn->up
- * IF edgelevels equal
- IF testvert is in neighb->ed
- change pointers both ways
- ELSE
- RETURN
- ELSE
- IF neighb edgelevel is deeper
- change neighb pointer
-
- */
- int ok= 0;
-
- if(neighb==0) return;
- if(newn->up==0) return;
-
- if(neighb->ed1==newn->up) {
- if(neighb->lev1==level) {
- if(vert==neighb->v1 || vert==neighb->v2) {
- *edpp= neighb;
- neighb->ed1= newn;
- }
- else return;
- }
- else if(neighb->lev1>level) {
- neighb->ed1= newn;
- }
- ok= 1;
- }
- else if(neighb->ed2==newn->up) {
- if(neighb->lev2==level) {
- if(vert==neighb->v2 || vert==neighb->v3) {
- *edpp= neighb;
- neighb->ed2= newn;
- }
- else return;
- }
- else if(neighb->lev2>level) {
- neighb->ed2= newn;
- }
- ok= 1;
- }
- else if(neighb->ed3==newn->up) {
- if(neighb->lev3==level) {
- if(neighb->type==3) {
- if(vert==neighb->v3 || vert==neighb->v1) {
- *edpp= neighb;
- neighb->ed3= newn;
- }
- else return;
- }
- else {
- if(vert==neighb->v3 || vert==neighb->v4) {
- *edpp= neighb;
- neighb->ed3= newn;
- }
- else return;
- }
- }
- else if(neighb->lev3>level) {
- neighb->ed3= newn;
- }
- ok= 1;
- }
- else if(neighb->ed4==newn->up) {
- if(neighb->lev4==level) {
- if(vert==neighb->v4 || vert==neighb->v1) {
- *edpp= neighb;
- neighb->ed4= newn;
- }
- else return;
- }
- else if(neighb->lev4>level) {
- neighb->ed4= newn;
- }
- ok= 1;
- }
-
- if(ok && neighb->down1) {
- replaceTestNode(neighb->down1, edpp, newn, level, vert);
- replaceTestNode(neighb->down2, edpp, newn, level, vert);
- }
-
-}
-
-int setvertexpointersNode(RNode *neighb, RNode *node, int level, float **v1, float **v2)
-{
- /* compares edgelevels , if equal it sets the vertexpointers */
-
- if(neighb==0) return 0;
-
- if(neighb->ed1==node) {
- if(neighb->lev1==level) {
- *v1= neighb->v1;
- *v2= neighb->v2;
- return 1;
- }
- }
- else if(neighb->ed2==node) {
- if(neighb->lev2==level) {
- *v1= neighb->v2;
- *v2= neighb->v3;
- return 1;
- }
- }
- else if(neighb->ed3==node) {
- if(neighb->lev3==level) {
- if(neighb->type==3) {
- *v1= neighb->v3;
- *v2= neighb->v1;
- }
- else {
- *v1= neighb->v3;
- *v2= neighb->v4;
- }
- return 1;
- }
- }
- else if(neighb->ed4==node) {
- if(neighb->lev4==level) {
- *v1= neighb->v4;
- *v2= neighb->v1;
- return 1;
- }
- }
- return 0;
-}
-
-float edlen(float *v1, float *v2)
-{
- return (v1[0]-v2[0])*(v1[0]-v2[0])+ (v1[1]-v2[1])*(v1[1]-v2[1])+ (v1[2]-v2[2])*(v1[2]-v2[2]);
-}
-
-
-void subdivideTriNode(RNode *node, RNode *edge)
-{
- RNode *n1, *n2, *up;
- float fu, fv, fl, *v1, *v2; /* , AreaT3Dfl(); ... from arithb... */
- int uvl;
-
- if(node->down1 || node->down2) {
- /* printf("trinode: subd already done\n"); */
- return;
- }
-
- /* defines subdivide direction */
-
- if(edge==0) {
- /* areathreshold */
- if(node->area<nodelimit) return;
-
- fu= edlen(node->v1, node->v2);
- fv= edlen(node->v2, node->v3);
- fl= edlen(node->v3, node->v1);
-
- if(fu>fv && fu>fl) uvl= 1;
- else if(fv>fu && fv>fl) uvl= 2;
- else uvl= 3;
- }
- else {
-
- if(edge==node->ed1) uvl= 1;
- else if(edge==node->ed2) uvl= 2;
- else uvl= 3;
- }
-
- /* should neighbour nodes be deeper? Recursive! */
- n1= 0;
- if(uvl==1) {
- if(node->ed1 && node->ed1->down1==0) n1= node->ed1;
- }
- else if(uvl==2) {
- if(node->ed2 && node->ed2->down1==0) n1= node->ed2;
- }
- else {
- if(node->ed3 && node->ed3->down1==0) n1= node->ed3;
- }
- if(n1) {
- up= node->up;
- while(up) { /* also test for ed4 !!! */
- if(n1->ed1==up || n1->ed2==up || n1->ed3==up || n1->ed4==up) {
- subdivideNode(n1, up);
- break;
- }
- up= up->up;
- }
- }
-
- /* the subdividing */
- n1= mallocNode();
- memcpy(n1, node, sizeof(RNode));
- n2= mallocNode();
- memcpy(n2, node, sizeof(RNode));
-
- n1->up= node;
- n2->up= node;
-
- node->down1= n1;
- node->down2= n2;
-
- /* subdivide edge 1 */
- if(uvl==1) {
-
- /* FIRST NODE gets edge 2 */
- n1->ed3= n2;
- n1->lev3= 0;
- replaceAllNode(n1->ed2, n1);
- n1->lev1++;
- replaceTestNode(n1->ed1, &(n1->ed1), n1, n1->lev1, n1->v2);
-
- /* SECOND NODE gets edge 3 */
- n2->ed2= n1;
- n2->lev2= 0;
- replaceAllNode(n2->ed3, n2);
- n2->lev1++;
- replaceTestNode(n2->ed1, &(n2->ed1), n2, n2->lev1, n2->v1);
-
- /* NEW VERTEX from edge 1 */
- if( setvertexpointersNode(n1->ed1, n1, n1->lev1, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v1= v2;
- n2->v2= v2;
- }
- else {
- n1->v1= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v1= n2->v2= mallocVert();
- n1->v1[0]= 0.5*(node->v1[0]+ node->v2[0]);
- n1->v1[1]= 0.5*(node->v1[1]+ node->v2[1]);
- n1->v1[2]= 0.5*(node->v1[2]+ node->v2[2]);
- n1->v1[3]= node->v1[3]; /* color */
- }
- }
- else if(uvl==2) {
-
- /* FIRST NODE gets edge 1 */
- n1->ed3= n2;
- n1->lev3= 0;
- replaceAllNode(n1->ed1, n1);
- n1->lev2++;
- replaceTestNode(n1->ed2, &(n1->ed2), n1, n1->lev2, n1->v2);
-
- /* SECOND NODE gets edge 3 */
- n2->ed1= n1;
- n2->lev1= 0;
- replaceAllNode(n2->ed3, n2);
- n2->lev2++;
- replaceTestNode(n2->ed2, &(n2->ed2), n2, n2->lev2, n2->v3);
-
- /* NEW VERTEX from edge 2 */
- if( setvertexpointersNode(n1->ed2, n1, n1->lev2, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v3= v2;
- n2->v2= v2;
- }
- else {
- n1->v3= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v3= n2->v2= mallocVert();
- n1->v3[0]= 0.5*(node->v2[0]+ node->v3[0]);
- n1->v3[1]= 0.5*(node->v2[1]+ node->v3[1]);
- n1->v3[2]= 0.5*(node->v2[2]+ node->v3[2]);
- n1->v3[3]= node->v1[3]; /* color */
- }
- }
- else if(uvl==3) {
-
- /* FIRST NODE gets edge 1 */
- n1->ed2= n2;
- n1->lev2= 0;
- replaceAllNode(n1->ed1, n1);
- n1->lev3++;
- replaceTestNode(n1->ed3, &(n1->ed3), n1, n1->lev3, n1->v1);
-
- /* SECOND NODE gets edge 2 */
- n2->ed1= n1;
- n2->lev1= 0;
- replaceAllNode(n2->ed2, n2);
- n2->lev3++;
- replaceTestNode(n2->ed3, &(n2->ed3), n2, n2->lev3, n2->v3);
-
- /* NEW VERTEX from edge 3 */
- if( setvertexpointersNode(n1->ed3, n1, n1->lev3, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v1) {
- n1->v3= v2;
- n2->v1= v2;
- }
- else {
- n1->v3= v1;
- n2->v1= v1;
- }
- }
- else {
- n1->v3= n2->v1= mallocVert();
- n1->v3[0]= 0.5*(node->v1[0]+ node->v3[0]);
- n1->v3[1]= 0.5*(node->v1[1]+ node->v3[1]);
- n1->v3[2]= 0.5*(node->v1[2]+ node->v3[2]);
- n1->v3[3]= node->v3[3]; /* color */
- }
- }
- n1->area= AreaT3Dfl(n1->v1, n1->v2, n1->v3);
- n2->area= AreaT3Dfl(n2->v1, n2->v2, n2->v3);
-
-}
-
-
-void subdivideNode(RNode *node, RNode *edge)
-{
- RNode *n1, *n2, *up;
- float fu, fv, *v1, *v2;/*, AreaQ3Dfl(); ... from arithb... */
- int uvl;
-
- if(Ntotnode>RG.maxnode) return;
-
- if(node->type==3) {
- subdivideTriNode(node, edge);
- return;
- }
-
- if(node->down1 || node->down2) {
- /* printf("subdivide Node: already done \n"); */
- return;
- }
-
- /* defines subdivide direction */
-
- if(edge==0) {
- /* areathreshold */
- if(node->area<nodelimit) {
- return;
- }
- fu= fabs(node->v1[0]- node->v2[0])+ fabs(node->v1[1]- node->v2[1]) +fabs(node->v1[2]- node->v2[2]);
- fv= fabs(node->v1[0]- node->v4[0])+ fabs(node->v1[1]- node->v4[1]) +fabs(node->v1[2]- node->v4[2]);
- if(fu>fv) uvl= 1;
- else uvl= 2;
- }
- else {
- if(edge==node->ed1 || edge==node->ed3) uvl= 1;
- else uvl= 2;
- }
-
- /* do neighbour nodes have to be deeper? Recursive! */
- n1= n2= 0;
- if(uvl==1) {
- if(node->ed1 && node->ed1->down1==0) n1= node->ed1;
- if(node->ed3 && node->ed3->down1==0) n2= node->ed3;
- }
- else {
- if(node->ed2 && node->ed2->down1==0) n1= node->ed2;
- if(node->ed4 && node->ed4->down1==0) n2= node->ed4;
- }
- if(n1) {
- up= node->up;
- while(up) {
- if(n1->ed1==up || n1->ed2==up || n1->ed3==up || n1->ed4==up) {
- /* printf("recurs subd\n"); */
- subdivideNode(n1, up);
- break;
- }
- up= up->up;
- }
- }
- if(n2) {
- up= node->up;
- while(up) {
- if(n2->ed1==up || n2->ed2==up || n2->ed3==up || n2->ed4==up) {
- /* printf("recurs subd\n"); */
- subdivideNode(n2, up);
- break;
- }
- up= up->up;
- }
- }
-
- /* the subdividing */
- n1= mallocNode();
- memcpy(n1, node, sizeof(RNode));
- n2= mallocNode();
- memcpy(n2, node, sizeof(RNode));
-
- n1->up= node;
- n2->up= node;
-
- node->down1= n1;
- node->down2= n2;
-
- /* subdivide edge 1 and 3 */
- if(uvl==1) {
-
- /* FIRST NODE gets edge 2 */
- n1->ed4= n2;
- n1->lev4= 0;
- replaceAllNode(n1->ed2, n1);
- n1->lev1++;
- n1->lev3++;
- replaceTestNode(n1->ed1, &(n1->ed1), n1, n1->lev1, n1->v2);
- replaceTestNode(n1->ed3, &(n1->ed3), n1, n1->lev3, n1->v3);
-
- /* SECOND NODE gets edge 4 */
- n2->ed2= n1;
- n2->lev2= 0;
- replaceAllNode(n2->ed4, n2);
- n2->lev1++;
- n2->lev3++;
- replaceTestNode(n2->ed1, &(n2->ed1), n2, n2->lev1, n2->v1);
- replaceTestNode(n2->ed3, &(n2->ed3), n2, n2->lev3, n2->v4);
-
- /* NEW VERTEX from edge 1 */
- if( setvertexpointersNode(n1->ed1, n1, n1->lev1, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v1= v2;
- n2->v2= v2;
- }
- else {
- n1->v1= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v1= n2->v2= mallocVert();
- n1->v1[0]= 0.5*(node->v1[0]+ node->v2[0]);
- n1->v1[1]= 0.5*(node->v1[1]+ node->v2[1]);
- n1->v1[2]= 0.5*(node->v1[2]+ node->v2[2]);
- n1->v1[3]= node->v1[3]; /* color */
- }
-
- /* NEW VERTEX from edge 3 */
- if( setvertexpointersNode(n1->ed3, n1, n1->lev3, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v3) {
- n1->v4= v2;
- n2->v3= v2;
- }
- else {
- n1->v4= v1;
- n2->v3= v1;
- }
- }
- else {
- n1->v4= n2->v3= mallocVert();
- n1->v4[0]= 0.5*(node->v3[0]+ node->v4[0]);
- n1->v4[1]= 0.5*(node->v3[1]+ node->v4[1]);
- n1->v4[2]= 0.5*(node->v3[2]+ node->v4[2]);
- n1->v4[3]= node->v4[3]; /* color */
- }
- }
- /* subdivide edge 2 and 4 */
- else if(uvl==2) {
-
- /* FIRST NODE gets edge 1 */
- n1->ed3= n2;
- n1->lev3= 0;
- replaceAllNode(n1->ed1, n1);
- n1->lev2++;
- n1->lev4++;
- replaceTestNode(n1->ed2, &(n1->ed2), n1, n1->lev2, n1->v2);
- replaceTestNode(n1->ed4, &(n1->ed4), n1, n1->lev4, n1->v1);
-
- /* SECOND NODE gets edge 3 */
- n2->ed1= n1;
- n2->lev1= 0;
- replaceAllNode(n2->ed3, n2);
- n2->lev2++;
- n2->lev4++;
- replaceTestNode(n2->ed2, &(n2->ed2), n2, n2->lev2, n2->v3);
- replaceTestNode(n2->ed4, &(n2->ed4), n2, n2->lev4, n2->v4);
-
- /* NEW VERTEX from edge 2 */
- if( setvertexpointersNode(n1->ed2, n1, n1->lev2, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v2) {
- n1->v3= v2;
- n2->v2= v2;
- }
- else {
- n1->v3= v1;
- n2->v2= v1;
- }
- }
- else {
- n1->v3= n2->v2= mallocVert();
- n1->v3[0]= 0.5*(node->v2[0]+ node->v3[0]);
- n1->v3[1]= 0.5*(node->v2[1]+ node->v3[1]);
- n1->v3[2]= 0.5*(node->v2[2]+ node->v3[2]);
- n1->v3[3]= node->v3[3]; /* color */
- }
-
- /* NEW VERTEX from edge 4 */
- if( setvertexpointersNode(n1->ed4, n1, n1->lev4, &v1, &v2) ) { /* nodes have equal levels */
- if(v1== n1->v1) {
- n1->v4= v2;
- n2->v1= v2;
- }
- else {
- n1->v4= v1;
- n2->v1= v1;
- }
- }
- else {
- n1->v4= n2->v1= mallocVert();
- n1->v4[0]= 0.5*(node->v1[0]+ node->v4[0]);
- n1->v4[1]= 0.5*(node->v1[1]+ node->v4[1]);
- n1->v4[2]= 0.5*(node->v1[2]+ node->v4[2]);
- n1->v4[3]= node->v4[3]; /* color */
- }
- }
-
- n1->area= AreaQ3Dfl(n1->v1, n1->v2, n1->v3, n1->v4);
- n2->area= AreaQ3Dfl(n2->v1, n2->v2, n2->v3, n2->v4);
-
-}
-
-int comparelevel(RNode *node, RNode *nb, int level)
-{
- /* recursive descent: test with deepest node */
- /* return 1 means equal or higher */
-
- if(nb==0) return 1;
-
- if(nb->down1) {
- return 0;
-
- /* THERE IS AN ERROR HERE, BUT WHAT? (without this function the system
- works too, but is slower) (ton) */
-
- /*
- n1= nb->down1;
- if(n1->ed1==node) return comparelevel(node, n1, level);
- if(n1->ed2==node) return comparelevel(node, n1, level);
- if(n1->ed3==node) return comparelevel(node, n1, level);
- if(n1->ed4==node) return comparelevel(node, n1, level);
- n1= nb->down2;
- if(n1->ed1==node) return comparelevel(node, n1, level);
- if(n1->ed2==node) return comparelevel(node, n1, level);
- if(n1->ed3==node) return comparelevel(node, n1, level);
- if(n1->ed4==node) return comparelevel(node, n1, level);
- printf(" dit kan niet ");
- return 0;
- */
-
- }
-
- if(nb->down1==0) {
- /* if(nb->ed1==node) return (nb->lev1<=level); */
- /* if(nb->ed2==node) return (nb->lev2<=level); */
- /* if(nb->ed3==node) return (nb->lev3<=level); */
- /* if(nb->ed4==node) return (nb->lev4<=level); */
-
- return 1; /* is higher node */
- }
- return 1;
-}
-
-static void deleteTriNodes(RNode *node) /* both children of node */
-{
- RNode *n1, *n2;
-
- /* if neighbour nodes are deeper: no delete */
- /* just test 2 nodes, from the others the level doesn't change */
-
- n1= node->down1;
- n2= node->down2;
-
- if(n1==0 || n2==0) return;
-
- if(n1->down1 || n2->down1) return;
-
- /* at the edges no subdivided node is allowed */
-
- if(n1->ed1 && n1->ed1->down1) return;
- if(n1->ed2 && n1->ed2->down1) return;
- if(n1->ed3 && n1->ed3->down1) return;
-
- if(n2->ed1 && n2->ed1->down1) return;
- if(n2->ed2 && n2->ed2->down1) return;
- if(n2->ed3 && n2->ed3->down1) return;
-
- replaceAllNodeInv(n1->ed1, n1);
- replaceAllNodeInv(n1->ed2, n1);
- replaceAllNodeInv(n1->ed3, n1);
-
- replaceAllNodeUp(n1->ed1, n1);
- replaceAllNodeUp(n1->ed2, n1);
- replaceAllNodeUp(n1->ed3, n1);
-
- replaceAllNodeInv(n2->ed1, n2);
- replaceAllNodeInv(n2->ed2, n2);
- replaceAllNodeInv(n2->ed3, n2);
-
- replaceAllNodeUp(n2->ed1, n2);
- replaceAllNodeUp(n2->ed2, n2);
- replaceAllNodeUp(n2->ed3, n2);
-
- n1->down1= (RNode *)12; /* for debug */
- n2->down1= (RNode *)12;
-
- freeNode(n1);
- freeNode(n2);
- node->down1= node->down2= 0;
-
-}
-
- /* both children of node */
-void deleteNodes(RNode *node)
-{
- RNode *n1, *n2;
-
- /* if neighbour nodes are deeper: no delete */
- /* just test 2 nodes, from the others the level doesn't change */
-
- if(node->type==3) {
- deleteTriNodes(node);
- return;
- }
-
- n1= node->down1;
- n2= node->down2;
-
- if(n1==0 || n2==0) return;
-
- if(n1->down1 || n2->down1) return;
-
- if(n1->ed3==n2) {
-
- /* at the edges no subdivided node is allowed */
-
- if(n1->ed1 && n1->ed1->down1) return;
- if(n1->ed2 && n1->ed2->down1) return;
- if(n1->ed4 && n1->ed4->down1) return;
-
- if(n2->ed2 && n2->ed2->down1) return;
- if(n2->ed3 && n2->ed3->down1) return;
- if(n2->ed4 && n2->ed4->down1) return;
-
- replaceAllNodeInv(n1->ed1, n1);
- replaceAllNodeInv(n1->ed2, n1);
- replaceAllNodeInv(n1->ed4, n1);
-
- replaceAllNodeUp(n1->ed1, n1);
- replaceAllNodeUp(n1->ed2, n1);
- replaceAllNodeUp(n1->ed4, n1);
-
- replaceAllNodeInv(n2->ed2, n2);
- replaceAllNodeInv(n2->ed3, n2);
- replaceAllNodeInv(n2->ed4, n2);
-
- replaceAllNodeUp(n2->ed2, n2);
- replaceAllNodeUp(n2->ed3, n2);
- replaceAllNodeUp(n2->ed4, n2);
-
- n1->down1= (RNode *)12; /* for debug */
- n2->down1= (RNode *)12;
-
- freeNode(n1);
- freeNode(n2);
- node->down1= node->down2= 0;
-
- return;
- }
- else if(n1->ed4==n2) {
-
- if(n1->ed1 && n1->ed1->down1) return;
- if(n1->ed2 && n1->ed2->down1) return;
- if(n1->ed3 && n1->ed3->down1) return;
-
- if(n2->ed1 && n2->ed1->down1) return;
- if(n2->ed3 && n2->ed3->down1) return;
- if(n2->ed4 && n2->ed4->down1) return;
-
- replaceAllNodeInv(n1->ed1, n1);
- replaceAllNodeInv(n1->ed2, n1);
- replaceAllNodeInv(n1->ed3, n1);
-
- replaceAllNodeUp(n1->ed1, n1);
- replaceAllNodeUp(n1->ed2, n1);
- replaceAllNodeUp(n1->ed3, n1);
-
- replaceAllNodeInv(n2->ed1, n2);
- replaceAllNodeInv(n2->ed3, n2);
- replaceAllNodeInv(n2->ed4, n2);
-
- replaceAllNodeUp(n2->ed1, n2);
- replaceAllNodeUp(n2->ed3, n2);
- replaceAllNodeUp(n2->ed4, n2);
-
- n1->down1= (RNode *)12; /* for debug */
- n2->down1= (RNode *)12;
-
- freeNode(n1);
- freeNode(n2);
- node->down1= node->down2= 0;
-
- return;
- }
-
-}
-
-
diff --git a/source/blender/radiosity/intern/source/radpostprocess.c b/source/blender/radiosity/intern/source/radpostprocess.c
deleted file mode 100644
index 6912c737a51..00000000000
--- a/source/blender/radiosity/intern/source/radpostprocess.c
+++ /dev/null
@@ -1,824 +0,0 @@
-/* ***************************************
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- radpostprocess.c nov/dec 1992
- may 1999
-
- - faces
- - filtering and node-limit
- - apply to meshes
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_ghash.h"
-
-#include "DNA_material_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_radio_types.h"
-#include "DNA_scene_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_mesh.h"
-#include "BKE_object.h"
-#include "BKE_utildefines.h"
-
-#include "radio.h"
-
-/* locals? not. done in radio.h... */
-/* void rad_addmesh(void); */
-/* void rad_replacemesh(void); */
-
-void addaccu(register char *z, register char *t)
-{
- register int div, mul;
-
- mul= *t;
- div= mul+1;
- (*t)++;
-
- t[1]= (mul*t[1]+z[1])/div;
- t[2]= (mul*t[2]+z[2])/div;
- t[3]= (mul*t[3]+z[3])/div;
-
-}
-
-void addaccuweight(register char *z, register char *t, int w)
-{
- register int div, mul;
-
- if(w==0) w= 1;
-
- mul= *t;
- div= mul+w;
- if(div>255) return;
- (*t)= div;
-
- t[1]= (mul*t[1]+w*z[1])/div;
- t[2]= (mul*t[2]+w*z[2])/div;
- t[3]= (mul*t[3]+w*z[3])/div;
-
-}
-
-void triaweight(Face *face, int *w1, int *w2, int *w3)
-{
- float n1[3], n2[3], n3[3], temp;
-
- n1[0]= face->v2[0]-face->v1[0];
- n1[1]= face->v2[1]-face->v1[1];
- n1[2]= face->v2[2]-face->v1[2];
- n2[0]= face->v3[0]-face->v2[0];
- n2[1]= face->v3[1]-face->v2[1];
- n2[2]= face->v3[2]-face->v2[2];
- n3[0]= face->v1[0]-face->v3[0];
- n3[1]= face->v1[1]-face->v3[1];
- n3[2]= face->v1[2]-face->v3[2];
- Normalize(n1);
- Normalize(n2);
- Normalize(n3);
- temp= 32.0/(PI);
- *w1= 0.5+temp*acos(-n1[0]*n3[0]-n1[1]*n3[1]-n1[2]*n3[2]);
- *w2= 0.5+temp*acos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2]);
- *w3= 0.5+temp*acos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2]);
-
-}
-
-
-
-void init_face_tab()
-{
- int a= 0;
-
- if(RG.facebase==0) {
- RG.facebase= MEM_callocN(sizeof(void *)*RAD_MAXFACETAB, "init_face_tab");
- }
- for(a=0; a<RAD_MAXFACETAB; a++) {
- if(RG.facebase[a]==0) break;
- MEM_freeN(RG.facebase[a]);
- RG.facebase[a]= 0;
- }
- RG.totface= 0;
-}
-
-Face *addface()
-{
- Face *face;
- int a;
-
- if(RG.totface<0 || RG.totface>RAD_MAXFACETAB*1024 ) {
- printf("error in addface: %d\n", RG.totface);
- return 0;
- }
- a= RG.totface>>10;
- face= RG.facebase[a];
- if(face==0) {
- face= MEM_callocN(1024*sizeof(Face),"addface");
- RG.facebase[a]= face;
- }
- face+= (RG.totface & 1023);
-
- RG.totface++;
-
- return face;
-
-}
-
-Face * makeface(float *v1, float *v2, float *v3, float *v4, RNode *rn)
-{
- Face *face;
-
- face= addface();
- face->v1= v1;
- face->v2= v2;
- face->v3= v3;
- face->v4= v4;
- face->col= rn->col;
- face->matindex= rn->par->matindex;
- face->orig= rn->orig;
-
- return face;
-}
-
-void anchorQuadface(RNode *rn, float *v1, float *v2, float *v3, float *v4, int flag)
-{
- Face *face;
-
- switch(flag) {
- case 1:
- face = makeface(rn->v1, v1, rn->v4, NULL, rn);
- face = makeface(v1, rn->v3, rn->v4, NULL, rn);
- face = makeface(v1, rn->v2, rn->v3, NULL, rn);
- break;
- case 2:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn);
- face = makeface(v2, rn->v4, rn->v1, NULL, rn);
- face = makeface(v2, rn->v3, rn->v4, NULL, rn);
- break;
- case 4:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn);
- face = makeface(v3, rn->v1, rn->v2, NULL, rn);
- face = makeface(v3, rn->v4, rn->v1, NULL, rn);
- break;
- case 8:
- face = makeface(rn->v4, v4, rn->v3, NULL, rn);
- face = makeface(v4, rn->v2, rn->v3, NULL, rn);
- face = makeface(v4, rn->v1, rn->v2, NULL, rn);
- break;
- case 3:
- face = makeface(rn->v1, v1, rn->v4, NULL, rn);
- face = makeface(v1, v2, rn->v4, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- face = makeface(v2, rn->v3, rn->v4, NULL, rn);
- break;
- case 6:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn);
- face = makeface(v2, v3, rn->v1, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- face = makeface(v3, rn->v4, rn->v1, NULL, rn);
- break;
- case 12:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn);
- face = makeface(v3, v4, rn->v2, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- face = makeface(v4, rn->v1, rn->v2, NULL, rn);
- break;
- case 9:
- face = makeface(rn->v4, v4, rn->v3, NULL, rn);
- face = makeface(v4, v1, rn->v3, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- face = makeface(v1, rn->v2, rn->v3, NULL, rn);
- break;
- case 5:
- face = makeface(rn->v1, v1, v3, rn->v4, rn);
- face = makeface(v1, rn->v2, rn->v3, v3, rn);
- break;
- case 10:
- face = makeface(rn->v1, rn->v2, v2, v4, rn);
- face = makeface(v4, v2, rn->v3, rn->v4, rn);
- break;
- case 7:
- face = makeface(rn->v1, v1, v3, rn->v4, rn);
- face = makeface(v1, v2, v3, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- break;
- case 14:
- face = makeface(rn->v2, v2, v4, rn->v1, rn);
- face = makeface(v2, v3, v4, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- break;
- case 13:
- face = makeface(rn->v3, v3, v1, rn->v2, rn);
- face = makeface(v3, v4, v1, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- break;
- case 11:
- face = makeface(rn->v4, v4, v2, rn->v3, rn);
- face = makeface(v4, v1, v2, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- break;
- case 15:
- face = makeface(v1, v2, v3, v4, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- face = makeface(v3, rn->v4, v4, NULL, rn);
- face = makeface(v4, rn->v1, v1, NULL, rn);
- break;
- }
-}
-
-void anchorTriface(RNode *rn, float *v1, float *v2, float *v3, int flag)
-{
- Face *face;
-
- switch(flag) {
- case 1:
- face = makeface(rn->v1, v1, rn->v3, NULL, rn);
- face = makeface(v1, rn->v2, rn->v3, NULL, rn);
- break;
- case 2:
- face = makeface(rn->v2, v2, rn->v1, NULL, rn);
- face = makeface(v2, rn->v3, rn->v1, NULL, rn);
- break;
- case 4:
- face = makeface(rn->v3, v3, rn->v2, NULL, rn);
- face = makeface(v3, rn->v1, rn->v2, NULL, rn);
- break;
- case 3:
- face = makeface(rn->v1, v2, rn->v3, NULL, rn);
- face = makeface(rn->v1, v1, v2, NULL, rn);
- face = makeface(v1, rn->v2, v2, NULL, rn);
- break;
- case 6:
- face = makeface(rn->v2, v3, rn->v1, NULL, rn);
- face = makeface(rn->v2, v2, v3, NULL, rn);
- face = makeface(v2, rn->v3, v3, NULL, rn);
- break;
- case 5:
- face = makeface(rn->v3, v1, rn->v2, NULL, rn);
- face = makeface(rn->v3, v3, v1, NULL, rn);
- face = makeface(v3, rn->v1, v1, NULL, rn);
- break;
-
- case 7:
- face = makeface(v1, v2, v3, NULL, rn);
- face = makeface(rn->v1, v1, v3, NULL, rn);
- face = makeface(rn->v2, v2, v1, NULL, rn);
- face = makeface(rn->v3, v3, v2, NULL, rn);
- break;
- }
-}
-
-
-float *findmiddlevertex(RNode *node, RNode *nb, float *v1, float *v2)
-{
- int test= 0;
-
- if(nb==0) return 0;
-
- if(nb->ed1==node) {
- if(nb->v1==v1 || nb->v1==v2) test++;
- if(nb->v2==v1 || nb->v2==v2) test+=2;
- if(test==1) return nb->v2;
- else if(test==2) return nb->v1;
- }
- else if(nb->ed2==node) {
- if(nb->v2==v1 || nb->v2==v2) test++;
- if(nb->v3==v1 || nb->v3==v2) test+=2;
- if(test==1) return nb->v3;
- else if(test==2) return nb->v2;
- }
- else if(nb->ed3==node) {
- if(nb->type==4) {
- if(nb->v3==v1 || nb->v3==v2) test++;
- if(nb->v4==v1 || nb->v4==v2) test+=2;
- if(test==1) return nb->v4;
- else if(test==2) return nb->v3;
- }
- else {
- if(nb->v3==v1 || nb->v3==v2) test++;
- if(nb->v1==v1 || nb->v1==v2) test+=2;
- if(test==1) return nb->v1;
- else if(test==2) return nb->v3;
- }
- }
- else if(nb->ed4==node) {
- if(nb->v4==v1 || nb->v4==v2) test++;
- if(nb->v1==v1 || nb->v1==v2) test+=2;
- if(test==1) return nb->v1;
- else if(test==2) return nb->v4;
- }
- return 0;
-}
-
-void make_face_tab() /* takes care of anchoring */
-{
- RNode *rn, **el;
- Face *face = NULL;
- float *v1, *v2, *v3, *v4;
- int a, flag, w1, w2, w3;
- char *charcol;
-
- if(RG.totelem==0) return;
-
- init_face_tab();
-
- RG.igamma= 1.0/RG.gamma;
- RG.radfactor= RG.radfac*pow(64*64, RG.igamma);
-
- /* convert face colors */
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- charcol= (char *)&( rn->col );
-
- charcol[3]= calculatecolor(rn->totrad[0]);
- charcol[2]= calculatecolor(rn->totrad[1]);
- charcol[1]= calculatecolor(rn->totrad[2]);
- }
-
- /* check nodes and make faces */
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
-
- rn= *el;
-
- rn->v1[3]= 0.0;
- rn->v2[3]= 0.0;
- rn->v3[3]= 0.0;
- if(rn->v4) rn->v4[3]= 0.0;
-
- /* test edges for subdivide */
- flag= 0;
- v1= v2= v3= v4= 0;
- if(rn->ed1) {
- v1= findmiddlevertex(rn, rn->ed1->down1, rn->v1, rn->v2);
- if(v1) flag |= 1;
- }
- if(rn->ed2) {
- v2= findmiddlevertex(rn, rn->ed2->down1, rn->v2, rn->v3);
- if(v2) flag |= 2;
- }
- if(rn->ed3) {
- if(rn->type==4)
- v3= findmiddlevertex(rn, rn->ed3->down1, rn->v3, rn->v4);
- else
- v3= findmiddlevertex(rn, rn->ed3->down1, rn->v3, rn->v1);
- if(v3) flag |= 4;
- }
- if(rn->ed4) {
- v4= findmiddlevertex(rn, rn->ed4->down1, rn->v4, rn->v1);
- if(v4) flag |= 8;
- }
-
- /* using flag and vertexpointers now Faces can be made */
-
- if(flag==0) {
- makeface(rn->v1, rn->v2, rn->v3, rn->v4, rn);
- }
- else if(rn->type==4) anchorQuadface(rn, v1, v2, v3, v4, flag);
- else anchorTriface(rn, v1, v2, v3, flag);
- }
-
- /* add */
- for(a=0; a<RG.totface; a++) {
-
- RAD_NEXTFACE(a);
-
- if(face->v4) {
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v4+3), 16 );
- }
- else {
- triaweight(face, &w1, &w2, &w3);
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), w1 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), w2 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), w3 );
- }
- }
-
-}
-
-void filterFaces()
-{
- /* put vertex colors in faces, and put them back */
-
- Face *face = NULL;
- int a, w1, w2, w3;
-
- if(RG.totface==0) return;
-
- /* clear */
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
- face->col= 0;
- }
-
- /* add: vertices with faces */
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
-
- if(face->v4) {
- addaccuweight( (char *)(face->v1+3), (char *)&(face->col), 16 );
- addaccuweight( (char *)(face->v2+3), (char *)&(face->col), 16 );
- addaccuweight( (char *)(face->v3+3), (char *)&(face->col), 16 );
- addaccuweight( (char *)(face->v4+3), (char *)&(face->col), 16 );
- }
- else {
- triaweight(face, &w1, &w2, &w3);
- addaccuweight( (char *)(face->v1+3), (char *)&(face->col), w1 );
- addaccuweight( (char *)(face->v2+3), (char *)&(face->col), w2 );
- addaccuweight( (char *)(face->v3+3), (char *)&(face->col), w3 );
- }
- }
-
- /* clear */
- for(a=0; a<RG.totface; a++) {
- RAD_NEXTFACE(a);
- face->v1[3]= 0.0;
- face->v2[3]= 0.0;
- face->v3[3]= 0.0;
- if(face->v4) face->v4[3]= 0.0;
- }
-
-
- /* add: faces with vertices */
- for(a=0; a<RG.totface; a++) {
-
- RAD_NEXTFACE(a);
-
- if(face->v4) {
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), 16 );
- addaccuweight( (char *)&(face->col), (char *)(face->v4+3), 16 );
- }
- else {
- triaweight(face, &w1, &w2, &w3);
- addaccuweight( (char *)&(face->col), (char *)(face->v1+3), w1 );
- addaccuweight( (char *)&(face->col), (char *)(face->v2+3), w2 );
- addaccuweight( (char *)&(face->col), (char *)(face->v3+3), w3 );
- }
- }
-}
-
-void calcfiltrad(RNode *rn, float *cd)
-{
- float area;
-
- cd[0]= 2.0*rn->totrad[0];
- cd[1]= 2.0*rn->totrad[1];
- cd[2]= 2.0*rn->totrad[2];
- area= 2.0;
-
- if(rn->ed1) {
- cd[0]+= rn->ed1->totrad[0];
- cd[1]+= rn->ed1->totrad[1];
- cd[2]+= rn->ed1->totrad[2];
- area+= 1.0;
- }
- if(rn->ed2) {
- cd[0]+= rn->ed2->totrad[0];
- cd[1]+= rn->ed2->totrad[1];
- cd[2]+= rn->ed2->totrad[2];
- area+= 1.0;
- }
- if(rn->ed3) {
- cd[0]+= rn->ed3->totrad[0];
- cd[1]+= rn->ed3->totrad[1];
- cd[2]+= rn->ed3->totrad[2];
- area+= 1.0;
- }
- if(rn->ed4) {
- cd[0]+= rn->ed4->totrad[0];
- cd[1]+= rn->ed4->totrad[1];
- cd[2]+= rn->ed4->totrad[2];
- area+= 1.0;
- }
- cd[0]/= area;
- cd[1]/= area;
- cd[2]/= area;
-
-}
-
-void filterNodes()
-{
- /* colors from nodes in tempblock and back */
-
- RNode *rn, **el;
- float *coldata, *cd;
- int a;
-
- if(RG.totelem==0) return;
- /* the up-nodes need a color */
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- rn= *el;
- if(rn->up) {
- rn->up->totrad[0]= 0.0;
- rn->up->totrad[1]= 0.0;
- rn->up->totrad[2]= 0.0;
- if(rn->up->up) {
- rn->up->up->totrad[0]= 0.0;
- rn->up->up->totrad[1]= 0.0;
- rn->up->up->totrad[2]= 0.0;
- }
- }
- }
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- rn= *el;
- if(rn->up) {
- rn->up->totrad[0]+= 0.5*rn->totrad[0];
- rn->up->totrad[1]+= 0.5*rn->totrad[1];
- rn->up->totrad[2]+= 0.5*rn->totrad[2];
- if(rn->up->up) {
- rn->up->up->totrad[0]+= 0.25*rn->totrad[0];
- rn->up->up->totrad[1]+= 0.25*rn->totrad[1];
- rn->up->up->totrad[2]+= 0.25*rn->totrad[2];
- }
- }
- }
-
- /* add using area */
- cd= coldata= MEM_mallocN(3*4*RG.totelem, "filterNodes");
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- calcfiltrad(*el, cd);
- cd+= 3;
- }
-
- cd= coldata;
- el= RG.elem;
- for(a=0; a<RG.totelem; a++, el++) {
- rn= *el;
- VECCOPY(rn->totrad, cd);
- cd+= 3;
- }
- MEM_freeN(coldata);
-}
-
-void removeEqualNodes(short limit)
-{
- /* nodes with equal colors: remove */
- RNode **el, *rn, *rn1;
- float thresh, f1, f2;
- int a, foundone=1, ok;
- int c1, c2;
-
- if(limit==0) return;
-
- thresh= 1.0/(256.0*RG.radfactor);
- thresh= 3.0*pow(thresh, RG.gamma);
-
-// XXX waitcursor(1);
-
- while(foundone) {
- foundone= 0;
-
- el= RG.elem;
- for(a=RG.totelem; a>1; a--, el++) {
- rn= *el;
- rn1= *(el+1);
-
- if(rn!=rn->par->first && rn1!=rn1->par->first) {
- if(rn->up && rn->up==rn1->up) {
- f1= rn->totrad[0]+ rn->totrad[1]+ rn->totrad[2];
- f2= rn1->totrad[0]+ rn1->totrad[1]+ rn1->totrad[2];
-
- ok= 0;
- if(f1<thresh && f2<thresh) ok= 1;
- else {
- c1= calculatecolor(rn->totrad[0]);
- c2= calculatecolor(rn1->totrad[0]);
-
- if( abs(c1-c2)<=limit ) {
- c1= calculatecolor(rn->totrad[1]);
- c2= calculatecolor(rn1->totrad[1]);
-
- if( abs(c1-c2)<=limit ) {
- c1= calculatecolor(rn->totrad[2]);
- c2= calculatecolor(rn1->totrad[2]);
-
- if( abs(c1-c2)<=limit ) {
- ok= 1;
- }
- }
- }
- }
-
- if(ok) {
- rn->up->totrad[0]= 0.5f*(rn->totrad[0]+rn1->totrad[0]);
- rn->up->totrad[1]= 0.5f*(rn->totrad[1]+rn1->totrad[1]);
- rn->up->totrad[2]= 0.5f*(rn->totrad[2]+rn1->totrad[2]);
- rn1= rn->up;
- deleteNodes(rn1);
- if(rn1->down1) ;
- else {
- foundone++;
- a--; el++;
- }
- }
- }
- }
- }
- if(foundone) {
- makeGlobalElemArray();
- }
- }
-// XXX waitcursor(0);
-}
-
-unsigned int rad_find_or_add_mvert(Mesh *me, MFace *mf, RNode *orignode, float *w, float *radco, GHash *hash)
-{
- MVert *mvert = BLI_ghash_lookup(hash, radco);
-
- if(!mvert) {
- mvert = &me->mvert[me->totvert];
- VECCOPY(mvert->co, radco);
- me->totvert++;
-
- BLI_ghash_insert(hash, radco, mvert);
- }
-
- InterpWeightsQ3Dfl(orignode->v1, orignode->v2, orignode->v3,
- orignode->v4, mvert->co, w);
-
- return (unsigned int)(mvert - me->mvert);
-}
-
-void rad_addmesh(Scene *scene)
-{
- Face *face = NULL;
- Object *ob;
- Mesh *me;
- MVert *mvert;
- MFace *mf;
- RNode *node;
- Material *ma=0;
- GHash *verthash;
- unsigned int *mcol;
- float cent[3], min[3], max[3], w[4][4];
- int a;
-
- if(RG.totface==0)
- return;
-
-// if(RG.totmat==MAXMAT)
-// XXX notice("warning: cannot assign more than 16 materials to 1 mesh");
-
- /* create the mesh */
- ob= add_object(scene, OB_MESH);
-
- me= ob->data;
- me->totvert= totalRadVert();
- me->totface= RG.totface;
- me->flag= 0;
-
- CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
- CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
- CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
-
- CustomData_merge(RG.mfdata, &me->fdata, CD_MASK_MESH, CD_CALLOC, me->totface);
- mesh_update_customdata_pointers(me);
-
- /* create materials and set vertex color flag */
- for(a=0; a<RG.totmat; a++) {
- assign_material(ob, RG.matar[a], a+1);
- ma= RG.matar[a];
- if(ma) ma->mode |= MA_VERTEXCOL;
- }
-
- /* create vertices and faces in one go, adding vertices to the end of the
- mvert array if they were not added already */
- me->totvert= 0;
- verthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
-
- mcol= (unsigned int*)me->mcol;
- mf= me->mface;
-
- for(a=0; a<me->totface; a++, mf++, mcol+=4) {
- RAD_NEXTFACE(a);
-
- /* the original node that this node is a subnode of */
- node= RG.mfdatanodes[face->orig];
-
- /* set mverts from the radio data, and compute interpolation weights */
- mf->v1= rad_find_or_add_mvert(me, mf, node, w[0], face->v1, verthash);
- mf->v2= rad_find_or_add_mvert(me, mf, node, w[1], face->v2, verthash);
- mf->v3= rad_find_or_add_mvert(me, mf, node, w[2], face->v3, verthash);
- if(face->v4)
- mf->v4= rad_find_or_add_mvert(me, mf, node, w[3], face->v4, verthash);
-
- /* copy face and interpolate data */
- mf->mat_nr= face->matindex;
-
- CustomData_copy_data(RG.mfdata, &me->fdata, face->orig, a, 1);
- CustomData_interp(RG.mfdata, &me->fdata, &face->orig, NULL, (float*)w, 1, a);
-
- /* load face vertex colors, with alpha added */
- mcol[0]= *((unsigned int*)face->v1+3) | 0x1000000;
- mcol[1]= *((unsigned int*)face->v2+3) | 0x1000000;
- mcol[2]= *((unsigned int*)face->v3+3) | 0x1000000;
- if(face->v4)
- mcol[3]= *((unsigned int*)face->v4+3) | 0x1000000;
-
- /* reorder face indices if needed to make face->v4 == 0 */
- test_index_face(mf, &me->fdata, a, face->v4? 4: 3);
- }
-
- BLI_ghash_free(verthash, NULL, NULL);
-
- /* boundbox and center new */
- INIT_MINMAX(min, max);
-
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- DO_MINMAX(mvert->co, min, max);
- }
-
- cent[0]= (min[0]+max[0])/2.0f;
- cent[1]= (min[1]+max[1])/2.0f;
- cent[2]= (min[2]+max[2])/2.0f;
-
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- VecSubf(mvert->co, mvert->co, cent);
- }
-
- VECCOPY(ob->loc, cent);
-
- /* create edges */
- make_edges(me, 0);
-}
-
-void rad_replacemesh(Scene *scene)
-{
- RPatch *rp;
-
-// XXX deselectall();
-
- rp= RG.patchbase.first;
- while(rp) {
- if( exist_object(rp->from)) {
- if (rp->from->type == OB_MESH) {
- rp->from->flag |= SELECT;
- }
- }
- rp= rp->next;
- }
-
- copy_objectflags(scene);
-// XXX delete_obj(1);
-
- rad_addmesh(scene);
-}
-
diff --git a/source/blender/radiosity/intern/source/radpreprocess.c b/source/blender/radiosity/intern/source/radpreprocess.c
deleted file mode 100644
index 2b3ce1a856b..00000000000
--- a/source/blender/radiosity/intern/source/radpreprocess.c
+++ /dev/null
@@ -1,828 +0,0 @@
- /* ***************************************
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
-
-
-
- preproces.c nov/dec 1992
- may 1999
-
- - collect from meshes
- - countglobaldata()
- - makeGlobalElemArray()
-
- $Id$
-
- *************************************** */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_view3d_types.h"
-
-#include "BKE_customdata.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_mesh.h"
-#include "BKE_object.h" /* during_script() */
-#include "BKE_utildefines.h"
-
-#include "radio.h"
-
-#include "BLO_sys_types.h" // for intptr_t support
-
-void setparelem(RNode *rn, RPatch *par);
-
-void splitconnected()
-{
- /* Since input meshes can have faces with sharing vertices, the geometry is being tested here.
- * Using normals and colors, faces are split separately. we do this by storing for each
- * vertex a normal and a color
- */
- RPatch *rp;
- RNode *rn;
- VeNoCo *vnc, *next, *vnc1;
- int a;
-
- /* test if we need a split */
-
- rp= RG.patchbase.first;
- while(rp) {
- rn= rp->first;
- if((rp->f1 & RAD_NO_SPLIT)==0) {
- for(a=0; a<rp->type; a++) {
-
- if(a==0) vnc= (VeNoCo *)rn->v1;
- else if(a==1) vnc= (VeNoCo *)rn->v2;
- else if(a==2) vnc= (VeNoCo *)rn->v3;
- else vnc= (VeNoCo *)rn->v4;
-
- if(vnc->flag==0) {
- vnc->n= (float *)rp->norm;
- vnc->col= (float *)rp->ref;
- vnc->flag= 1;
- }
- else { /* is face from this vertex allowed for gouraud? */
- vnc1= vnc;
- while(vnc1) {
- if(VecCompare(vnc1->n, rp->norm, 0.01f)) {
- if(VecCompare(vnc1->col, rp->ref, 0.01f)) {
- break;
- }
- }
- vnc= vnc1;
- vnc1= vnc1->next;
- }
- if(vnc1==0) {
- vnc1= MEM_mallocN(sizeof(VeNoCo), "splitconn");
- vnc1->next= 0;
- vnc1->v= mallocVert();
- vnc->next= vnc1;
- VECCOPY(vnc1->v, vnc->v);
- vnc1->n= (float *)rp->norm;
- vnc1->col= (float *)rp->ref;
- }
- if(a==0) rn->v1= (float *)vnc1;
- else if(a==1) rn->v2= (float *)vnc1;
- else if(a==2) rn->v3= (float *)vnc1;
- else rn->v4= (float *)vnc1;
- }
- }
- }
- rp= rp->next;
- }
- /* adapt vertexpointers from nodes */
-
- rp= RG.patchbase.first;
- while(rp) {
- rn= rp->first;
- rn->v1= ((VeNoCo *)(rn->v1))->v;
- rn->v2= ((VeNoCo *)(rn->v2))->v;
- rn->v3= ((VeNoCo *)(rn->v3))->v;
- if(rp->type==4) rn->v4= ((VeNoCo *)(rn->v4))->v;
-
- rp= rp->next;
- }
-
-
- /* free all */
- vnc= RG.verts;
- for(a=0; a<RG.totvert; a++) {
- vnc1= vnc->next;
- while(vnc1) {
- next= vnc1->next;
- MEM_freeN(vnc1);
- vnc1= next;
- }
- vnc++;
- }
- MEM_freeN(RG.verts);
- RG.verts= 0;
-}
-
-int vergedge(const void *v1,const void *v2)
-{
- int *e1, *e2;
-
- e1= (int *)v1;
- e2= (int *)v2;
-
- if( e1[0] > e2[0] ) return 1;
- else if( e1[0] < e2[0] ) return -1;
- else if( e1[1] > e2[1] ) return 1;
- else if( e1[1] < e2[1] ) return -1;
-
- return 0;
-}
-
-
-void addedge(float *v1, float *v2, EdSort *es)
-{
- if( ((intptr_t)v1)<((intptr_t)v2) ) {
- es->v1= v1;
- es->v2= v2;
- }
- else {
- es->v2= v1;
- es->v1= v2;
- }
-}
-
-static void setedge(RNode *node, RNode *nb, int nr, int nrb)
-{
- switch(nr) {
- case 1:
- node->ed1= nb;
- break;
- case 2:
- node->ed2= nb;
- break;
- case 3:
- node->ed3= nb;
- break;
- case 4:
- node->ed4= nb;
- break;
- }
- switch(nrb) {
- case 1:
- nb->ed1= node;
- break;
- case 2:
- nb->ed2= node;
- break;
- case 3:
- nb->ed3= node;
- break;
- case 4:
- nb->ed4= node;
- break;
- }
-}
-
-void setedgepointers()
-{
- /* make edge-array and sort it */
- /* pairs of edges are put together: fill in pointers in nodes */
- EdSort *es, *esblock;
- RPatch *rp;
- RNode *rn;
- int tot= 0;
-
- rp= RG.patchbase.first;
- while(rp) {
- tot+= rp->type;
- rp= rp->next;
- }
-
- if(tot==0) return;
-
- es=esblock= MEM_mallocN(tot*sizeof(EdSort), "setedgepointers");
- rp= RG.patchbase.first;
- while(rp) {
- rn= rp->first;
- addedge(rn->v1, rn->v2, es);
- es->nr= 1;
- es->node= rn;
- es++;
- addedge(rn->v2, rn->v3, es);
- es->nr= 2;
- es->node= rn;
- es++;
- if(rp->type==3) {
- addedge(rn->v3, rn->v1, es);
- es->nr= 3;
- es->node= rn;
- es++;
- }
- else {
- addedge(rn->v3, rn->v4, es);
- es->nr= 3;
- es->node= rn;
- es++;
- addedge(rn->v4, rn->v1, es);
- es->nr= 4;
- es->node= rn;
- es++;
- }
- rp= rp->next;
- }
-
- qsort(esblock,tot,sizeof(EdSort),vergedge);
-
- es= esblock;
- while(tot>0) {
- if( es->v1== (es+1)->v1 ) {
- if( es->v2== (es+1)->v2 ) {
- setedge(es->node, (es+1)->node, es->nr, (es+1)->nr);
- tot--;
- es++;
- }
- }
- es++;
- tot--;
- }
-
- MEM_freeN(esblock);
-}
-
-static int materialIndex(Material *ma)
-{
- int i = 0;
- for(i=0;i< RG.totmat; i++)
- {
- if (RG.matar[i] == ma) {
- return i;
- }
- }
- return -1;
-}
-
-void rad_collect_meshes(Scene *scene, View3D *v3d)
-{
- extern Material defmaterial;
- Base *base;
- Object *ob;
- Mesh *me;
- MVert *mvert;
- MFace *mface;
- MTFace *tf, *tface;
- Material *ma = NULL, *noma= NULL;
- RPatch *rp;
- RNode *rn;
- VeNoCo *vnc, **nodevert;
- float *vd, *v1, *v2, *v3, *v4 = NULL;
- int a, b, offs, index, mfdatatot;
-
- if (v3d==NULL) {
- printf("Error, trying to collect radiosity meshes with no 3d view\n");
- return;
- }
-
- set_radglobal(scene);
-
- freeAllRad(scene);
-
- start_fastmalloc("Radiosity");
-
- /* count the number of verts */
- RG.totvert= 0;
- RG.totface= 0;
- base= (scene->base.first);
- while(base) {
- if(((base)->flag & SELECT) && ((base)->lay & v3d->lay) ) {
- if(base->object->type==OB_MESH) {
- base->flag |= OB_RADIO;
- me= base->object->data;
- RG.totvert+= me->totvert;
- }
- }
- base= base->next;
- }
- if(RG.totvert==0) {
- if (!during_script()); //XXX error("No vertices");
- return;
- }
- vnc= RG.verts= MEM_callocN(RG.totvert*sizeof(VeNoCo), "radioverts");
-
- RG.min[0]= RG.min[1]= RG.min[2]= 1.0e20f;
- RG.max[0]= RG.max[1]= RG.max[2]= -1.0e20f;
-
- mfdatatot= 0;
-
- /* min-max and material array */
- base= (scene->base.first);
- while(base) {
- if( ((base)->flag & SELECT) && ((base)->lay & v3d->lay) ) {
- if(base->object->type==OB_MESH) {
- me= base->object->data;
- mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++) {
- vd= mallocVert();
- VECCOPY(vd, mvert->co);
- /* Should make MTC its own module... */
- Mat4MulVecfl(base->object->obmat, vd);
-
- vnc->v= vd;
- for(b=0; b<3; b++) {
- RG.min[b]= MIN2(RG.min[b], vd[b]);
- RG.max[b]= MAX2(RG.max[b], vd[b]);
- }
- vnc++;
- }
-
- if(base->object->totcol==0) {
- if(RG.totmat<MAXMAT) {
- if(noma==NULL) {
- noma= add_material("RadioMat");
- RG.matar[RG.totmat]= noma;
- RG.totmat++;
- }
- }
- }
- else {
- for(a=0; a<base->object->totcol; a++) {
- if(RG.totmat >= MAXMAT) break;
-
- ma = give_current_material(base->object, a+1);
-
- if (materialIndex(ma)!=-1) break;
-
- RG.matar[RG.totmat]= ma;
- RG.totmat++;
- }
- }
-
- mfdatatot += me->totface;
- }
- }
- base= base->next;
- }
-
- RG.cent[0]= (RG.min[0]+ RG.max[0])/2;
- RG.cent[1]= (RG.min[1]+ RG.max[1])/2;
- RG.cent[2]= (RG.min[2]+ RG.max[2])/2;
- RG.size[0]= (RG.max[0]- RG.min[0]);
- RG.size[1]= (RG.max[1]- RG.min[1]);
- RG.size[2]= (RG.max[2]- RG.min[2]);
- RG.maxsize= MAX3(RG.size[0],RG.size[1],RG.size[2]);
-
- RG.mfdata= MEM_callocN(sizeof(CustomData), "radiomfdata");
- RG.mfdatanodes= MEM_mallocN(sizeof(RNode*)*mfdatatot, "radiomfdatanodes");
- RG.mfdatatot= mfdatatot;
-
- /* make patches */
-
- RG.totelem= 0;
- RG.totpatch= 0;
- RG.totlamp= 0;
- offs= 0;
-
- base= (scene->base.first);
- while(base) {
- if( ((base)->flag & SELECT) && ((base)->lay & v3d->lay) ) {
- if(base->object->type==OB_MESH) {
- ob= base->object;
- me= ob->data;
- mface= me->mface;
- tface= me->mtface;
-
- index= -1;
-
- CustomData_merge(&me->fdata, RG.mfdata, CD_MASK_DERIVEDMESH,
- CD_DEFAULT, mfdatatot);
-
- for(a=0; a<me->totface; a++, mface++) {
- tf= tface? tface+a: NULL;
-
- if (tf && (tf->mode & TF_INVISIBLE))
- continue;
-
- rp= callocPatch();
- BLI_addtail(&(RG.patchbase), rp);
- rp->from= ob;
-
- if(mface->v4) rp->type= 4;
- else rp->type= 3;
-
- rp->first= rn= callocNode();
-
- if(mface->flag & ME_SMOOTH) rp->f1= RAD_NO_SPLIT;
-
- /* temporal: we store the venoco in the node */
- rn->v1= (float *)(RG.verts+mface->v1+offs);
- v1= (RG.verts+mface->v1+offs)->v;
- rn->v2= (float *)(RG.verts+mface->v2+offs);
- v2= (RG.verts+mface->v2+offs)->v;
- rn->v3= (float *)(RG.verts+mface->v3+offs);
- v3= (RG.verts+mface->v3+offs)->v;
-
- if(mface->v4) {
- rn->v4= (float *)(RG.verts+mface->v4+offs);
- v4= (RG.verts+mface->v4+offs)->v;
- }
- rn->par= rp;
- rn->f= RAD_PATCH; /* this node is a Patch */
- rn->type= rp->type;
-
- if(rn->type==4) {
- rp->area= AreaQ3Dfl(v1, v2, v3, v4);
- CalcNormFloat4(v1, v2, v3, v4, rp->norm);
- }
- else {
- rp->area= AreaT3Dfl(v1, v2, v3);
- CalcNormFloat(v1, v2, v3, rp->norm);
- }
-
- rn->area= rp->area;
-
- /* color and emit */
- if(mface->mat_nr != index) {
- index= mface->mat_nr;
- ma= give_current_material(ob, index+1);
- if(ma==0) ma= &defmaterial;
- }
- rp->ref[0]= ma->r;
- rp->ref[1]= ma->g;
- rp->ref[2]= ma->b;
-
- if(ma->emit) RG.totlamp++;
-
- rp->emit[0]= rp->emit[1]= rp->emit[2]= ma->emit;
- rp->emit[0]*= rp->ref[0];
- rp->emit[1]*= rp->ref[1];
- rp->emit[2]*= rp->ref[2];
-
-// uncommented, this is not satisfying, but i leave it in code for now (ton)
-// if(ma->translucency!=0.0) rn->f |= RAD_TWOSIDED;
-
- nodevert= (VeNoCo **)&(rn->v1);
- for(b=0; b<rp->type; b++) {
- rp->cent[0]+= (*nodevert)->v[0];
- rp->cent[1]+= (*nodevert)->v[1];
- rp->cent[2]+= (*nodevert)->v[2];
- nodevert++;
- }
- rp->cent[0]/= (float)rp->type;
- rp->cent[1]/= (float)rp->type;
- rp->cent[2]/= (float)rp->type;
-
- /* for reconstruction materials */
- rp->matindex= materialIndex(ma);
- if(rp->matindex==-1) rp->matindex= 1;
-
- /* these RNode's are stored now for later use in rad_addmesh
- they should not get deleted before that */
- rn->orig= RG.totelem;
- RG.mfdatanodes[RG.totelem]= rn;
-
- CustomData_copy_data(&me->fdata, RG.mfdata, a, RG.totelem, 1);
-
- RG.totelem++;
- RG.totpatch++;
- }
-
- offs+= me->totvert;
- }
- }
- base= base->next;
- }
-
- splitconnected();
- setedgepointers();
-
- makeGlobalElemArray();
- pseudoAmb();
- rad_setlimits(scene);
-}
-
-void setparelem(RNode *rn, RPatch *par)
-{
-
- if(rn->down1) {
- setparelem(rn->down1, par);
- setparelem(rn->down2, par);
- }
- else {
- rn->par= par;
- }
-}
-
-void countelem(RNode *rn)
-{
-
- if(rn->down1) {
- countelem(rn->down1);
- countelem(rn->down2);
- }
- else RG.totelem++;
-}
-
-void countglobaldata()
-{
- /* counts elements and patches*/
- RPatch *rp;
-
- RG.totelem= RG.totpatch= 0;
-
- rp= RG.patchbase.first;
- while(rp) {
- RG.totpatch++;
- countelem(rp->first);
- rp= rp->next;
- }
-}
-
-void addelem(RNode ***el, RNode *rn, RPatch *rp)
-{
- if(rn->down1) {
- addelem(el, rn->down1, rp);
- addelem(el, rn->down2, rp);
- }
- else {
- rn->par= rp;
- **el= rn;
- (*el)++;
- }
-}
-
-void makeGlobalElemArray()
-{
- /* always called when # of elements change */
- RPatch *rp;
- RNode **el;
-
- countglobaldata();
-
- if(RG.elem) MEM_freeN(RG.elem);
- if(RG.totelem) {
- el= RG.elem= MEM_mallocN(sizeof(void *)*RG.totelem, "makeGlobalElemArray");
- }
- else {
- RG.elem= 0;
- return;
- }
-
- /* recursive adding elements */
- rp= RG.patchbase.first;
- while(rp) {
- addelem(&el, rp->first, rp);
- rp= rp->next;
- }
-
- /* formfactor array */
- if(RG.formfactors) MEM_freeN(RG.formfactors);
- if(RG.totelem)
- RG.formfactors= MEM_mallocN(sizeof(float)*RG.totelem, "formfactors");
- else
- RG.formfactors= 0;
-}
-
-void splitpatch(RPatch *old) /* in case of overflow during shoot */
-{
- RNode *rn;
- float **fpp;
- RPatch *rp;
- int a;
-
- rn= old->first;
- if(rn->down1==0) return;
- rn= rn->down1;
-
- old->unshot[0]/=2.0;
- old->unshot[1]/=2.0;
- old->unshot[2]/=2.0;
- setnodeflags(old->first, 2, 0);
-
- rp= mallocPatch();
- *rp= *old;
- BLI_addhead(&RG.patchbase, rp);
- rp->first= rn;
- rp->area= rn->area;
- rp->cent[0]= rp->cent[1]= rp->cent[2]= 0.0;
- fpp= &(rn->v1);
- for(a=0; a<rp->type; a++) {
- rp->cent[0]+= (*fpp)[0];
- rp->cent[1]+= (*fpp)[1];
- rp->cent[2]+= (*fpp)[2];
- fpp++;
- }
- rp->cent[0]/=(float)rp->type;
- rp->cent[1]/=(float)rp->type;
- rp->cent[2]/=(float)rp->type;
-
- setparelem(rn, rp);
-
- rn= old->first->down2;
-
- rp= mallocPatch();
- *rp= *old;
- BLI_addhead(&RG.patchbase, rp);
- rp->first= rn;
- rp->area= rn->area;
- rp->cent[0]= rp->cent[1]= rp->cent[2]= 0.0;
- fpp= &(rn->v1);
- for(a=0; a<rp->type; a++) {
- rp->cent[0]+= (*fpp)[0];
- rp->cent[1]+= (*fpp)[1];
- rp->cent[2]+= (*fpp)[2];
- fpp++;
- }
- rp->cent[0]/=(float)rp->type;
- rp->cent[1]/=(float)rp->type;
- rp->cent[2]/=(float)rp->type;
-
- setparelem(rn, rp);
-
- BLI_remlink(&RG.patchbase, old);
- freePatch(old);
-}
-
-
-void addpatch(RPatch *old, RNode *rn)
-{
- float **fpp;
- RPatch *rp;
- int a;
-
- if(rn->down1) {
- addpatch(old, rn->down1);
- addpatch(old, rn->down2);
- }
- else {
- rp= mallocPatch();
- *rp= *old;
- BLI_addhead(&RG.patchbase, rp);
- rp->first= rn;
-
- rp->area= rn->area;
- rp->cent[0]= rp->cent[1]= rp->cent[2]= 0.0;
- fpp= &(rn->v1);
- for(a=0; a<rp->type; a++) {
- rp->cent[0]+= (*fpp)[0];
- rp->cent[1]+= (*fpp)[1];
- rp->cent[2]+= (*fpp)[2];
- fpp++;
- }
- rp->cent[0]/=(float)rp->type;
- rp->cent[1]/=(float)rp->type;
- rp->cent[2]/=(float)rp->type;
-
- rn->par= rp;
- }
-}
-
-void converttopatches()
-{
- /* chacks patches list, if node subdivided: new patch */
- RPatch *rp, *next;
-
- rp= RG.patchbase.first;
- while(rp) {
- next= rp->next;
- if(rp->first->down1) {
- addpatch(rp, rp->first);
- BLI_remlink(&RG.patchbase, rp);
- freePatch(rp);
- }
- rp= next;
- }
-
-}
-
-void subdiv_elements()
-{
- RNode **el, *rn;
- int a, toobig= 1;
-
- rad_init_energy();
-
- /* first maxsize elements */
-
- while(toobig) {
- toobig= 0;
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- if( rn->totrad[0]==0.0 && rn->totrad[1]==0.0 && rn->totrad[2]==0.0) {
- if(rn->area>RG.elemmin) {
- subdivideNode(rn, 0);
- if(rn->down1 ) {
- toobig= 1;
- if(rn->down1->area>RG.elemmin)
- subdivideNode( rn->down1, 0);
- if(rn->down2->area>RG.elemmin)
- subdivideNode( rn->down2, 0);
- }
- }
- }
- }
- if(toobig) makeGlobalElemArray();
- }
-
- el= RG.elem;
- for(a=RG.totelem; a>0; a--, el++) {
- rn= *el;
- if( rn->totrad[0]==0.0 && rn->totrad[1]==0.0 && rn->totrad[2]==0.0) {
- subdivideNode(rn, 0);
- if( rn->down1 ) {
- subdivideNode( rn->down1, 0);
- subdivideNode( rn->down2, 0);
- }
- }
- }
- makeGlobalElemArray();
-}
-
-void subdividelamps()
-{
- RPatch *rp, *next;
-
- rp= RG.patchbase.first;
- while(rp) {
- next= rp->next;
- if(rp->emit[0]!=0.0 || rp->emit[1]!=0.0 || rp->emit[2]!=0.0) {
- subdivideNode( rp->first, 0);
- if(rp->first->down1) {
- subdivideNode(rp->first->down1, 0);
- subdivideNode(rp->first->down2, 0);
- }
-
- addpatch(rp, rp->first);
- BLI_remlink(&RG.patchbase, rp);
- freePatch(rp);
- }
- rp= next;
- }
-
-}
-
-void maxsizePatches()
-{
- RPatch *rp;
- int toobig= 1;
-
- while(toobig) {
- toobig= 0;
- rp= RG.patchbase.first;
- while(rp) {
- if(rp->area>RG.patchmax) {
- subdivideNode( rp->first, 0);
- if(rp->first->down1) toobig= 1;
- }
- rp= rp->next;
- }
-
- if(toobig) converttopatches();
- }
-
- /* count lamps */
- rp= RG.patchbase.first;
- RG.totlamp= 0;
- while(rp) {
- if(rp->emit[0]!=0.0 || rp->emit[1]!=0.0 || rp->emit[2]!=0.0) {
- RG.totlamp++;
- }
- rp= rp->next;
- }
- makeGlobalElemArray();
-}
-
-
-
diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c
deleted file mode 100644
index d33bbc90ee3..00000000000
--- a/source/blender/radiosity/intern/source/radrender.c
+++ /dev/null
@@ -1,530 +0,0 @@
-/* ***************************************
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/* radrender.c, aug 2003
- *
- * Most of the code here is copied from radiosity code, to optimize for renderfaces.
- * Shared function calls mostly reside in radfactors.c
- * No adaptive subdivision takes place
- *
- * - do_radio_render(); main call, extern
- * - initradfaces(); add radface structs in render faces, init radio globals
- * -
- * - initradiosity(); LUTs
- * - inithemiwindows();
- * - progressiverad(); main itteration loop
- * - hemi zbuffers
- * - calc rad factors
- *
- * - closehemiwindows();
- * - freeAllRad();
- * - make vertex colors
- *
- * - during render, materials use totrad as ambient replacement
- * - free radfaces
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_rand.h"
-
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
-
-#include "radio.h"
-
-/* the radiosity module uses internal includes from render! */
-#include "renderpipeline.h"
-#include "render_types.h"
-#include "renderdatabase.h"
-
-
-/* only needed now for a print, if its useful move to RG */
-static float maxenergy;
-
-/* find the face with maximum energy to become shooter */
-/* nb: _rr means rad-render version of existing radio call */
-static void findshoot_rr(Render *re, VlakRen **shoot_p, RadFace **shootrf_p)
-{
- RadFace *rf, *shootrf, **radface;
- ObjectRen *obr;
- VlakRen *vlr=NULL, *shoot;
- float energy;
- int a;
-
- shoot= NULL;
- shootrf= NULL;
- maxenergy= 0.0;
-
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- rf->flag &= ~RAD_SHOOT;
-
- energy= rf->unshot[0]*rf->area;
- energy+= rf->unshot[1]*rf->area;
- energy+= rf->unshot[2]*rf->area;
-
- if(energy>maxenergy) {
- shoot= vlr;
- shootrf= rf;
- maxenergy= energy;
- }
- }
- }
- }
-
- if(shootrf) {
- maxenergy/= RG.totenergy;
- if(maxenergy<RG.convergence) {
- *shoot_p= NULL;
- *shootrf_p= NULL;
- return;
- }
- shootrf->flag |= RAD_SHOOT;
- }
-
- *shoot_p= shoot;
- *shootrf_p= shootrf;
-}
-
-static void backface_test_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float tvec[3];
- int a;
-
- /* backface testing */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr != shoot && (radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- VecSubf(tvec, shootrf->cent, rf->cent);
-
- if(tvec[0]*rf->norm[0]+ tvec[1]*rf->norm[1]+ tvec[2]*rf->norm[2] < 0.0)
- rf->flag |= RAD_BACKFACE;
- }
- }
- }
-}
-
-static void clear_backface_test_rr(Render *re)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- int a;
-
- /* backface flag clear */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- rf->flag &= ~RAD_BACKFACE;
- }
- }
- }
-}
-
-extern RadView hemitop, hemiside; // radfactors.c
-
-/* hemi-zbuffering, delivers formfactors array */
-static void makeformfactors_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float len, vec[3], up[3], side[3], tar[5][3], *fp;
- int a;
-
- memset(RG.formfactors, 0, sizeof(float)*RG.totelem);
-
- /* set up hemiview */
- /* first: upvector for hemitop, we use diagonal hemicubes to prevent aliasing */
-
- VecSubf(vec, shoot->v1->co, shootrf->cent);
- Crossf(up, shootrf->norm, vec);
- len= Normalize(up);
-
- VECCOPY(hemitop.up, up);
- VECCOPY(hemiside.up, shootrf->norm);
-
- Crossf(side, shootrf->norm, up);
-
- /* five targets */
- VecAddf(tar[0], shootrf->cent, shootrf->norm);
- VecAddf(tar[1], shootrf->cent, up);
- VecSubf(tar[2], shootrf->cent, up);
- VecAddf(tar[3], shootrf->cent, side);
- VecSubf(tar[4], shootrf->cent, side);
-
- /* camera */
- VECCOPY(hemiside.cam, shootrf->cent);
- VECCOPY(hemitop.cam, shootrf->cent);
-
- /* do it! */
- VECCOPY(hemitop.tar, tar[0]);
- hemizbuf(&hemitop);
-
- for(a=1; a<5; a++) {
- VECCOPY(hemiside.tar, tar[a]);
- hemizbuf(&hemiside);
- }
-
- /* convert factors to real radiosity */
- fp= RG.formfactors;
-
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- if(*fp!=0.0 && rf->area!=0.0) {
- *fp *= shootrf->area/rf->area;
- if(*fp>1.0) *fp= 1.0001;
- }
- fp++;
- }
- }
- }
-}
-
-/* based at RG.formfactors array, distribute shoot energy over other faces */
-static void applyformfactors_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
-{
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float *fp, *ref, unr, ung, unb, r, g, b;
- int a;
-
- unr= shootrf->unshot[0];
- ung= shootrf->unshot[1];
- unb= shootrf->unshot[2];
-
- fp= RG.formfactors;
-
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- if(*fp!= 0.0) {
-
- ref= &(vlr->mat->r);
-
- r= (*fp)*unr*ref[0];
- g= (*fp)*ung*ref[1];
- b= (*fp)*unb*ref[2];
-
- // if(rf->flag & RAD_BACKFACE) {
-
- rf->totrad[0]+= r;
- rf->totrad[1]+= g;
- rf->totrad[2]+= b;
-
- rf->unshot[0]+= r;
- rf->unshot[1]+= g;
- rf->unshot[2]+= b;
- }
- fp++;
- }
- }
- }
- /* shoot energy has been shot */
- shootrf->unshot[0]= shootrf->unshot[1]= shootrf->unshot[2]= 0.0;
-}
-
-
-/* main loop for itterations */
-static void progressiverad_rr(Render *re)
-{
- VlakRen *shoot;
- RadFace *shootrf;
- float unshot[3];
- int it= 0;
-
- findshoot_rr(re, &shoot, &shootrf);
- while( shoot ) {
-
- /* backfaces receive no energy, but are zbuffered... */
- backface_test_rr(re, shoot, shootrf);
-
- /* ...unless it's two sided */
- if(shootrf->flag & RAD_TWOSIDED) {
- VECCOPY(unshot, shootrf->unshot);
- VecNegf(shootrf->norm);
- makeformfactors_rr(re, shoot, shootrf);
- applyformfactors_rr(re, shoot, shootrf);
- VecNegf(shootrf->norm);
- VECCOPY(shootrf->unshot, unshot);
- }
-
- /* hemi-zbuffers */
- makeformfactors_rr(re, shoot, shootrf);
- /* based at RG.formfactors array, distribute shoot energy over other faces */
- applyformfactors_rr(re, shoot, shootrf);
-
- it++;
- re->timecursor(re->tch, it);
-
- clear_backface_test_rr(re);
-
- if(re->test_break(re->tbh)) break;
- if(RG.maxiter && RG.maxiter<=it) break;
-
- findshoot_rr(re, &shoot, &shootrf);
- }
- printf(" Unshot energy:%f\n", 1000.0*maxenergy);
-
- re->timecursor(re->tch, re->scene->r.cfra);
-}
-
-static RadFace *radfaces=NULL;
-
-static void initradfaces(Render *re)
-{
- ObjectRen *obr;
- VlakRen *vlr= NULL;
- RadFace *rf, **radface;
- int a, b;
-
- /* globals */
- RG.totenergy= 0.0;
- RG.totpatch= 0; // we count initial emittors here
- RG.totelem= 0; // total # faces are put here (so we can use radfactors.c calls)
- /* size is needed for hemicube clipping */
- RG.min[0]= RG.min[1]= RG.min[2]= 1.0e20;
- RG.max[0]= RG.max[1]= RG.max[2]= -1.0e20;
-
- /* count first for fast malloc */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if(vlr->mat->mode & MA_RADIO) {
- if(vlr->mat->emit > 0.0) {
- RG.totpatch++;
- }
- RG.totelem++;
- }
- }
- }
-
-printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch);
- if(RG.totelem==0 || RG.totpatch==0) return;
-
- /* make/init radfaces */
- rf=radfaces= MEM_callocN(RG.totelem*sizeof(RadFace), "radfaces");
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if(vlr->mat->mode & MA_RADIO) {
-
- /* during render, vlr->n gets flipped/corrected, we cannot have that */
- if (obr->ob->transflag & OB_NEG_SCALE){
- /* The object has negative scale that will cause the normals to flip.
- To counter this unwanted normal flip, swap vertex 2 and 4 for a quad
- or vertex 2 and 3 (see flip_face) for a triangle in the call to CalcNormFloat4
- in order to flip the normals back to the way they were in the original mesh. */
- if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v4->co, vlr->v3->co, vlr->v2->co, rf->norm);
- else CalcNormFloat(vlr->v1->co, vlr->v3->co, vlr->v2->co, rf->norm);
- }else{
- if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
- else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
- }
-
- rf->totrad[0]= vlr->mat->emit*vlr->mat->r;
- rf->totrad[1]= vlr->mat->emit*vlr->mat->g;
- rf->totrad[2]= vlr->mat->emit*vlr->mat->b;
- VECCOPY(rf->unshot, rf->totrad);
-
- if(vlr->v4) {
- rf->area= AreaQ3Dfl(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co);
- CalcCent4f(rf->cent, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co);
- }
- else {
- rf->area= AreaT3Dfl(vlr->v1->co, vlr->v2->co, vlr->v3->co);
- CalcCent3f(rf->cent, vlr->v1->co, vlr->v2->co, vlr->v3->co);
- }
-
- RG.totenergy+= rf->unshot[0]*rf->area;
- RG.totenergy+= rf->unshot[1]*rf->area;
- RG.totenergy+= rf->unshot[2]*rf->area;
-
- for(b=0; b<3; b++) {
- RG.min[b]= MIN2(RG.min[b], rf->cent[b]);
- RG.max[b]= MAX2(RG.max[b], rf->cent[b]);
- }
-
- // uncommented; this isnt satisfying, but i leave it in the code for now (ton)
- // if(vlr->mat->translucency!=0.0) rf->flag |= RAD_TWOSIDED;
-
- radface=RE_vlakren_get_radface(obr, vlr, 1);
- *radface= rf++;
- }
- }
- }
- RG.size[0]= (RG.max[0]- RG.min[0]);
- RG.size[1]= (RG.max[1]- RG.min[1]);
- RG.size[2]= (RG.max[2]- RG.min[2]);
- RG.maxsize= MAX3(RG.size[0],RG.size[1],RG.size[2]);
-
- /* formfactor array */
- if(RG.formfactors) MEM_freeN(RG.formfactors);
- if(RG.totelem)
- RG.formfactors= MEM_mallocN(sizeof(float)*RG.totelem, "formfactors");
- else
- RG.formfactors= NULL;
-
-}
-
-static void vecaddfac(float *vec, float *v1, float *v2, float fac)
-{
- vec[0]= v1[0] + fac*v2[0];
- vec[1]= v1[1] + fac*v2[1];
- vec[2]= v1[2] + fac*v2[2];
-
-}
-
-/* unused now, doesnt work..., find it in cvs of nov 2005 or older */
-/* static void filter_rad_values(void) */
-
-
-static void make_vertex_rad_values(Render *re)
-{
- ObjectRen *obr;
- VertRen *v1=NULL;
- VlakRen *vlr=NULL;
- RadFace *rf, **radface;
- float *col;
- int a;
-
- RG.igamma= 1.0/RG.gamma;
- RG.radfactor= RG.radfac*pow(64*64, RG.igamma)/128.0; /* compatible with radio-tool */
-
- /* accumulate vertexcolors */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
-
- /* apply correction */
- rf->totrad[0]= RG.radfactor*pow( rf->totrad[0], RG.igamma);
- rf->totrad[1]= RG.radfactor*pow( rf->totrad[1], RG.igamma);
- rf->totrad[2]= RG.radfactor*pow( rf->totrad[2], RG.igamma);
-
- /* correct rf->rad values for color */
- if(vlr->mat->r > 0.0) rf->totrad[0]/= vlr->mat->r;
- if(vlr->mat->g > 0.0) rf->totrad[1]/= vlr->mat->g;
- if(vlr->mat->b > 0.0) rf->totrad[2]/= vlr->mat->b;
-
- col= RE_vertren_get_rad(obr, vlr->v1, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
-
- col= RE_vertren_get_rad(obr, vlr->v2, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
-
- col= RE_vertren_get_rad(obr, vlr->v3, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
-
- if(vlr->v4) {
- col= RE_vertren_get_rad(obr, vlr->v4, 1);
- vecaddfac(col, col, rf->totrad, rf->area);
- col[3]+= rf->area;
- }
- }
- }
-
- /* make vertex colors */
- for(a=0; a<obr->totvert; a++) {
- if((a & 255)==0) v1= RE_findOrAddVert(obr, a); else v1++;
-
- col= RE_vertren_get_rad(obr, v1, 0);
- if(col && col[3]>0.0) {
- col[0]/= col[3];
- col[1]/= col[3];
- col[2]/= col[3];
- }
- }
- }
-}
-
-/* main call, extern */
-void do_radio_render(Render *re)
-{
- if(re->scene->radio==NULL) add_radio(re->scene);
- freeAllRad(re->scene); /* just in case radio-tool is still used */
-
- set_radglobal(re->scene); /* init the RG struct */
- RG.re= re; /* only used by hemizbuf(), prevents polluting radio code all over */
-
- initradfaces(re); /* add radface structs to render faces */
- if(RG.totenergy>0.0) {
-
- initradiosity(); /* LUT's */
- inithemiwindows(); /* views, need RG.maxsize for clipping */
-
- progressiverad_rr(re); /* main radio loop */
-
- make_vertex_rad_values(re); /* convert face energy to vertex ones */
-
- }
-
- freeAllRad(re->scene); /* luts, hemis, sets vars at zero */
-}
-
-/* free call, after rendering, extern */
-void end_radio_render(void)
-{
- if(radfaces) MEM_freeN(radfaces);
- radfaces= NULL;
-}
-
diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h
index 20eea0c98bd..15b59f2c8cc 100644
--- a/source/blender/render/extern/include/RE_render_ext.h
+++ b/source/blender/render/extern/include/RE_render_ext.h
@@ -47,7 +47,8 @@ struct Render;
struct MTex;
struct ImBuf;
-void RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_totelem, struct Render *re);
+// RADIO REMOVED, Maybe this will be useful later
+//void RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_totelem, struct Render *re);
/* particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */
int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta);
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 98e5819c0d3..a00cd2211fc 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -104,7 +104,6 @@
#include "rendercore.h"
#include "renderdatabase.h"
#include "renderpipeline.h"
-#include "radio.h"
#include "shadbuf.h"
#include "shading.h"
#include "strand.h"
@@ -1886,6 +1885,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(psys_get_particle_state(re->scene,ob,psys,a,&state,0)==0)
continue;
+ if(psys->parent)
+ Mat4MulVecfl(psys->parent->obmat, state.co);
+
VECCOPY(loc,state.co);
if(part->ren_as!=PART_DRAW_BB)
MTC_Mat4MulVecfl(re->viewmat,loc);
@@ -4308,8 +4310,9 @@ void RE_Database_Free(Render *re)
}
free_mesh_orco_hash(re);
-
+#if 0 /* radio can be redone better */
end_radio_render();
+#endif
end_render_materials();
end_render_textures();
@@ -4736,10 +4739,11 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view)
/* yafray: 'direct' radiosity, environment maps and raytree init not needed for yafray render */
/* although radio mode could be useful at some point, later */
if (re->r.renderer==R_INTERN) {
+#if 0 /* RADIO was removed */
/* RADIO (uses no R anymore) */
if(!re->test_break(re->tbh))
if(re->r.mode & R_RADIO) do_radio_render(re);
-
+#endif
/* raytree */
if(!re->test_break(re->tbh)) {
if(re->r.mode & R_RAYTRACE) {
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 07560edb76b..5eec13ed7fe 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -46,6 +46,7 @@
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */
+#include "BKE_pointcache.h"
#include "MEM_guardedalloc.h"
@@ -61,7 +62,6 @@
#include "intern/openexr/openexr_multi.h"
#include "RE_pipeline.h"
-#include "radio.h"
/* internal */
#include "render_types.h"
@@ -2413,6 +2413,20 @@ static int is_rendering_allowed(Render *re)
return 1;
}
+static void update_physics_cache(Render *re, Scene *scene)
+{
+ PTCacheBaker baker;
+
+ baker.scene = scene;
+ baker.pid = NULL;
+ baker.bake = 0;
+ baker.render = 1;
+ baker.break_test = re->test_break;
+ baker.break_data = re->tbh;
+ baker.progressbar = NULL;
+
+ BKE_ptcache_make_cache(&baker);
+}
/* evaluating scene options for general Blender render */
static int render_initialize_from_scene(Render *re, Scene *scene, int anim)
{
@@ -2450,6 +2464,9 @@ static int render_initialize_from_scene(Render *re, Scene *scene, int anim)
/* check all scenes involved */
tag_scenes_for_render(re);
+
+ /* make sure dynamics are up to date */
+ update_physics_cache(re, scene);
if(scene->r.scemode & R_SINGLE_LAYER)
push_render_result(re);
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index b68cecce7bd..21c3977fc0b 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -49,14 +49,12 @@
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_material_types.h"
#include "BKE_global.h"
#include "BKE_material.h"
#include "BKE_utildefines.h"
-#include "radio_types.h"
-#include "radio.h" /* needs RG, some root data for radiosity */
-
#include "RE_render_ext.h"
/* local includes */
@@ -2301,110 +2299,6 @@ static int hashlist_projectvert(float *v1, float winmat[][4], float *hoco)
return buck->clip;
}
-/* used for booth radio 'tool' as during render */
-void RE_zbufferall_radio(struct RadView *vw, RNode **rg_elem, int rg_totelem, Render *re)
-{
- ZSpan zspan;
- float hoco[4][4], winmat[4][4];
- int a, zvlnr;
- int c1, c2, c3, c4= 0;
-
- if(rg_totelem==0) return;
-
- hashlist_projectvert(NULL, winmat, NULL);
-
- /* needed for projectvert */
- MTC_Mat4MulMat4(winmat, vw->viewmat, vw->winmat);
-
- /* 1.0f for clipping in clippyra()... bad stuff actually */
- zbuf_alloc_span(&zspan, vw->rectx, vw->recty, 1.0f);
- zspan.zmulx= ((float)vw->rectx)/2.0;
- zspan.zmuly= ((float)vw->recty)/2.0;
- zspan.zofsx= -0.5f;
- zspan.zofsy= -0.5f;
-
- /* the buffers */
- zspan.rectz= (int *)vw->rectz;
- zspan.rectp= (int *)vw->rect;
- zspan.recto= MEM_callocN(sizeof(int)*vw->rectx*vw->recty, "radiorecto");
- fillrect(zspan.rectz, vw->rectx, vw->recty, 0x7FFFFFFF);
- fillrect(zspan.rectp, vw->rectx, vw->recty, 0xFFFFFF);
-
- /* filling methods */
- zspan.zbuffunc= zbuffillGL4;
-
- if(rg_elem) { /* radio tool */
- RNode **re, *rn;
-
- re= rg_elem;
- re+= (rg_totelem-1);
- for(a= rg_totelem-1; a>=0; a--, re--) {
- rn= *re;
- if( (rn->f & RAD_SHOOT)==0 ) { /* no shootelement */
-
- if( rn->f & RAD_TWOSIDED) zvlnr= a;
- else if( rn->f & RAD_BACKFACE) zvlnr= 0xFFFFFF;
- else zvlnr= a;
-
- c1= hashlist_projectvert(rn->v1, winmat, hoco[0]);
- c2= hashlist_projectvert(rn->v2, winmat, hoco[1]);
- c3= hashlist_projectvert(rn->v3, winmat, hoco[2]);
-
- if(rn->v4) {
- c4= hashlist_projectvert(rn->v4, winmat, hoco[3]);
- }
-
- if(rn->v4)
- zbufclip4(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
- else
- zbufclip(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], c1, c2, c3);
- }
- }
- }
- else { /* radio render */
- ObjectRen *obr;
- VlakRen *vlr=NULL;
- RadFace **radface, *rf;
- int totface=0;
-
- /* note: radio render doesn't support duplis */
- for(obr=re->objecttable.first; obr; obr=obr->next) {
- hashlist_projectvert(NULL, NULL, NULL); /* clear hashlist */
-
- for(a=0; a<obr->totvlak; a++) {
- if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
-
- if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
- rf= *radface;
- if( (rf->flag & RAD_SHOOT)==0 ) { /* no shootelement */
-
- if( rf->flag & RAD_TWOSIDED) zvlnr= totface;
- else if( rf->flag & RAD_BACKFACE) zvlnr= 0xFFFFFF; /* receives no energy, but is zbuffered */
- else zvlnr= totface;
-
- c1= hashlist_projectvert(vlr->v1->co, winmat, hoco[0]);
- c2= hashlist_projectvert(vlr->v2->co, winmat, hoco[1]);
- c3= hashlist_projectvert(vlr->v3->co, winmat, hoco[2]);
-
- if(vlr->v4) {
- c4= hashlist_projectvert(vlr->v4->co, winmat, hoco[3]);
- }
-
- if(vlr->v4)
- zbufclip4(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4);
- else
- zbufclip(&zspan, 0, zvlnr, hoco[0], hoco[1], hoco[2], c1, c2, c3);
- }
- totface++;
- }
- }
- }
- }
-
- MEM_freeN(zspan.recto);
- zbuf_free_span(&zspan);
-}
-
void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int size, float jitx, float jity)
{
ZbufProjectCache cache[ZBUF_PROJECT_CACHE_SIZE];
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 739cfbcc1ac..9b987cdfa51 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -58,37 +58,6 @@ enum {
WM_OP_EXEC_SCREEN
};
-/* ************** wmEvent ************************ */
-
-/* each event should have full modifier state */
-/* event comes from eventmanager and from keymap */
-typedef struct wmEvent {
- struct wmEvent *next, *prev;
-
- short type; /* event code itself (short, is also in keymap) */
- short val; /* press, release, scrollvalue */
- short x, y; /* mouse pointer position, screen coord */
- short mval[2]; /* region mouse position, name convention pre 2.5 :) */
- short prevx, prevy; /* previous mouse pointer position */
- short unicode; /* future, ghost? */
- char ascii; /* from ghost */
- char pad;
-
- /* modifier states */
- short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */
- short keymodifier; /* rawkey modifier */
-
- /* keymap item, set by handler (weak?) */
- const char *keymap_idname;
-
- /* custom data */
- short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */
- void *customdata; /* ascii, unicode, mouse coords, angles, vectors, dragdrop info */
- short customdatafree;
-
-} wmEvent;
-
-
/* ************** wmKeyMap ************************ */
/* modifier */
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index adbc43e439d..0bc35ffa9b2 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -58,8 +58,6 @@
#include "RE_pipeline.h" /* RE_ free stuff */
-#include "radio.h"
-
#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
#endif
@@ -196,9 +194,6 @@ void WM_exit(bContext *C)
// BIF_freeRetarget();
BIF_freeTemplates(C);
BIF_freeSketch(C);
-
- /* Context should still working here. but radio tool needs cleaning... */
- freeAllRad(CTX_data_scene(C));
free_ttfont(); /* bke_font.h */
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 7528321c7c5..85028e3ea1a 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -44,6 +44,7 @@
#include "RNA_access.h"
#include "RNA_types.h"
+#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -155,313 +156,9 @@ ListBase *WM_keymap_listbase(wmWindowManager *wm, const char *nameid, int spacei
char *WM_key_event_string(short type)
{
- /* not returned: CAPSLOCKKEY, UNKNOWNKEY, COMMANDKEY, GRLESSKEY */
-
- switch(type) {
- case AKEY:
- return "A";
- break;
- case BKEY:
- return "B";
- break;
- case CKEY:
- return "C";
- break;
- case DKEY:
- return "D";
- break;
- case EKEY:
- return "E";
- break;
- case FKEY:
- return "F";
- break;
- case GKEY:
- return "G";
- break;
- case HKEY:
- return "H";
- break;
- case IKEY:
- return "I";
- break;
- case JKEY:
- return "J";
- break;
- case KKEY:
- return "K";
- break;
- case LKEY:
- return "L";
- break;
- case MKEY:
- return "M";
- break;
- case NKEY:
- return "N";
- break;
- case OKEY:
- return "O";
- break;
- case PKEY:
- return "P";
- break;
- case QKEY:
- return "Q";
- break;
- case RKEY:
- return "R";
- break;
- case SKEY:
- return "S";
- break;
- case TKEY:
- return "T";
- break;
- case UKEY:
- return "U";
- break;
- case VKEY:
- return "V";
- break;
- case WKEY:
- return "W";
- break;
- case XKEY:
- return "X";
- break;
- case YKEY:
- return "Y";
- break;
- case ZKEY:
- return "Z";
- break;
-
- case ZEROKEY:
- return "Zero";
- break;
- case ONEKEY:
- return "One";
- break;
- case TWOKEY:
- return "Two";
- break;
- case THREEKEY:
- return "Three";
- break;
- case FOURKEY:
- return "Four";
- break;
- case FIVEKEY:
- return "Five";
- break;
- case SIXKEY:
- return "Six";
- break;
- case SEVENKEY:
- return "Seven";
- break;
- case EIGHTKEY:
- return "Eight";
- break;
- case NINEKEY:
- return "Nine";
- break;
-
- case LEFTCTRLKEY:
- return "Leftctrl";
- break;
- case LEFTALTKEY:
- return "Leftalt";
- break;
- case RIGHTALTKEY:
- return "Rightalt";
- break;
- case RIGHTCTRLKEY:
- return "Rightctrl";
- break;
- case RIGHTSHIFTKEY:
- return "Rightshift";
- break;
- case LEFTSHIFTKEY:
- return "Leftshift";
- break;
-
- case ESCKEY:
- return "Esc";
- break;
- case TABKEY:
- return "Tab";
- break;
- case RETKEY:
- return "Ret";
- break;
- case SPACEKEY:
- return "Space";
- break;
- case LINEFEEDKEY:
- return "Linefeed";
- break;
- case BACKSPACEKEY:
- return "Backspace";
- break;
- case DELKEY:
- return "Del";
- break;
- case SEMICOLONKEY:
- return "Semicolon";
- break;
- case PERIODKEY:
- return "Period";
- break;
- case COMMAKEY:
- return "Comma";
- break;
- case QUOTEKEY:
- return "Quote";
- break;
- case ACCENTGRAVEKEY:
- return "Accentgrave";
- break;
- case MINUSKEY:
- return "Minus";
- break;
- case SLASHKEY:
- return "Slash";
- break;
- case BACKSLASHKEY:
- return "Backslash";
- break;
- case EQUALKEY:
- return "Equal";
- break;
- case LEFTBRACKETKEY:
- return "Leftbracket";
- break;
- case RIGHTBRACKETKEY:
- return "Rightbracket";
- break;
-
- case LEFTARROWKEY:
- return "Leftarrow";
- break;
- case DOWNARROWKEY:
- return "Downarrow";
- break;
- case RIGHTARROWKEY:
- return "Rightarrow";
- break;
- case UPARROWKEY:
- return "Uparrow";
- break;
-
- case PAD2:
- return "Numpad 2";
- break;
- case PAD4:
- return "Numpad 4";
- break;
- case PAD6:
- return "Numpad 6";
- break;
- case PAD8:
- return "Numpad 8";
- break;
- case PAD1:
- return "Numpad 1";
- break;
- case PAD3:
- return "Numpad 3";
- break;
- case PAD5:
- return "Numpad 5";
- break;
- case PAD7:
- return "Numpad 7";
- break;
- case PAD9:
- return "Numpad 9";
- break;
-
- case PADPERIOD:
- return "Numpad .";
- break;
- case PADSLASHKEY:
- return "Numpad /";
- break;
- case PADASTERKEY:
- return "Numpad *";
- break;
-
- case PAD0:
- return "Numpad 0";
- break;
- case PADMINUS:
- return "Numpad -";
- break;
- case PADENTER:
- return "Numpad Enter";
- break;
- case PADPLUSKEY:
- return "Numpad +";
- break;
-
- case F1KEY:
- return "F1";
- break;
- case F2KEY:
- return "F2";
- break;
- case F3KEY:
- return "F3";
- break;
- case F4KEY:
- return "F4";
- break;
- case F5KEY:
- return "F5";
- break;
- case F6KEY:
- return "F6";
- break;
- case F7KEY:
- return "F7";
- break;
- case F8KEY:
- return "F8";
- break;
- case F9KEY:
- return "F9";
- break;
- case F10KEY:
- return "F10";
- break;
- case F11KEY:
- return "F11";
- break;
- case F12KEY:
- return "F12";
- break;
-
- case PAUSEKEY:
- return "Pause";
- break;
- case INSERTKEY:
- return "Insert";
- break;
- case HOMEKEY:
- return "Home";
- break;
- case PAGEUPKEY:
- return "Pageup";
- break;
- case PAGEDOWNKEY:
- return "Pagedown";
- break;
- case ENDKEY:
- return "End";
- break;
- }
+ const char *name= NULL;
+ if(RNA_enum_name(event_type_items, (int)type, &name))
+ return name;
return "";
}
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 4701eba810f..ade5a2a64a8 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -198,7 +198,7 @@ ADD_DEPENDENCIES(blender makesdna)
FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS)
-SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render blender_radiosity)
+SET(BLENDER_LINK_LIBS bf_nodes ${BLENDER_LINK_LIBS} bf_windowmanager bf_editors blender_render)
IF(WITH_ELBEEM)
SET(BLENDER_LINK_LIBS ${BLENDER_LINK_LIBS} bf_elbeem)
@@ -218,7 +218,6 @@ IF(UNIX)
bf_ghost
bf_string
blender_render
- blender_radiosity
blender_ONL
bf_python
bf_gen_python
@@ -238,7 +237,6 @@ IF(UNIX)
bf_kernel
bf_decimation
bf_elbeem
- bf_yafray
bf_IK
bf_memutil
bf_guardedalloc
@@ -264,10 +262,7 @@ IF(UNIX)
bf_ngnetwork
extern_bullet
bf_loopbacknetwork
- bf_sumo
bf_common
- extern_solid
- extern_qhull
bf_moto
bf_python
bf_gen_python
diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile
index f5486bae87b..549e466c4e0 100644
--- a/source/gameengine/BlenderRoutines/Makefile
+++ b/source/gameengine/BlenderRoutines/Makefile
@@ -36,8 +36,6 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_GLEW)/include
-CPPFLAGS += -I$(NAN_SUMO)/include -I$(NAN_SOLID)/include
-CPPFLAGS += -I$(NAN_SOLID)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include
@@ -67,7 +65,6 @@ CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I../Network
CPPFLAGS += -I../Network/LoopBackNetwork
CPPFLAGS += -I../Physics/common
-CPPFLAGS += -I../Physics/Sumo
CPPFLAGS += -I.
ifeq ($(OS),windows)
diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript
index a0cc3af3611..c2094a15825 100644
--- a/source/gameengine/BlenderRoutines/SConscript
+++ b/source/gameengine/BlenderRoutines/SConscript
@@ -20,11 +20,6 @@ incs += ' #intern/SoundSystem #source/blender/misc #source/blender/blenloader'
incs += ' #extern/glew/include #source/blender/gpu'
incs += ' #source/blender/windowmanager'
-if env['WITH_BF_SOLID']:
- incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/Fuzzics/include'
- incs += ' ' + env['BF_SOLID_INC']
- defs.append('USE_SUMO_SOLID')
-
if env['WITH_BF_FFMPEG']:
defs.append('WITH_FFMPEG')
diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt
index fd05858710d..f546a31fb2e 100644
--- a/source/gameengine/CMakeLists.txt
+++ b/source/gameengine/CMakeLists.txt
@@ -38,7 +38,6 @@ ADD_SUBDIRECTORY(Rasterizer)
ADD_SUBDIRECTORY(Rasterizer/RAS_OpenGLRasterizer)
ADD_SUBDIRECTORY(SceneGraph)
ADD_SUBDIRECTORY(Physics/Bullet)
-ADD_SUBDIRECTORY(Physics/Sumo)
ADD_SUBDIRECTORY(VideoTexture)
IF(WITH_PLAYER)
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index b907e300879..177f261e40b 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -163,7 +163,6 @@ extern "C" {
#include "SG_BBox.h"
#include "SG_Tree.h"
-// defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h"
#ifdef USE_BULLET
#include "CcdPhysicsEnvironment.h"
@@ -1610,18 +1609,6 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
break;
#endif
-#ifdef USE_SUMO_SOLID
- case UseSumo:
- KX_ConvertSumoObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop);
- break;
-#endif
-
-#ifdef USE_ODE
- case UseODE:
- KX_ConvertODEEngineObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop);
- break;
-#endif //USE_ODE
-
case UseDynamo:
//KX_ConvertDynamoObject(gameobj,meshobj,kxscene,shapeprops, smmaterial, &objprop);
break;
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 86e20b88580..9e0a710f44f 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -44,21 +44,12 @@
#include "DummyPhysicsEnvironment.h"
-//to decide to use sumo/ode or dummy physics - defines USE_ODE
#include "KX_ConvertPhysicsObject.h"
#ifdef USE_BULLET
#include "CcdPhysicsEnvironment.h"
#endif
-#ifdef USE_ODE
-#include "OdePhysicsEnvironment.h"
-#endif //USE_ODE
-
-#ifdef USE_SUMO_SOLID
-#include "SumoPhysicsEnvironment.h"
-#endif
-
#include "KX_BlenderSceneConverter.h"
#include "KX_BlenderScalarInterpolator.h"
#include "BL_BlenderDataConversion.h"
@@ -145,10 +136,6 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter()
delete (*itm).second;
itm++;
}
-
-#ifdef USE_SUMO_SOLID
- KX_ClearSumoSharedShapes();
-#endif
#ifdef USE_BULLET
KX_ClearBulletSharedShapes();
@@ -331,20 +318,7 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
destinationscene->SetPhysicsEnvironment(ccdPhysEnv);
break;
}
-#endif
-
-#ifdef USE_SUMO_SOLID
- case UseSumo:
- destinationscene ->SetPhysicsEnvironment(new SumoPhysicsEnvironment());
- break;
-#endif
-#ifdef USE_ODE
-
- case UseODE:
- destinationscene ->SetPhysicsEnvironment(new ODEPhysicsEnvironment());
- break;
-#endif //USE_ODE
-
+#endif
case UseDynamo:
{
}
diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile
index abded70f289..ed95aa968c7 100644
--- a/source/gameengine/Converter/Makefile
+++ b/source/gameengine/Converter/Makefile
@@ -39,8 +39,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_BULLET2)/include
CPPFLAGS += -I../../blender
diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript
index 3e0929e605a..05ea01c902a 100644
--- a/source/gameengine/Converter/SConscript
+++ b/source/gameengine/Converter/SConscript
@@ -21,11 +21,6 @@ incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu'
incs += ' #source/blender/windowmanager'
incs += ' #source/blender/makesrna'
-if env['WITH_BF_SOLID']:
- incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/Fuzzics/include'
- incs += ' ' + env['BF_SOLID_INC']
- defs.append('USE_SUMO_SOLID')
-
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_BULLET_INC']
diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt
index e3942b46557..dffd13f64ff 100644
--- a/source/gameengine/Expressions/CMakeLists.txt
+++ b/source/gameengine/Expressions/CMakeLists.txt
@@ -32,6 +32,7 @@ SET(INC
../../../intern/string
../../../intern/moto/include
../../../source/gameengine/SceneGraph
+ ../../../source/blender/blenloader
${PYTHON_INC}
)
diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile
index 84b4a4170a9..4a952856739 100644
--- a/source/gameengine/GamePlayer/common/Makefile
+++ b/source/gameengine/GamePlayer/common/Makefile
@@ -50,8 +50,6 @@ CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_SUMO)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_PNG)/include
CPPFLAGS += -I$(NAN_ZLIB)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
@@ -69,7 +67,6 @@ CPPFLAGS += -I../../../gameengine/Network/LoopBackNetwork
CPPFLAGS += -I../../../gameengine/Rasterizer
CPPFLAGS += -I../../../gameengine/SceneGraph
CPPFLAGS += -I../../../gameengine/Rasterizer/RAS_OpenGLRasterizer
-CPPFLAGS += -I../../../gameengine/Physics/Sumo
CPPFLAGS += -I../../../gameengine/Physics/common
###############################
diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript
index e96b2c5400b..f899385c841 100644
--- a/source/gameengine/GamePlayer/common/SConscript
+++ b/source/gameengine/GamePlayer/common/SConscript
@@ -59,11 +59,6 @@ incs = ['.',
# 'unix/GPU_System.cpp']
# gp_common_env.Append ( CPPPATH = ['unix'])
-if env['WITH_BF_SOLID']:
- incs.append('#source/gameengine/Physics/Sumo')
- incs.append('#source/gameengine/Physics/Sumo/Fuzzics/include')
- incs += Split(env['BF_SOLID_INC'])
-
incs += Split(env['BF_PYTHON_INC'])
incs += Split(env['BF_PNG_INC'])
incs += Split(env['BF_ZLIB_INC'])
diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp
index a5dec02c753..0ef087efbfe 100644
--- a/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp
+++ b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp
@@ -44,9 +44,6 @@
#include "NG_LoopBackNetworkDeviceInterface.h"
#include "SND_DeviceManager.h"
#include "KX_BlenderSceneConverter.h"
-#ifdef USE_SUMO_SOLID
- #include "SM_Scene.h"
-#endif
#include "KX_KetsjiEngine.h"
#include "GPC_RenderTools.h"
diff --git a/source/gameengine/GamePlayer/common/unix/Makefile b/source/gameengine/GamePlayer/common/unix/Makefile
index 90342c7b735..08c52ddc904 100644
--- a/source/gameengine/GamePlayer/common/unix/Makefile
+++ b/source/gameengine/GamePlayer/common/unix/Makefile
@@ -57,10 +57,8 @@ CPPFLAGS += -I../../../../gameengine/Rasterizer/RAS_OpenGLRasterizer
CPPFLAGS += -I../../../../gameengine/SceneGraph
CPPFLAGS += -I$(NAN_FUZZICS)/include
-CPPFLAGS += -I$(NAN_SUMO)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
# Blender stuff
CPPFLAGS += -I../../../../blender/blenkernel
diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript
index 390b6f5e089..19234cb663c 100644
--- a/source/gameengine/GamePlayer/ghost/SConscript
+++ b/source/gameengine/GamePlayer/ghost/SConscript
@@ -41,10 +41,6 @@ incs = ['.',
'#source/blender/gpu',
'#extern/glew/include']
-if env['WITH_BF_SOLID']:
- incs.append(['#source/gameengine/Physics/Sumo', '#source/gameengine/Physics/Sumo/Fuzzics/include'])
- incs += Split(env['BF_SOLID_INC'])
-
incs += Split(env['BF_PYTHON_INC'])
cxxflags = []
diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
index 077ac96f0ac..1898dc71ef8 100644
--- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h
+++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h
@@ -30,9 +30,6 @@
#define __KX_CLIENTOBJECT_INFO_H
/* Note, the way this works with/without sumo is a bit odd */
-#ifdef USE_SUMO_SOLID
-#include <SM_Object.h>
-#endif //USE_SUMO_SOLID
#include <list>
@@ -42,9 +39,6 @@ class KX_GameObject;
* Client Type and Additional Info. This structure can be use instead of a bare void* pointer, for safeness, and additional info for callbacks
*/
struct KX_ClientObjectInfo
-#ifdef USE_SUMO_SOLID
- : public SM_ClientObject
-#endif
{
enum clienttype {
STATIC,
@@ -59,18 +53,12 @@ struct KX_ClientObjectInfo
std::list<SCA_ISensor*> m_sensors;
public:
KX_ClientObjectInfo(KX_GameObject *gameobject, clienttype type = STATIC, void *auxilary_info = NULL) :
-#ifdef USE_SUMO_SOLID
- SM_ClientObject(),
-#endif
m_type(type),
m_gameobject(gameobject),
m_auxilary_info(auxilary_info)
{}
KX_ClientObjectInfo(const KX_ClientObjectInfo &copy) :
-#ifdef USE_SUMO_SOLID
- SM_ClientObject(copy),
-#endif
m_type(copy.m_type),
m_gameobject(copy.m_gameobject),
m_auxilary_info(copy.m_auxilary_info)
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
index 74042366bae..9d3b9cdaf74 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
@@ -32,11 +32,8 @@
/* These are defined by the build system... */
//but the build system is broken, because it doesn't allow for 2 or more defines at once.
//Please leave Sumo _AND_ Bullet enabled
-//#define USE_SUMO_SOLID // scons defines this
#define USE_BULLET
-//#define USE_ODE
-
//on visual studio 7/8, always enable BULLET for now
//you can have multiple physics engines running anyway, and
//the scons build system doesn't really support this at the moment.
@@ -148,20 +145,6 @@ struct KX_ObjectProperties
} m_boundobject;
};
-#ifdef USE_ODE
-
-
-void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop);
-
-
-#endif //USE_ODE
-
-
void KX_ConvertDynamoObject(KX_GameObject* gameobj,
RAS_MeshObject* meshobj,
KX_Scene* kxscene,
@@ -169,19 +152,6 @@ void KX_ConvertDynamoObject(KX_GameObject* gameobj,
struct PHY_MaterialProps* smmaterial,
struct KX_ObjectProperties* objprop);
-#ifdef USE_SUMO_SOLID
-
-void KX_ConvertSumoObject( class KX_GameObject* gameobj,
- class RAS_MeshObject* meshobj,
- class KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop);
-
-void KX_ClearSumoSharedShapes();
-bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj);
-
-#endif
#ifdef USE_BULLET
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 51c41c0686d..64b5760de28 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -32,7 +32,6 @@
#include "MT_assert.h"
-// defines USE_ODE to choose physics engine
#include "KX_ConvertPhysicsObject.h"
#include "BL_DeformableGameObject.h"
#include "RAS_MeshObject.h"
@@ -56,597 +55,6 @@ extern "C"{
#include "BKE_DerivedMesh.h"
}
-#ifdef USE_ODE
-
-#include "KX_OdePhysicsController.h"
-#include "OdePhysicsEnvironment.h"
-#endif //USE_ODE
-
-
-// USE_SUMO_SOLID is defined in headerfile KX_ConvertPhysicsObject.h
-#ifdef USE_SUMO_SOLID
-
-
-#include "SumoPhysicsEnvironment.h"
-#include "KX_SumoPhysicsController.h"
-
-
-// sumo physics specific
-#include "SM_Object.h"
-#include "SM_FhObject.h"
-#include "SM_Scene.h"
-#include "SM_ClientObjectInfo.h"
-
-#include "KX_SumoPhysicsController.h"
-
-struct KX_PhysicsInstance
-{
- DT_VertexBaseHandle m_vertexbase;
- RAS_DisplayArray* m_darray;
- RAS_IPolyMaterial* m_material;
-
- KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, RAS_DisplayArray *darray, RAS_IPolyMaterial* mat)
- : m_vertexbase(vertex_base),
- m_darray(darray),
- m_material(mat)
- {
- }
-
- ~KX_PhysicsInstance()
- {
- DT_DeleteVertexBase(m_vertexbase);
- }
-};
-
-static GEN_Map<GEN_HashedPtr,DT_ShapeHandle> map_gamemesh_to_sumoshape;
-static GEN_Map<GEN_HashedPtr, KX_PhysicsInstance*> map_gamemesh_to_instance;
-
-// forward declarations
-static void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,class SM_Object* sumoObj,const STR_String& matname,bool isDynamic,bool isActor);
-static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope);
-
-void KX_ConvertSumoObject( KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- PHY_ShapeProps* kxshapeprops,
- PHY_MaterialProps* kxmaterial,
- struct KX_ObjectProperties* objprop)
-
-
-{
- SM_ShapeProps* smprop = new SM_ShapeProps;
-
- smprop->m_ang_drag = kxshapeprops->m_ang_drag;
- smprop->m_do_anisotropic = kxshapeprops->m_do_anisotropic;
- smprop->m_do_fh = kxshapeprops->m_do_fh;
- smprop->m_do_rot_fh = kxshapeprops->m_do_rot_fh ;
- smprop->m_friction_scaling[0] = kxshapeprops->m_friction_scaling[0];
- smprop->m_friction_scaling[1] = kxshapeprops->m_friction_scaling[1];
- smprop->m_friction_scaling[2] = kxshapeprops->m_friction_scaling[2];
- smprop->m_inertia = MT_Vector3(1., 1., 1.) * kxshapeprops->m_inertia;
- smprop->m_lin_drag = kxshapeprops->m_lin_drag;
- smprop->m_mass = kxshapeprops->m_mass;
- smprop->m_radius = objprop->m_radius;
-
-
- SM_MaterialProps* smmaterial = new SM_MaterialProps;
-
- smmaterial->m_fh_damping = kxmaterial->m_fh_damping;
- smmaterial->m_fh_distance = kxmaterial->m_fh_distance;
- smmaterial->m_fh_normal = kxmaterial->m_fh_normal;
- smmaterial->m_fh_spring = kxmaterial->m_fh_spring;
- smmaterial->m_friction = kxmaterial->m_friction;
- smmaterial->m_restitution = kxmaterial->m_restitution;
-
- SumoPhysicsEnvironment* sumoEnv =
- (SumoPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
-
- SM_Scene* sceneptr = sumoEnv->GetSumoScene();
-
- SM_Object* sumoObj=NULL;
-
- if (objprop->m_dyna && objprop->m_isactor)
- {
- DT_ShapeHandle shape = NULL;
- bool polytope = false;
- switch (objprop->m_boundclass)
- {
- case KX_BOUNDBOX:
- shape = DT_NewBox(objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]);
- smprop->m_inertia.scale(objprop->m_boundobject.box.m_extends[0]*objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1]*objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]*objprop->m_boundobject.box.m_extends[2]);
- smprop->m_inertia *= smprop->m_mass/MT_Vector3(objprop->m_boundobject.box.m_extends).length();
- break;
- case KX_BOUNDCYLINDER:
- shape = DT_NewCylinder(smprop->m_radius, objprop->m_boundobject.c.m_height);
- smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
- break;
- case KX_BOUNDCONE:
- shape = DT_NewCone(objprop->m_radius, objprop->m_boundobject.c.m_height);
- smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
- break;
- /* Dynamic mesh objects. WARNING! slow. */
- case KX_BOUNDPOLYTOPE:
- polytope = true;
- // fall through
- case KX_BOUNDMESH:
- if (meshobj && meshobj->NumPolygons() > 0)
- {
- if ((shape = CreateShapeFromMesh(meshobj, polytope)))
- {
- // TODO: calculate proper inertia
- smprop->m_inertia *= smprop->m_mass*smprop->m_radius*smprop->m_radius;
- break;
- }
- }
- /* If CreateShapeFromMesh fails, fall through and use sphere */
- default:
- case KX_BOUNDSPHERE:
- shape = DT_NewSphere(objprop->m_radius);
- smprop->m_inertia *= smprop->m_mass*smprop->m_radius*smprop->m_radius;
- break;
-
- }
-
- sumoObj = new SM_Object(shape, !objprop->m_ghost?smmaterial:NULL,smprop,NULL);
-
- sumoObj->setRigidBody(objprop->m_angular_rigidbody?true:false);
-
- BL_RegisterSumoObject(gameobj,sceneptr,sumoObj,"",true, true);
-
- }
- else {
- // non physics object
- if (meshobj)
- {
- int numpolys = meshobj->NumPolygons();
- {
-
- DT_ShapeHandle complexshape=0;
- bool polytope = false;
-
- switch (objprop->m_boundclass)
- {
- case KX_BOUNDBOX:
- complexshape = DT_NewBox(objprop->m_boundobject.box.m_extends[0], objprop->m_boundobject.box.m_extends[1], objprop->m_boundobject.box.m_extends[2]);
- break;
- case KX_BOUNDSPHERE:
- complexshape = DT_NewSphere(objprop->m_boundobject.c.m_radius);
- break;
- case KX_BOUNDCYLINDER:
- complexshape = DT_NewCylinder(objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height);
- break;
- case KX_BOUNDCONE:
- complexshape = DT_NewCone(objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height);
- break;
- case KX_BOUNDPOLYTOPE:
- polytope = true;
- // fall through
- default:
- case KX_BOUNDMESH:
- if (numpolys>0)
- {
- complexshape = CreateShapeFromMesh(meshobj, polytope);
- //std::cout << "Convert Physics Mesh: " << meshobj->GetName() << std::endl;
-/* if (!complexshape)
- {
- // Something has to be done here - if the object has no polygons, it will not be able to have
- // sensors attached to it.
- DT_Vector3 pt = {0., 0., 0.};
- complexshape = DT_NewSphere(1.0);
- objprop->m_ghost = evilObject = true;
- } */
- }
- break;
- }
-
- if (complexshape)
- {
- SM_Object *dynamicParent = NULL;
-
- if (objprop->m_dynamic_parent)
- {
- // problem is how to find the dynamic parent
- // in the scenegraph
- KX_SumoPhysicsController* sumoctrl =
- (KX_SumoPhysicsController*)
- objprop->m_dynamic_parent->GetPhysicsController();
-
- if (sumoctrl)
- {
- dynamicParent = sumoctrl->GetSumoObject();
- }
-
- MT_assert(dynamicParent);
- }
-
-
- sumoObj = new SM_Object(complexshape,!objprop->m_ghost?smmaterial:NULL,NULL, dynamicParent);
- const STR_String& matname=meshobj->GetMaterialName(0);
-
-
- BL_RegisterSumoObject(gameobj,sceneptr,
- sumoObj,
- matname,
- objprop->m_dyna,
- objprop->m_isactor);
- }
- }
- }
- }
-
- // physics object get updated here !
-
-
- // lazy evaluation because we might not support scaling !gameobj->UpdateTransform();
-
- if (objprop->m_in_active_layer && sumoObj)
- {
- sceneptr->add(*sumoObj);
- }
-
-}
-
-
-
-static void BL_RegisterSumoObject(
- KX_GameObject* gameobj,
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- const STR_String& matname,
- bool isDynamic,
- bool isActor)
-{
- PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
-
- // need easy access, not via 'node' etc.
- KX_SumoPhysicsController* physicscontroller = new KX_SumoPhysicsController(sumoScene,sumoObj,motionstate,isDynamic);
- gameobj->SetPhysicsController(physicscontroller,isDynamic);
-
-
- if (!gameobj->getClientInfo())
- std::cout << "BL_RegisterSumoObject: WARNING: Object " << gameobj->GetName() << " has no client info" << std::endl;
- physicscontroller->setNewClientInfo(gameobj->getClientInfo());
-
-
- gameobj->GetSGNode()->AddSGController(physicscontroller);
-
- gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC);
-
- // store materialname in auxinfo, needed for touchsensors
- gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL);
-
- physicscontroller->SetObject(gameobj->GetSGNode());
-}
-
-static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat)
-{
- // instance a mesh from a single vertex array & material
- const RAS_TexVert *vertex_array = &darray->m_vertex[0];
- DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert));
-
- DT_ShapeHandle shape = DT_NewComplexShape(vertex_base);
-
- std::vector<DT_Index> indices;
- for (int p = 0; p < meshobj->NumPolygons(); p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- DT_Begin();
- DT_VertexIndex(poly->GetVertexOffset(0));
- DT_VertexIndex(poly->GetVertexOffset(1));
- DT_VertexIndex(poly->GetVertexOffset(2));
- DT_End();
-
- // tesselate
- if (poly->VertexCount() == 4)
- {
- DT_Begin();
- DT_VertexIndex(poly->GetVertexOffset(0));
- DT_VertexIndex(poly->GetVertexOffset(2));
- DT_VertexIndex(poly->GetVertexOffset(3));
- DT_End();
- }
- }
- }
-
- //DT_VertexIndices(indices.size(), &indices[0]);
- DT_EndComplexShape();
-
- map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat));
- return shape;
-}
-
-static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat)
-{
- // instance a mesh from a single vertex array & material
- const RAS_TexVert *vertex_array = &darray->m_vertex[0];
- DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert));
-
- std::vector<DT_Index> indices;
- for (int p = 0; p < meshobj->NumPolygons(); p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- indices.push_back(poly->GetVertexOffset(0));
- indices.push_back(poly->GetVertexOffset(1));
- indices.push_back(poly->GetVertexOffset(2));
-
- if (poly->VertexCount() == 4)
- indices.push_back(poly->GetVertexOffset(3));
- }
- }
-
- DT_ShapeHandle shape = DT_NewPolytope(vertex_base);
- DT_VertexIndices(indices.size(), &indices[0]);
- DT_EndPolytope();
-
- map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat));
- return shape;
-}
-
-// This will have to be a method in a class somewhere...
-// Update SOLID with a changed physics mesh.
-// not used... yet.
-bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj)
-{
- KX_PhysicsInstance *instance = *map_gamemesh_to_instance[GEN_HashedPtr(meshobj)];
- if (instance)
- {
- const RAS_TexVert *vertex_array = &instance->m_darray->m_vertex[0];
- DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getXYZ());
- return true;
- }
- return false;
-}
-
-static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope)
-{
-
- DT_ShapeHandle *shapeptr = map_gamemesh_to_sumoshape[GEN_HashedPtr(meshobj)];
- // Mesh has already been converted: reuse
- if (shapeptr)
- {
- return *shapeptr;
- }
-
- // Mesh has no polygons!
- int numpolys = meshobj->NumPolygons();
- if (!numpolys)
- {
- return NULL;
- }
-
- // Count the number of collision polygons and check they all come from the same
- // vertex array
- int numvalidpolys = 0;
- RAS_DisplayArray *darray = NULL;
- RAS_IPolyMaterial *poly_material = NULL;
- bool reinstance = true;
-
- for (int p=0; p<numpolys; p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- // check polygon is from the same vertex array
- if (poly->GetDisplayArray() != darray)
- {
- if (darray == NULL)
- darray = poly->GetDisplayArray();
- else
- {
- reinstance = false;
- darray = NULL;
- }
- }
-
- // check poly is from the same material
- if (poly->GetMaterial()->GetPolyMaterial() != poly_material)
- {
- if (poly_material)
- {
- reinstance = false;
- poly_material = NULL;
- }
- else
- poly_material = poly->GetMaterial()->GetPolyMaterial();
- }
-
- // count the number of collision polys
- numvalidpolys++;
-
- // We have one collision poly, and we can't reinstance, so we
- // might as well break here.
- if (!reinstance)
- break;
- }
- }
-
- // No collision polygons
- if (numvalidpolys < 1)
- return NULL;
-
- DT_ShapeHandle shape;
- if (reinstance)
- {
- if (polytope)
- shape = InstancePhysicsPolytope(meshobj, darray, poly_material);
- else
- shape = InstancePhysicsComplex(meshobj, darray, poly_material);
- }
- else
- {
- if (polytope)
- {
- std::cout << "CreateShapeFromMesh: " << meshobj->GetName() << " is not suitable for polytope." << std::endl;
- if (!poly_material)
- std::cout << " Check mesh materials." << std::endl;
- if (darray == NULL)
- std::cout << " Check number of vertices." << std::endl;
- }
-
- shape = DT_NewComplexShape(NULL);
-
- numvalidpolys = 0;
-
- for (int p2=0; p2<numpolys; p2++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p2);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- { /* We have to tesselate here because SOLID can only raycast triangles */
- DT_Begin();
- /* V1, V2, V3 */
- DT_Vertex(poly->GetVertex(2)->getXYZ());
- DT_Vertex(poly->GetVertex(1)->getXYZ());
- DT_Vertex(poly->GetVertex(0)->getXYZ());
-
- numvalidpolys++;
- DT_End();
-
- if (poly->VertexCount() == 4)
- {
- DT_Begin();
- /* V1, V3, V4 */
- DT_Vertex(poly->GetVertex(3)->getXYZ());
- DT_Vertex(poly->GetVertex(2)->getXYZ());
- DT_Vertex(poly->GetVertex(0)->getXYZ());
-
- numvalidpolys++;
- DT_End();
- }
-
- }
- }
-
- DT_EndComplexShape();
- }
-
- if (numvalidpolys > 0)
- {
- map_gamemesh_to_sumoshape.insert(GEN_HashedPtr(meshobj),shape);
- return shape;
- }
-
- delete shape;
- return NULL;
-}
-
-void KX_ClearSumoSharedShapes()
-{
- int numshapes = map_gamemesh_to_sumoshape.size();
- int i;
- for (i=0;i<numshapes ;i++)
- {
- DT_ShapeHandle shape = *map_gamemesh_to_sumoshape.at(i);
- DT_DeleteShape(shape);
- }
-
- map_gamemesh_to_sumoshape.clear();
-
- for (i=0; i < map_gamemesh_to_instance.size(); i++)
- delete *map_gamemesh_to_instance.at(i);
-
- map_gamemesh_to_instance.clear();
-}
-
-
-
-
-
-#endif //USE_SUMO_SOLID
-
-
-#ifdef USE_ODE
-
-void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- struct PHY_ShapeProps* shapeprops,
- struct PHY_MaterialProps* smmaterial,
- struct KX_ObjectProperties* objprop)
-{
-
- // not yet, future extension :)
- bool dyna=objprop->m_dyna;
- bool fullRigidBody= ( objprop->m_dyna && objprop->m_angular_rigidbody) != 0;
- bool phantom = objprop->m_ghost;
- class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
-
- class ODEPhysicsEnvironment* odeEnv =
- (ODEPhysicsEnvironment*)kxscene->GetPhysicsEnvironment();
-
- dxSpace* space = odeEnv->GetOdeSpace();
- dxWorld* world = odeEnv->GetOdeWorld();
-
- bool isSphere = false;
-
- switch (objprop->m_boundclass)
- {
- case KX_BOUNDBOX:
- {
-
- KX_OdePhysicsController* physicscontroller =
- new KX_OdePhysicsController(
- dyna,
- fullRigidBody,
- phantom,
- motionstate,
- space,
- world,
- shapeprops->m_mass,
- smmaterial->m_friction,
- smmaterial->m_restitution,
- isSphere,
- objprop->m_boundobject.box.m_center,
- objprop->m_boundobject.box.m_extends,
- objprop->m_boundobject.c.m_radius
- );
-
- gameobj->SetPhysicsController(physicscontroller);
- physicscontroller->setNewClientInfo(gameobj->getClientInfo());
- gameobj->GetSGNode()->AddSGController(physicscontroller);
-
- bool isActor = objprop->m_isactor;
- STR_String materialname;
- if (meshobj)
- materialname = meshobj->GetMaterialName(0);
-
- const char* matname = materialname.ReadPtr();
-
-
- physicscontroller->SetObject(gameobj->GetSGNode());
-
- break;
- }
- default:
- {
- }
- };
-
-}
-
-
-#endif // USE_ODE
-
-
#ifdef USE_BULLET
#include "CcdPhysicsEnvironment.h"
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index a43ea59220b..1a417110c08 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -61,10 +61,6 @@
#include "KX_PyConstraintBinding.h"
#include "PHY_IPhysicsEnvironment.h"
-#ifdef USE_SUMO_SOLID
-#include "SumoPhysicsEnvironment.h"
-#endif
-
#include "SND_Scene.h"
#include "SND_IAudioDevice.h"
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
deleted file mode 100644
index dc6990267d4..00000000000
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include "KX_ConvertPhysicsObject.h"
-
-#ifdef USE_ODE
-
-#include "KX_OdePhysicsController.h"
-#include "KX_GameObject.h"
-#include "KX_MotionState.h"
-
-#include "MT_assert.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-KX_OdePhysicsController::KX_OdePhysicsController(
- bool dyna,
- bool fullRigidBody,
- bool phantom,
- class PHY_IMotionState* motionstate,
- struct dxSpace* space,
- struct dxWorld* world,
- float mass,
- float friction,
- float restitution,
- bool implicitsphere,
- float center[3],
- float extends[3],
- float radius
- )
-: KX_IPhysicsController(dyna,false,(PHY_IPhysicsController*)this),
-ODEPhysicsController(
-dyna,fullRigidBody,phantom,motionstate,
-space,world,mass,friction,restitution,
-implicitsphere,center,extends,radius)
-{
-};
-
-
-bool KX_OdePhysicsController::Update(double time)
-{
- return SynchronizeMotionStates(time);
-}
-
-void KX_OdePhysicsController::SetObject (SG_IObject* object)
-{
- SG_Controller::SetObject(object);
-
- // cheating here...
- KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
- gameobj->SetPhysicsController(this);
-
-}
-
-
-
-void KX_OdePhysicsController::applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)
-{
- ODEPhysicsController::applyImpulse(attach[0],attach[1],attach[2],impulse[0],impulse[1],impulse[2]);
-}
-
-
-
-void KX_OdePhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local)
-{
- ODEPhysicsController::RelativeTranslate(dloc[0],dloc[1],dloc[2],local);
-
-}
-void KX_OdePhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool local)
-{
- double oldmat[12];
- drot.getValue(oldmat);
- float newmat[9];
- float *m = &newmat[0];
- double *orgm = &oldmat[0];
-
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
-
- ODEPhysicsController::RelativeRotate(newmat,local);
-
-}
-
-void KX_OdePhysicsController::ApplyTorque(const MT_Vector3& torque,bool local)
-{
- ODEPhysicsController::ApplyTorque(torque[0],torque[1],torque[2],local);
-
-}
-void KX_OdePhysicsController::ApplyForce(const MT_Vector3& force,bool local)
-{
- ODEPhysicsController::ApplyForce(force[0],force[1],force[2],local);
-
-}
-MT_Vector3 KX_OdePhysicsController::GetLinearVelocity()
-{
- return MT_Vector3(0,0,0);
-}
-
-MT_Vector3 KX_OdePhysicsController::GetVelocity(const MT_Point3& pos)
-{
- return MT_Vector3(0,0,0);
-}
-
-void KX_OdePhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
-
-}
-void KX_OdePhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- ODEPhysicsController::SetLinearVelocity(lin_vel[0],lin_vel[1],lin_vel[2],local);
-}
-
-void KX_OdePhysicsController::setOrientation(const MT_Matrix3x3& rot)
-{
- MT_Quaternion orn = rot.getRotation();
- ODEPhysicsController::setOrientation(orn[0],orn[1],orn[2],orn[3]);
-}
-
-void KX_OdePhysicsController::getOrientation(MT_Quaternion& orn)
-{
- float florn[4];
- florn[0]=orn[0];
- florn[1]=orn[1];
- florn[2]=orn[2];
- florn[3]=orn[3];
- ODEPhysicsController::getOrientation(florn[0],florn[1],florn[2],florn[3]);
- orn[0] = florn[0];
- orn[1] = florn[1];
- orn[2] = florn[2];
- orn[3] = florn[3];
-
-
-}
-
-void KX_OdePhysicsController::setPosition(const MT_Point3& pos)
-{
- ODEPhysicsController::setPosition(pos[0],pos[1],pos[2]);
-}
-
-void KX_OdePhysicsController::setScaling(const MT_Vector3& scaling)
-{
-}
-
-MT_Scalar KX_OdePhysicsController::GetMass()
-{
- return ODEPhysicsController::getMass();
-}
-
-MT_Scalar KX_OdePhysicsController::GetRadius()
-{
- return MT_Scalar(0.f);
-}
-
-MT_Vector3 KX_OdePhysicsController::getReactionForce()
-{
- return MT_Vector3(0,0,0);
-}
-void KX_OdePhysicsController::setRigidBody(bool rigid)
-{
-
-}
-
-void KX_OdePhysicsController::SuspendDynamics(bool)
-{
- ODEPhysicsController::SuspendDynamics();
-}
-void KX_OdePhysicsController::RestoreDynamics()
-{
- ODEPhysicsController::RestoreDynamics();
-}
-
-
-SG_Controller* KX_OdePhysicsController::GetReplica(class SG_Node* destnode)
-{
- PHY_IMotionState* motionstate = new KX_MotionState(destnode);
- KX_OdePhysicsController* copyctrl = new KX_OdePhysicsController(*this);
-
- // nlin: copied from KX_SumoPhysicsController.cpp. Not 100% sure what this does....
- // furthermore, the parentctrl is not used in ODEPhysicsController::PostProcessReplica, but
- // maybe it can/should be used in the future...
-
- // begin copy block ------------------------------------------------------------------
-
- //parentcontroller is here be able to avoid collisions between parent/child
-
- PHY_IPhysicsController* parentctrl = NULL;
-
- if (destnode != destnode->GetRootSGParent())
- {
- KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject();
- if (clientgameobj)
- {
- parentctrl = (KX_OdePhysicsController*)clientgameobj->GetPhysicsController();
- } else
- {
- // it could be a false node, try the children
- NodeList::const_iterator childit;
- for (
- childit = destnode->GetSGChildren().begin();
- childit!= destnode->GetSGChildren().end();
- ++childit
- ) {
- KX_GameObject* clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj)
- {
- parentctrl = (KX_OdePhysicsController*)clientgameobj->GetPhysicsController();
- }
- }
- }
- }
- // end copy block ------------------------------------------------------------------
-
- copyctrl->PostProcessReplica(motionstate, this);
-
- return copyctrl;
-
-}
-
-void KX_OdePhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
-}
-
-
-void KX_OdePhysicsController::SetSumoTransform(bool nondynaonly)
-{
-
-}
- // todo: remove next line !
-void KX_OdePhysicsController::SetSimulatedTime(double time)
-{
-
-}
-
-#endif //USE_ODE
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h
deleted file mode 100644
index 8c3974c38a3..00000000000
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __KX_ODEPHYSICSCONTROLLER_H
-#define __KX_ODEPHYSICSCONTROLLER_H
-
-#include "KX_IPhysicsController.h"
-#include "OdePhysicsController.h"
-
-/**
- Physics Controller, a special kind of Scene Graph Transformation Controller.
- It get's callbacks from Physics in case a transformation change took place.
- Each time the scene graph get's updated, the controller get's a chance
- in the 'Update' method to reflect changed.
-*/
-
-class KX_OdePhysicsController : public KX_IPhysicsController, public ODEPhysicsController
-
-{
-
-public:
- KX_OdePhysicsController(
- bool dyna,
- bool fullRigidBody,
- bool phantom,
- class PHY_IMotionState* motionstate,
- struct dxSpace* space,
- struct dxWorld* world,
- float mass,
- float friction,
- float restitution,
- bool implicitsphere,
- float center[3],
- float extends[3],
- float radius);
-
- virtual ~KX_OdePhysicsController() {};
-
- virtual void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
- virtual void SetObject (SG_IObject* object);
-
- virtual void RelativeTranslate(const MT_Vector3& dloc,bool local);
- virtual void RelativeRotate(const MT_Matrix3x3& drot,bool local);
- virtual void ApplyTorque(const MT_Vector3& torque,bool local);
- virtual void ApplyForce(const MT_Vector3& force,bool local);
- virtual MT_Vector3 GetLinearVelocity();
- virtual MT_Vector3 GetVelocity(const MT_Point3& pos);
- virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
- virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
- virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Matrix3x3& orn);
- virtual void setPosition(const MT_Point3& pos);
- virtual void setScaling(const MT_Vector3& scaling);
- virtual void SetTransform() {}
- virtual MT_Scalar GetMass();
- virtual MT_Vector3 getReactionForce();
- virtual void setRigidBody(bool rigid);
- virtual void AddCompoundChild(KX_IPhysicsController* child) { }
- virtual void RemoveCompoundChild(KX_IPhysicsController* child) { }
-
- virtual void SuspendDynamics(bool);
- virtual void RestoreDynamics();
- virtual MT_Scalar GetRadius();
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
-
- virtual float GetLinVelocityMin() { return ODEPhysicsController::GetLinVelocityMin(); }
- virtual void SetLinVelocityMin(float val) { ODEPhysicsController::SetLinVelocityMin(val); }
- virtual float GetLinVelocityMax() { return ODEPhysicsController::GetLinVelocityMax(); }
- virtual void SetLinVelocityMax(float val) { ODEPhysicsController::SetLinVelocityMax(val); }
-
- virtual void SetSumoTransform(bool nondynaonly);
- // todo: remove next line !
- virtual void SetSimulatedTime(double time);
-
- // call from scene graph to update
- virtual bool Update(double time);
-
- void
- SetOption(
- int option,
- int value
- ){
- // intentionally empty
- };
-
-};
-
-#endif //__KX_ODEPHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
deleted file mode 100644
index fc053f05e63..00000000000
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-#include "KX_ConvertPhysicsObject.h"
-
-#ifdef USE_SUMO_SOLID
-
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#endif
-
-#include "KX_SumoPhysicsController.h"
-#include "SG_Spatial.h"
-#include "SM_Scene.h"
-#include "KX_GameObject.h"
-#include "KX_MotionState.h"
-#include "KX_ClientObjectInfo.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-void KX_SumoPhysicsController::applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse)
-{
- SumoPhysicsController::applyImpulse(attach[0],attach[1],attach[2],impulse[0],impulse[1],impulse[2]);
-}
-void KX_SumoPhysicsController::RelativeTranslate(const MT_Vector3& dloc,bool local)
-{
- SumoPhysicsController::RelativeTranslate(dloc[0],dloc[1],dloc[2],local);
-
-}
-void KX_SumoPhysicsController::RelativeRotate(const MT_Matrix3x3& drot,bool local)
-{
- float oldmat[12];
- drot.getValue(oldmat);
-/* float newmat[9];
- float *m = &newmat[0];
- double *orgm = &oldmat[0];
-
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++;
- *m++ = *orgm++;*m++ = *orgm++;*m++ = *orgm++;orgm++; */
-
- SumoPhysicsController::RelativeRotate(oldmat,local);
-}
-
-void KX_SumoPhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool local)
-{
- SumoPhysicsController::SetLinearVelocity(lin_vel[0],lin_vel[1],lin_vel[2],local);
-
-}
-
-void KX_SumoPhysicsController::SetAngularVelocity(const MT_Vector3& ang_vel,bool local)
-{
- SumoPhysicsController::SetAngularVelocity(ang_vel[0],ang_vel[1],ang_vel[2],local);
-}
-
-MT_Vector3 KX_SumoPhysicsController::GetVelocity(const MT_Point3& pos)
-{
-
- float linvel[3];
- SumoPhysicsController::GetVelocity(pos[0],pos[1],pos[2],linvel[0],linvel[1],linvel[2]);
-
- return MT_Vector3 (linvel);
-}
-
-MT_Vector3 KX_SumoPhysicsController::GetLinearVelocity()
-{
- return GetVelocity(MT_Point3(0,0,0));
-
-}
-
-void KX_SumoPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
- SumoPhysicsController::resolveCombinedVelocities(linvelX,linvelY,linvelZ,angVelX,angVelY,angVelZ);
-}
-
-void KX_SumoPhysicsController::ApplyTorque(const MT_Vector3& torque,bool local)
-{
- SumoPhysicsController::ApplyTorque(torque[0],torque[1],torque[2],local);
-
-}
-
-void KX_SumoPhysicsController::ApplyForce(const MT_Vector3& force,bool local)
-{
- SumoPhysicsController::ApplyForce(force[0],force[1],force[2],local);
-}
-
-bool KX_SumoPhysicsController::Update(double time)
-{
- return SynchronizeMotionStates(time);
-}
-
-void KX_SumoPhysicsController::SetSimulatedTime(double time)
-{
-
-}
-
-void KX_SumoPhysicsController::SetSumoTransform(bool nondynaonly)
-{
- SumoPhysicsController::setSumoTransform(nondynaonly);
-
-}
-
-void KX_SumoPhysicsController::SuspendDynamics(bool)
-{
- SumoPhysicsController::SuspendDynamics();
-}
-
-void KX_SumoPhysicsController::RestoreDynamics()
-{
- SumoPhysicsController::RestoreDynamics();
-}
-
-SG_Controller* KX_SumoPhysicsController::GetReplica(SG_Node* destnode)
-{
-
- PHY_IMotionState* motionstate = new KX_MotionState(destnode);
-
- KX_SumoPhysicsController* physicsreplica = new KX_SumoPhysicsController(*this);
-
- //parentcontroller is here be able to avoid collisions between parent/child
-
- PHY_IPhysicsController* parentctrl = NULL;
-
- if (destnode != destnode->GetRootSGParent())
- {
- KX_GameObject* clientgameobj = (KX_GameObject*) destnode->GetRootSGParent()->GetSGClientObject();
- if (clientgameobj)
- {
- parentctrl = (KX_SumoPhysicsController*)clientgameobj->GetPhysicsController();
- } else
- {
- // it could be a false node, try the children
- NodeList::const_iterator childit;
- for (
- childit = destnode->GetSGChildren().begin();
- childit!= destnode->GetSGChildren().end();
- ++childit
- ) {
- KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
- if (clientgameobj)
- {
- parentctrl = (KX_SumoPhysicsController*)clientgameobj->GetPhysicsController();
- }
- }
- }
- }
-
- physicsreplica->PostProcessReplica(motionstate,parentctrl);
-
- return physicsreplica;
-}
-
-
-void KX_SumoPhysicsController::SetObject (SG_IObject* object)
-{
- SG_Controller::SetObject(object);
-
- // cheating here...
-//should not be necessary, is it for duplicates ?
-
-KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
-gameobj->SetPhysicsController(this,gameobj->IsDynamic());
-GetSumoObject()->setClientObject(gameobj->getClientInfo());
-}
-
-void KX_SumoPhysicsController::setMargin(float collisionMargin)
-{
- SumoPhysicsController::SetMargin(collisionMargin);
-}
-
-
-void KX_SumoPhysicsController::setOrientation(const MT_Matrix3x3& rot)
-{
- MT_Quaternion orn = rot.getRotation();
- SumoPhysicsController::setOrientation(
- orn[0],orn[1],orn[2],orn[3]);
-
-}
-void KX_SumoPhysicsController::getOrientation(MT_Quaternion& orn)
-{
-
- float quat[4];
-
- SumoPhysicsController::getOrientation(quat[0],quat[1],quat[2],quat[3]);
-
- orn = MT_Quaternion(quat);
-
-}
-
-void KX_SumoPhysicsController::setPosition(const MT_Point3& pos)
-{
- SumoPhysicsController::setPosition(pos[0],pos[1],pos[2]);
-
-}
-
-void KX_SumoPhysicsController::setScaling(const MT_Vector3& scaling)
-{
- SumoPhysicsController::setScaling(scaling[0],scaling[1],scaling[2]);
-
-}
-
-MT_Scalar KX_SumoPhysicsController::GetMass()
-{
- return SumoPhysicsController::getMass();
-}
-
-void KX_SumoPhysicsController::SetMass(MT_Scalar newmass)
-{
-}
-
-MT_Vector3 KX_SumoPhysicsController::GetLocalInertia()
-{
- return MT_Vector3(0.f, 0.f, 0.f); // \todo
-}
-
-MT_Scalar KX_SumoPhysicsController::GetRadius()
-{
- return SumoPhysicsController::GetRadius();
-}
-
-MT_Vector3 KX_SumoPhysicsController::getReactionForce()
-{
- float force[3];
- SumoPhysicsController::getReactionForce(force[0],force[1],force[2]);
- return MT_Vector3(force);
-
-}
-
-void KX_SumoPhysicsController::setRigidBody(bool rigid)
-{
- SumoPhysicsController::setRigidBody(rigid);
-
-}
-
-
-KX_SumoPhysicsController::~KX_SumoPhysicsController()
-{
-
-
-}
-
-
-#endif//USE_SUMO_SOLID
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
deleted file mode 100644
index 278994c6ae7..00000000000
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __KX_SUMOPHYSICSCONTROLLER_H
-#define __KX_SUMOPHYSICSCONTROLLER_H
-
-#include "PHY_IPhysicsController.h"
-
-/**
- Physics Controller, a special kind of Scene Graph Transformation Controller.
- It get's callbacks from Sumo in case a transformation change took place.
- Each time the scene graph get's updated, the controller get's a chance
- in the 'Update' method to reflect changed.
-*/
-
-#include "SumoPhysicsController.h"
-#include "KX_IPhysicsController.h"
-
-class KX_SumoPhysicsController : public KX_IPhysicsController,
- public SumoPhysicsController
-
-{
-
-
-public:
- KX_SumoPhysicsController(
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- class PHY_IMotionState* motionstate
- ,bool dyna)
- : KX_IPhysicsController(dyna,false,false,NULL) ,
- SumoPhysicsController(sumoScene,/*solidscene,*/sumoObj,motionstate,dyna)
- {
- };
- virtual ~KX_SumoPhysicsController();
-
- void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse);
- virtual void SetObject (SG_IObject* object);
- virtual void setMargin (float collisionMargin);
-
- void RelativeTranslate(const MT_Vector3& dloc,bool local);
- void RelativeRotate(const MT_Matrix3x3& drot,bool local);
- void ApplyTorque(const MT_Vector3& torque,bool local);
- void ApplyForce(const MT_Vector3& force,bool local);
- MT_Vector3 GetLinearVelocity();
- MT_Vector3 GetAngularVelocity() // to keep compiler happy
- { return MT_Vector3(0.0,0.0,0.0); }
- MT_Vector3 GetVelocity(const MT_Point3& pos);
- void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
- void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
- void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
-
-
- void SuspendDynamics(bool);
- void RestoreDynamics();
- virtual void AddCompoundChild(KX_IPhysicsController* child) { }
- virtual void RemoveCompoundChild(KX_IPhysicsController* child) { }
-
- virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Matrix3x3& orn);
- virtual void SetTransform() {}
-
- virtual void setPosition(const MT_Point3& pos);
- virtual void setScaling(const MT_Vector3& scaling);
- virtual MT_Scalar GetMass();
- virtual void SetMass(MT_Scalar newmass);
- virtual MT_Vector3 GetLocalInertia();
- virtual MT_Scalar GetRadius();
- virtual MT_Vector3 getReactionForce();
- virtual void setRigidBody(bool rigid);
-
- virtual float GetLinVelocityMin() { return SumoPhysicsController::GetLinVelocityMin(); }
- virtual void SetLinVelocityMin(float val) { SumoPhysicsController::SetLinVelocityMin(val); }
- virtual float GetLinVelocityMax() { return SumoPhysicsController::GetLinVelocityMax(); }
- virtual void SetLinVelocityMax(float val) { SumoPhysicsController::SetLinVelocityMax(val); }
-
- virtual SG_Controller* GetReplica(class SG_Node* destnode);
-
-
- void SetSumoTransform(bool nondynaonly);
- // todo: remove next line !
- virtual void SetSimulatedTime(double time);
-
- // call from scene graph to update
- virtual bool Update(double time);
-
- void
- SetOption(
- int option,
- int value
- ){
- // intentionally empty
- };
-};
-
-#endif //__KX_SUMOPHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile
index 59b3ff178fb..f57349b7138 100644
--- a/source/gameengine/Ketsji/Makefile
+++ b/source/gameengine/Ketsji/Makefile
@@ -44,7 +44,7 @@ CPPFLAGS += -I../../blender/python
CPPFLAGS += -I../../blender/python/generic
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_BULLET2)/include
CPPFLAGS += -I../Rasterizer/RAS_OpenGLRasterizer
@@ -54,8 +54,6 @@ CPPFLAGS += -I../../kernel/gen_system
CPPFLAGS += -I../Network -IKXNetwork
CPPFLAGS += -I../Physics/common
CPPFLAGS += -I../Physics/Dummy
-CPPFLAGS += -I../Physics/Sumo
-CPPFLAGS += -I../Physics/BlOde
CPPFLAGS += -I../Physics/Bullet
CPPFLAGS += -I.
CPPFLAGS += -I../Converter
diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript
index 49dbacc8916..b09267b79ff 100644
--- a/source/gameengine/Ketsji/SConscript
+++ b/source/gameengine/Ketsji/SConscript
@@ -18,16 +18,9 @@ incs += ' #source/blender/blenkernel #source/blender #source/blender/editors/inc
incs += ' #source/blender/makesdna #source/blender/python #source/gameengine/Rasterizer'
incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions #source/gameengine/Network'
incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common #source/gameengine/Physics/Bullet'
-incs += ' #source/gameengine/Physics/BlOde #source/gameengine/Physics/Dummy'
+incs += ' #source/gameengine/Physics/Dummy'
incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu'
-if env['WITH_BF_SOLID']:
- incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/include'
- incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork'
- incs += ' ' + env['BF_SOLID_INC']
- defs += ' USE_SUMO_SOLID'
-
-
incs += ' ' + env['BF_PYTHON_INC']
incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_OPENGL_INC']
diff --git a/source/gameengine/Physics/BlOde/Makefile b/source/gameengine/Physics/BlOde/Makefile
deleted file mode 100644
index 1fbbf198377..00000000000
--- a/source/gameengine/Physics/BlOde/Makefile
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-#
-
-LIBNAME = blode
-DIR = $(OCGDIR)/gameengine/blphys/$(LIBNAME)
-
-include nan_compile.mk
-
-CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-
-CPPFLAGS += -I$(OPENGL_HEADERS)
-CPPFLAGS += -I$(NAN_STRING)/include
-CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_ODE)/include
-CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
-CPPFLAGS += -I../../Physics/common
-CPPFLAGS += -I../../Physics/Dummy
-# nlin: fix this, should put in NAN_ODE dir
-#CPPFLAGS += -I./ode/ode/include
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
deleted file mode 100644
index 5efd0994311..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp
+++ /dev/null
@@ -1,625 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#define USE_ODE
-#ifdef USE_ODE
-
-#include "OdePhysicsController.h"
-#include "PHY_IMotionState.h"
-
-#include <ode/ode.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-///////////////////////////////////////////////////////////////////////////
-//
-// general to-do list for ODE physics. This is maintained in doxygen format.
-//
-/// \todo determine assignment time for bounding spheres.
-///
-/// it appears you have to select "sphere" for bounding volume AND "draw bounds"
-/// in order for a bounding sphere to be generated. otherwise a box is generated.
-/// determine exactly when and how the bounding volumes are generated and make
-/// this consistent.
-/// }
-///
-/// \todo bounding sphere size incorrect
-///
-/// it appears NOT to use the size of the shown bounding sphere (button "draw bounds").
-/// it appears instead to use the size of the "size" dynamic parameter in the
-/// gamebuttons but this "size" draws an incorrectly-sized circle on screen for the
-/// bounding sphere (leftover skewed size calculation from sumo?) so figure out WHERE
-/// its getting the radius from.
-///
-/// \todo ODE collisions must fire collision actuator
-///
-/// See OdePhysicsEnvironment::OdeNearCallback. If a sensor was created to check
-/// for the presence of this collision, then in the NearCallback you need to
-/// take appropriate action regarding the sensor - something like checking its
-/// controller and if needed firing its actuator. Need to find similar code in
-/// Fuzzics which fires collision controllers/actuators.
-///
-/// \todo Are ghost collisions possible?
-///
-/// How do ghost collisions work? Do they require collision detection through ODE
-/// and NON-CREATION of contact-joint in OdeNearCallback? Currently OdeNearCallback
-/// creates joints ALWAYS for collisions.
-///
-/// \todo Why is KX_GameObject::addLinearVelocity commented out?
-///
-/// Try putting this code back in.
-///
-/// \todo Too many non-dynamic actors bogs down ODE physics
-///
-/// Lots of "geoms" (ODE static geometry) probably slows down ode. Try a test file
-/// with lots of static geometry - the game performance in Blender says it is
-/// spending all its time in physics, and I bet all that time is in collision
-/// detection. It's ode's non-hierarchical collision detection.
-/// try making a separate ode test program (not within blender) with 1000 geoms and
-/// see how fast it is. if it is really slow, there is the culprit.
-/// isnt someone working on an improved ODE collision detector? check
-/// ode mailing list.
-///
-///
-/// \todo support collision of dynas with non-dynamic triangle meshes
-///
-/// ODE has trimesh-collision support but only for trimeshes without a transform
-/// matrix. update ODE tricollider to support a transform matrix. this will allow
-/// moving trimeshes non-dynamically (e.g. through Ipos). then collide trimeshes
-/// with dynas. this allows dynamic primitives (spheres, boxes) to collide with
-/// non-dynamic or kinematically controlled tri-meshes. full dynamic trimesh to
-/// dynamic trimesh support is hard because it requires (a) collision and penetration
-/// depth for trimesh to trimesh and (hard to compute) (b) an intertia tensor
-/// (easy to compute).
-///
-/// a triangle mesh collision geometry should be created when the blender
-/// bounding volume (F9, EDITBUTTONS) is set to "polyheder", since this is
-/// currently the place where sphere/box selection is made
-///
-/// \todo specify ODE ERP+CFM in blender interface
-///
-/// when ODE physics selected, have to be able to set global cfm and erp.
-/// per-joint erp/cfm could be handled in constraint window.
-///
-/// \todo moving infinite mass objects should impart extra impulse to objects they collide with
-///
-/// currently ODE's ERP pushes them apart but doesn't account for their motion.
-/// you have to detect if one body in a collision is a non-dyna. This
-/// requires adding a new accessor method to
-/// KX_IPhysicsInterfaceController to access the hidden m_isDyna variable,
-/// currently it can only be written, not read). If one of the bodies in a
-/// collision is a non-dyna, then impart an extra impulse based on the
-/// motion of the static object (using its last 2 frames as an approximation
-/// of its linear and angular velocity). Linear velocity is easy to
-/// approximate, but angular? you have orientation at this frame and
-/// orientation at previous frame. The question is what is the angular
-/// velocity which would have taken you from the previous frame's orientation
-/// to this frame's orientation?
-///
-/// \todo allow tweaking bounding volume size
-///
-/// the scene converter currently uses the blender bounding volume of the selected
-/// object as the geometry for ODE collision purposes. this is good and automatic
-/// intuitive - lets you choose between cube, sphere, mesh. but you need to be able
-/// to tweak this size for physics.
-///
-/// \todo off center meshes totally wrong for ode
-///
-/// ode uses x, y, z extents regradless of center. then places geom at center of object.
-/// but visual geom is not necessarily at center. need to detect off-center situations.
-/// then do what? treat it as an encapsulated off-center mass, or recenter it?
-///
-/// i.o.w. recalculate center, or recalculate mass distribution (using encapsulation)?
-///
-/// \todo allow off-center mass
-///
-/// using ode geometry encapsulators
-///
-/// \todo allow entering compound geoms for complex collision shapes specified as a union of simpler shapes
-///
-/// The collision shape for arbitrary triangle meshes can probably in general be
-///well approximated by a compound ODE geometry object, which is merely a combination
-///of many primitives (capsule, sphere, box). I eventually want to add the ability
-///to associate compound geometry objects with Blender gameobjects. I think one
-///way of doing this would be to add a new button in the GameButtons, "RigidBodyCompound".
-///If the object is "Dynamic" + "RigidBody", then the object's bounding volume (sphere,
-///box) is created. If an object is "Dynamic" + "RigidBodyCompound", then the object itself
-///will merely create a "wrapper" compound object, with the actual geometry objects
-///being created from the object's children in Blender. E.g. if I wanted to make a
-///compound collision object consisting of a sphere and 2 boxes, I would create a
-///parent gameobject with the actual triangle mesh, and set its GameButtons to
-///"RigidBodyCompound". I would then create 3 children of this object, 1 sphere and
-///2 boxes, and set the GameButtons for the children to be "RigidBody". Then at
-///scene conversion time, the scene converter sees "RigidBodyCompound" for the
-///top-level object, then appropriately traverses the children and creates the compound
-///collision geometry consisting of 2 boxes and a sphere. In this way, arbitrary
-///mesh-mesh collision becomes much less necessary - the artist can (or must,
-///depending on your point of view!) approximate the collision shape for arbitrary
-///meshes with a combination of one or more primitive shapes. I think using the
-///parent/child relationship in Blender and a new button "RigidBodyCompound" for the
-///parent object of a compound is a feasible way of doing this in Blender.
-///
-///See ODE demo test_boxstack and look at the code when you drop a compound object
-///with the "X" key.
-///
-/// \todo add visual specification of constraints
-///
-/// extend the armature constraint system. by using empties and constraining one empty
-/// to "copy location" of another, you can get a p2p constraint between the two empties.
-/// by making the two empties each a parent of a blender object, you effectively have
-/// a p2p constraint between 2 blender bodies. the scene converter can detect these
-/// empties, detect the constraint, and generate an ODE constraint.
-///
-/// then add a new constraint type "hinge" and "slider" to correspond to ODE joints.
-/// e.g. a slider would be a constraint which restricts the axis of its object to lie
-/// along the same line as another axis of a different object. e.g. you constrain x-axis
-/// of one empty to lie along the same line as the z-axis of another empty; this gives
-/// a slider joint.
-///
-/// open questions: how to handle powered joints? to what extent should/must constraints
-/// be enforced during modeling? use CCD-style algorithm in modeler to enforce constraints?
-/// how about ODE powered constraints e.g. motors?
-///
-/// \todo enable suspension of bodies
-/// ODE offers native support for suspending dynas. but what about suspending non-dynas
-/// (e.g. geoms)? suspending geoms is also necessary to ease the load of ODE's (simple?)
-/// collision detector. suspending dynas and geoms is important for the activity culling,
-/// which apparently works at a simple level. perhaps suspension should actually
-/// remove or insert geoms/dynas into the ODE space/world? is this operation (insertion/
-/// removal) fast enough at run-time? test it. if fast enough, then suspension=remove from
-/// ODE simulation, awakening=insertion into ODE simulation.
-///
-/// \todo python interface for tweaking constraints via python
-///
-/// \todo raytesting to support gameengine sensors that need it
-///
-/// \todo investigate compatibility issues with old Blender 2.25 physics engine (sumo/fuzzics)
-/// is it possible to have compatibility? how hard is it? how important is it?
-
-
-ODEPhysicsController::ODEPhysicsController(bool dyna, bool fullRigidBody,
- bool phantom, class PHY_IMotionState* motionstate, struct dxSpace* space,
- struct dxWorld* world, float mass,float friction,float restitution,
- bool implicitsphere,float center[3],float extents[3],float radius)
- :
- m_OdeDyna(dyna),
- m_firstTime(true),
- m_bFullRigidBody(fullRigidBody),
- m_bPhantom(phantom),
- m_bKinematic(false),
- m_bPrevKinematic(false),
- m_MotionState(motionstate),
- m_OdeSuspendDynamics(false),
- m_space(space),
- m_world(world),
- m_mass(mass),
- m_friction(friction),
- m_restitution(restitution),
- m_bodyId(0),
- m_geomId(0),
- m_implicitsphere(implicitsphere),
- m_radius(radius)
-{
- m_center[0] = center[0];
- m_center[1] = center[1];
- m_center[2] = center[2];
- m_extends[0] = extents[0];
- m_extends[1] = extents[1];
- m_extends[2] = extents[2];
-};
-
-
-ODEPhysicsController::~ODEPhysicsController()
-{
- if (m_geomId)
- {
- dGeomDestroy (m_geomId);
- }
-}
-
-float ODEPhysicsController::getMass()
-{
- dMass mass;
- dBodyGetMass(m_bodyId,&mass);
- return mass.mass;
-}
-
-//////////////////////////////////////////////////////////////////////
-/// \todo Impart some extra impulse to dynamic objects when they collide with kinematically controlled "static" objects (ODE geoms), by using last 2 frames as 1st order approximation to the linear/angular velocity, and computing an appropriate impulse. Sumo (old physics engine) did this, see for details.
-/// \todo handle scaling of static ODE geoms or fail with error message if Ipo tries to change scale of a static geom object
-
-bool ODEPhysicsController::SynchronizeMotionStates(float time)
-{
- /**
- 'Late binding' of the rigidbody, because the World Scaling is not available until the scenegraph is traversed
- */
-
-
- if (m_firstTime)
- {
- m_firstTime=false;
-
- m_MotionState->calculateWorldTransformations();
-
- dQuaternion worldquat;
- float worldpos[3];
-
-#ifdef dDOUBLE
- m_MotionState->getWorldOrientation((float)worldquat[1],
- (float)worldquat[2],(float)worldquat[3],(float)worldquat[0]);
-#else
- m_MotionState->getWorldOrientation(worldquat[1],
- worldquat[2],worldquat[3],worldquat[0]);
-#endif
- m_MotionState->getWorldPosition(worldpos[0],worldpos[1],worldpos[2]);
-
- float scaling[3];
- m_MotionState->getWorldScaling(scaling[0],scaling[1],scaling[2]);
-
- if (!m_bPhantom)
- {
- if (m_implicitsphere)
- {
- m_geomId = dCreateSphere (m_space,m_radius*scaling[0]);
- } else
- {
- m_geomId = dCreateBox (m_space, m_extends[0]*scaling[0],m_extends[1]*scaling[1],m_extends[2]*scaling[2]);
- }
- } else
- {
- m_geomId=0;
- }
-
- if (m_geomId)
- dGeomSetData(m_geomId,this);
-
- if (!this->m_OdeDyna)
- {
- if (!m_bPhantom)
- {
- dGeomSetPosition (this->m_geomId,worldpos[0],worldpos[1],worldpos[2]);
- dMatrix3 R;
- dQtoR (worldquat, R);
- dGeomSetRotation (this->m_geomId,R);
- }
- } else
- {
- //it's dynamic, so create a 'model'
- m_bodyId = dBodyCreate(this->m_world);
- dBodySetPosition (m_bodyId,worldpos[0],worldpos[1],worldpos[2]);
- dBodySetQuaternion (this->m_bodyId,worldquat);
- //this contains both scalar mass and inertia tensor
- dMass m;
- float length=1,width=1,height=1;
- dMassSetBox (&m,1,m_extends[0]*scaling[0],m_extends[1]*scaling[1],m_extends[2]*scaling[2]);
- dMassAdjust (&m,this->m_mass);
- dBodySetMass (m_bodyId,&m);
-
- if (!m_bPhantom)
- {
- dGeomSetBody (m_geomId,m_bodyId);
- }
-
-
- }
-
- if (this->m_OdeDyna && !m_bFullRigidBody)
- {
- // ?? huh? what to do here?
- }
- }
-
-
-
- if (m_OdeDyna)
- {
- if (this->m_OdeSuspendDynamics)
- {
- return false;
- }
-
- const float* worldPos = (float *)dBodyGetPosition(m_bodyId);
- m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
-
- const float* worldquat = (float *)dBodyGetQuaternion(m_bodyId);
- m_MotionState->setWorldOrientation(worldquat[1],worldquat[2],worldquat[3],worldquat[0]);
- }
- else {
- // not a dyna, so dynamics (i.e. this controller) has not updated
- // anything. BUT! an Ipo or something else might have changed the
- // position/orientation of this geometry.
- // so update the static geom position
-
- /// \todo impart some extra impulse to colliding objects!
- dQuaternion worldquat;
- float worldpos[3];
-
-#ifdef dDOUBLE
- m_MotionState->getWorldOrientation((float)worldquat[1],
- (float)worldquat[2],(float)worldquat[3],(float)worldquat[0]);
-#else
- m_MotionState->getWorldOrientation(worldquat[1],
- worldquat[2],worldquat[3],worldquat[0]);
-#endif
- m_MotionState->getWorldPosition(worldpos[0],worldpos[1],worldpos[2]);
-
- float scaling[3];
- m_MotionState->getWorldScaling(scaling[0],scaling[1],scaling[2]);
-
- /// \todo handle scaling! what if Ipo changes scale of object?
- // Must propagate to geom... is scaling geoms possible with ODE? Also
- // what about scaling trimeshes, that is certainly difficult...
- dGeomSetPosition (this->m_geomId,worldpos[0],worldpos[1],worldpos[2]);
- dMatrix3 R;
- dQtoR (worldquat, R);
- dGeomSetRotation (this->m_geomId,R);
- }
-
- return false; //it update the worldpos
-}
-
-PHY_IMotionState* ODEPhysicsController::GetMotionState()
-{
- return m_MotionState;
-}
-
-
-// kinematic methods
-void ODEPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
-{
-
-}
-void ODEPhysicsController::RelativeRotate(const float drot[9],bool local)
-{
-}
-void ODEPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
-{
-
- dQuaternion worldquat;
- worldquat[0] = quatReal;
- worldquat[1] = quatImag0;
- worldquat[2] = quatImag1;
- worldquat[3] = quatImag2;
-
- if (!this->m_OdeDyna)
- {
- dMatrix3 R;
- dQtoR (worldquat, R);
- dGeomSetRotation (this->m_geomId,R);
- } else
- {
- dBodySetQuaternion (m_bodyId,worldquat);
- this->m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
- }
-
-}
-
-void ODEPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
-{
- float q[4];
- this->m_MotionState->getWorldOrientation(q[0],q[1],q[2],q[3]);
- quatImag0=q[0];
- quatImag1=q[1];
- quatImag2=q[2];
- quatReal=q[3];
-}
-
-void ODEPhysicsController::getPosition(PHY__Vector3& pos) const
-{
- m_MotionState->getWorldPosition(pos[0],pos[1],pos[2]);
-
-}
-
-void ODEPhysicsController::setPosition(float posX,float posY,float posZ)
-{
- if (!m_bPhantom)
- {
- if (!this->m_OdeDyna)
- {
- dGeomSetPosition (m_geomId, posX, posY, posZ);
- } else
- {
- dBodySetPosition (m_bodyId, posX, posY, posZ);
- }
- }
-}
-void ODEPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
-{
-}
-
-// physics methods
-void ODEPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
-{
- if (m_OdeDyna) {
- if(local) {
- dBodyAddRelTorque(m_bodyId, torqueX, torqueY, torqueZ);
- } else {
- dBodyAddTorque (m_bodyId, torqueX, torqueY, torqueZ);
- }
- }
-}
-
-void ODEPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
-{
- if (m_OdeDyna) {
- if(local) {
- dBodyAddRelForce(m_bodyId, forceX, forceY, forceZ);
- } else {
- dBodyAddForce (m_bodyId, forceX, forceY, forceZ);
- }
- }
-}
-
-void ODEPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
-{
- if (m_OdeDyna) {
- if(local) {
- // TODO: translate angular vel into local frame, then apply
- } else {
- dBodySetAngularVel (m_bodyId, ang_velX,ang_velY,ang_velZ);
- }
- }
-}
-
-void ODEPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)
-{
- if (m_OdeDyna)
- {
- dVector3 vel = {lin_velX,lin_velY,lin_velZ, 1.0};
- if (local)
- {
- dMatrix3 worldmat;
- dVector3 localvel;
- dQuaternion worldquat;
-
-#ifdef dDOUBLE
- m_MotionState->getWorldOrientation((float)worldquat[1],
- (float)worldquat[2], (float)worldquat[3],(float)worldquat[0]);
-#else
- m_MotionState->getWorldOrientation(worldquat[1],worldquat[2],
- worldquat[3],worldquat[0]);
-#endif
- dQtoR (worldquat, worldmat);
-
- dMULTIPLY0_331 (localvel,worldmat,vel);
- dBodySetLinearVel (m_bodyId, localvel[0],localvel[1],localvel[2]);
-
- } else
- {
- dBodySetLinearVel (m_bodyId, lin_velX,lin_velY,lin_velZ);
- }
- }
-}
-
-void ODEPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
-{
- if (m_OdeDyna)
- {
- //apply linear and angular effect
- const dReal* linvel = dBodyGetLinearVel(m_bodyId);
- float mass = getMass();
- if (mass >= 0.00001f)
- {
- float massinv = 1.f/mass;
- float newvel[3];
- newvel[0]=linvel[0]+impulseX*massinv;
- newvel[1]=linvel[1]+impulseY*massinv;
- newvel[2]=linvel[2]+impulseZ*massinv;
- dBodySetLinearVel(m_bodyId,newvel[0],newvel[1],newvel[2]);
-
- const float* worldPos = (float *)dBodyGetPosition(m_bodyId);
-
- const float* angvelc = (float *)dBodyGetAngularVel(m_bodyId);
- float angvel[3];
- angvel[0]=angvelc[0];
- angvel[1]=angvelc[1];
- angvel[2]=angvelc[2];
-
- dVector3 impulse;
- impulse[0]=impulseX;
- impulse[1]=impulseY;
- impulse[2]=impulseZ;
-
- dVector3 ap;
- ap[0]=attachX-worldPos[0];
- ap[1]=attachY-worldPos[1];
- ap[2]=attachZ-worldPos[2];
-
- dCROSS(angvel,+=,ap,impulse);
- dBodySetAngularVel(m_bodyId,angvel[0],angvel[1],angvel[2]);
-
- }
-
- }
-
-}
-
-void ODEPhysicsController::SuspendDynamics()
-{
-
-}
-
-void ODEPhysicsController::RestoreDynamics()
-{
-
-}
-
-
-/**
- reading out information from physics
-*/
-void ODEPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
-{
- if (m_OdeDyna)
- {
- const float* vel = (float *)dBodyGetLinearVel(m_bodyId);
- linvX = vel[0];
- linvY = vel[1];
- linvZ = vel[2];
- } else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
-
- }
-}
-/**
- GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
-*/
-void ODEPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
-{
-
-}
-
-
-void ODEPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
-{
-
-}
-void ODEPhysicsController::setRigidBody(bool rigid)
-{
-
-}
-
-
-void ODEPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
-{
- m_MotionState = motionstate;
- m_bKinematic = false;
- m_bPrevKinematic = false;
- m_firstTime = true;
-}
-
-
-void ODEPhysicsController::SetSimulatedTime(float time)
-{
-}
-
-
-void ODEPhysicsController::WriteMotionStateToDynamics(bool nondynaonly)
-{
-
-}
-#endif
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.h b/source/gameengine/Physics/BlOde/OdePhysicsController.h
deleted file mode 100644
index 544d11da2ca..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __ODE_PHYSICSCONTROLLER_H
-#define __ODE_PHYSICSCONTROLLER_H
-
-
-#include "PHY_IPhysicsController.h"
-
-/**
- ODE Physics Controller, a special kind of a PhysicsController.
- A Physics Controller is a special kind of Scene Graph Transformation Controller.
- Each time the scene graph get's updated, the controller get's a chance
- in the 'Update' method to reflect changes.
-*/
-
-class ODEPhysicsController : public PHY_IPhysicsController
-
-{
-
- bool m_OdeDyna;
-
-public:
- ODEPhysicsController(
- bool dyna,
- bool fullRigidBody,
- bool phantom,
- class PHY_IMotionState* motionstate,
- struct dxSpace* space,
- struct dxWorld* world,
- float mass,
- float friction,
- float restitution,
- bool implicitsphere,
- float center[3],
- float extends[3],
- float radius);
-
- virtual ~ODEPhysicsController();
-
- // kinematic methods
- virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
- virtual void RelativeRotate(const float drot[9],bool local);
- virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
- virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
- virtual void setPosition(float posX,float posY,float posZ);
- virtual void getPosition(PHY__Vector3& pos) const;
-
- virtual void setScaling(float scaleX,float scaleY,float scaleZ);
-
- // physics methods
- virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local);
- virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local);
- virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
- virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
- virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
- virtual void SetActive(bool active){};
- virtual void SuspendDynamics();
- virtual void RestoreDynamics();
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
- {
- //todo ?
- }
-
-
- /**
- reading out information from physics
- */
- virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ);
- /**
- GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
- */
- virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ);
- virtual float getMass();
- virtual void getReactionForce(float& forceX,float& forceY,float& forceZ);
- virtual void setRigidBody(bool rigid);
-
-
- virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
-
- // \todo remove next line !
- virtual void SetSimulatedTime(float time);
-
-
- virtual void WriteDynamicsToMotionState() {};
- virtual void WriteMotionStateToDynamics(bool nondynaonly);
- virtual class PHY_IMotionState* GetMotionState();
-
- /**
- call from Scene Graph Node to 'update'.
- */
- virtual bool SynchronizeMotionStates(float time);
-
- virtual void calcXform(){}
- virtual void SetMargin(float margin) {}
- virtual float GetMargin() const {return 0.f;}
- virtual float GetRadius() const {return 0.f;}
- virtual void SetRadius(float margin) {}
-
- // clientinfo for raycasts for example
- virtual void* getNewClientInfo() { return m_clientInfo;}
- virtual void setNewClientInfo(void* clientinfo) {m_clientInfo = clientinfo;};
- void* m_clientInfo;
-
- struct dxBody* GetOdeBodyId() { return m_bodyId; }
-
- float getFriction() { return m_friction;}
- float getRestitution() { return m_restitution;}
-
- float GetLinVelocityMin() const { return 0.f; }
- void SetLinVelocityMin(float val) { }
- float GetLinVelocityMax() const { return 0.f; }
- void SetLinVelocityMax(float val) { }
-
-
-private:
-
- bool m_firstTime;
- bool m_bFullRigidBody;
- bool m_bPhantom; // special flag for objects that are not affected by physics 'resolver'
-
- // data to calculate fake velocities for kinematic objects (non-dynas)
- bool m_bKinematic;
- bool m_bPrevKinematic;
-
-
- float m_lastTime;
- bool m_OdeSuspendDynamics;
- class PHY_IMotionState* m_MotionState;
-
- //Ode specific members
- struct dxBody* m_bodyId;
- struct dxGeom* m_geomId;
- struct dxSpace* m_space;
- struct dxWorld* m_world;
- float m_mass;
- float m_friction;
- float m_restitution;
- bool m_implicitsphere;
- float m_center[3];
- float m_extends[3];
- float m_radius;
-};
-
-#endif //__ODE_PHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
deleted file mode 100644
index 54e97858b7f..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include "OdePhysicsEnvironment.h"
-#include "PHY_IMotionState.h"
-#include "OdePhysicsController.h"
-
-#include <ode/ode.h>
-#include <../ode/src/joint.h>
-#include <ode/odemath.h>
-
-ODEPhysicsEnvironment::ODEPhysicsEnvironment()
-{
- m_OdeWorld = dWorldCreate();
- m_OdeSpace = dHashSpaceCreate();
- m_OdeContactGroup = dJointGroupCreate (0);
- dWorldSetCFM (m_OdeWorld,1e-5f);
-
- m_JointGroup = dJointGroupCreate(0);
-
- setFixedTimeStep(true,1.f/60.f);
-}
-
-
-
-ODEPhysicsEnvironment::~ODEPhysicsEnvironment()
-{
- dJointGroupDestroy (m_OdeContactGroup);
- dJointGroupDestroy (m_JointGroup);
-
- dSpaceDestroy (m_OdeSpace);
- dWorldDestroy (m_OdeWorld);
-}
-
-
-
-void ODEPhysicsEnvironment::setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
-{
- m_useFixedTimeStep = useFixedTimeStep;
-
- if (useFixedTimeStep)
- {
- m_fixedTimeStep = fixedTimeStep;
- } else
- {
- m_fixedTimeStep = 0.f;
- }
- m_currentTime = 0.f;
-
- //todo:implement fixed timestepping
-
-}
-float ODEPhysicsEnvironment::getFixedTimeStep()
-{
- return m_fixedTimeStep;
-}
-
-
-
-bool ODEPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep1,float interval)
-{
-
- float deltaTime = timeStep1;
- int numSteps = 1;
-
- if (m_useFixedTimeStep)
- {
- m_currentTime += timeStep1;
- // equal to subSampling (might be a little smaller).
- numSteps = (int)(m_currentTime / m_fixedTimeStep);
- m_currentTime -= m_fixedTimeStep * (float)numSteps;
- deltaTime = m_fixedTimeStep;
- //todo: experiment by smoothing the remaining time over the substeps
- }
-
- for (int i=0;i<numSteps;i++)
- {
- // ode collision update
- dSpaceCollide (m_OdeSpace,this,&ODEPhysicsEnvironment::OdeNearCallback);
-
- int m_odeContacts = GetNumOdeContacts();
-
- //physics integrator + resolver update
- //dWorldStep (m_OdeWorld,deltaTime);
- //dWorldQuickStep (m_OdeWorld,deltaTime);
- //dWorldID w, dReal stepsize)
-
- //clear collision points
- this->ClearOdeContactGroup();
- }
- return true;
-}
-
-void ODEPhysicsEnvironment::setGravity(float x,float y,float z)
-{
- dWorldSetGravity (m_OdeWorld,x,y,z);
-}
-
-
-
-int ODEPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ)
-{
-
- int constraintid = 0;
- ODEPhysicsController* dynactrl = (ODEPhysicsController*)ctrl;
- ODEPhysicsController* dynactrl2 = (ODEPhysicsController*)ctrl2;
-
- switch (type)
- {
- case PHY_POINT2POINT_CONSTRAINT:
- {
- if (dynactrl)
- {
- dJointID jointid = dJointCreateBall (m_OdeWorld,m_JointGroup);
- struct dxBody* bodyid1 = dynactrl->GetOdeBodyId();
- struct dxBody* bodyid2=0;
- const dReal* pos = dBodyGetPosition(bodyid1);
- const dReal* R = dBodyGetRotation(bodyid1);
- dReal offset[3] = {pivotX,pivotY,pivotZ};
- dReal newoffset[3];
- dMULTIPLY0_331 (newoffset,R,offset);
- newoffset[0] += pos[0];
- newoffset[1] += pos[1];
- newoffset[2] += pos[2];
-
-
- if (dynactrl2)
- bodyid2 = dynactrl2->GetOdeBodyId();
-
- dJointAttach (jointid, bodyid1, bodyid2);
-
- dJointSetBallAnchor (jointid, newoffset[0], newoffset[1], newoffset[2]);
-
- constraintid = (int) jointid;
- }
- break;
- }
- case PHY_LINEHINGE_CONSTRAINT:
- {
- if (dynactrl)
- {
- dJointID jointid = dJointCreateHinge (m_OdeWorld,m_JointGroup);
- struct dxBody* bodyid1 = dynactrl->GetOdeBodyId();
- struct dxBody* bodyid2=0;
- const dReal* pos = dBodyGetPosition(bodyid1);
- const dReal* R = dBodyGetRotation(bodyid1);
- dReal offset[3] = {pivotX,pivotY,pivotZ};
- dReal axisset[3] = {axisX,axisY,axisZ};
-
- dReal newoffset[3];
- dReal newaxis[3];
- dMULTIPLY0_331 (newaxis,R,axisset);
-
- dMULTIPLY0_331 (newoffset,R,offset);
- newoffset[0] += pos[0];
- newoffset[1] += pos[1];
- newoffset[2] += pos[2];
-
-
- if (dynactrl2)
- bodyid2 = dynactrl2->GetOdeBodyId();
-
- dJointAttach (jointid, bodyid1, bodyid2);
-
- dJointSetHingeAnchor (jointid, newoffset[0], newoffset[1], newoffset[2]);
- dJointSetHingeAxis(jointid,newaxis[0],newaxis[1],newaxis[2]);
-
- constraintid = (int) jointid;
- }
- break;
- }
- default:
- {
- //not yet
- }
- }
-
- return constraintid;
-
-}
-
-void ODEPhysicsEnvironment::removeConstraint(void *constraintid)
-{
- if (constraintid)
- {
- dJointDestroy((dJointID) constraintid);
- }
-}
-
-PHY_IPhysicsController* ODEPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
-{
-
- //m_OdeWorld
- //collision detection / raytesting
- return NULL;
-}
-
-
-void ODEPhysicsEnvironment::OdeNearCallback (void *data, dGeomID o1, dGeomID o2)
-{
- // \todo if this is a registered collision sensor
- // fire the callback
-
- int i;
- // if (o1->body && o2->body) return;
- ODEPhysicsEnvironment* env = (ODEPhysicsEnvironment*) data;
- dBodyID b1,b2;
-
- b1 = dGeomGetBody(o1);
- b2 = dGeomGetBody(o2);
- // exit without doing anything if the two bodies are connected by a joint
- if (b1 && b2 && dAreConnected (b1,b2)) return;
-
- ODEPhysicsController * ctrl1 =(ODEPhysicsController *)dGeomGetData(o1);
- ODEPhysicsController * ctrl2 =(ODEPhysicsController *)dGeomGetData(o2);
- float friction=ctrl1->getFriction();
- float restitution = ctrl1->getRestitution();
- //for friction, take minimum
-
- friction=(friction < ctrl2->getFriction() ?
- friction :ctrl2->getFriction());
-
- //restitution:take minimum
- restitution = restitution < ctrl2->getRestitution()?
- restitution : ctrl2->getRestitution();
-
- dContact contact[3]; // up to 3 contacts per box
- for (i=0; i<3; i++) {
- contact[i].surface.mode = dContactBounce; //dContactMu2;
- contact[i].surface.mu = friction;//dInfinity;
- contact[i].surface.mu2 = 0;
- contact[i].surface.bounce = restitution;//0.5;
- contact[i].surface.bounce_vel = 0.1f;
- contact[i].surface.slip1=0.0;
- }
-
- if (int numc = dCollide (o1,o2,3,&contact[0].geom,sizeof(dContact))) {
- // dMatrix3 RI;
- // dRSetIdentity (RI);
- // const dReal ss[3] = {0.02,0.02,0.02};
- for (i=0; i<numc; i++) {
- dJointID c = dJointCreateContact (env->m_OdeWorld,env->m_OdeContactGroup,contact+i);
- dJointAttach (c,b1,b2);
- }
- }
-}
-
-
-void ODEPhysicsEnvironment::ClearOdeContactGroup()
-{
- dJointGroupEmpty (m_OdeContactGroup);
-}
-
-int ODEPhysicsEnvironment::GetNumOdeContacts()
-{
- return m_OdeContactGroup->num;
-}
-
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
deleted file mode 100644
index 54e4f7f90e1..00000000000
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * The contents of this file may be used under the terms of either the GNU
- * General Public License Version 2 or later (the "GPL", see
- * http://www.gnu.org/licenses/gpl.html ), or the Blender License 1.0 or
- * later (the "BL", see http://www.blender.org/BL/ ) which has to be
- * bought from the Blender Foundation to become active, in which case the
- * above mentioned GPL option does not apply.
- *
- * The Original Code is Copyright (C) 2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef _ODEPHYSICSENVIRONMENT
-#define _ODEPHYSICSENVIRONMENT
-
-
-#include "PHY_IPhysicsEnvironment.h"
-
-/**
-* Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.)
-* A derived class may be able to 'construct' entities by loading and/or converting
-*/
-class ODEPhysicsEnvironment : public PHY_IPhysicsEnvironment
-{
-
- bool m_useFixedTimeStep;
- float m_fixedTimeStep;
- float m_currentTime;
-
-public:
- ODEPhysicsEnvironment();
- virtual ~ODEPhysicsEnvironment();
- virtual void beginFrame() {}
- virtual void endFrame() {}
-
-
-// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
- virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
- virtual float getFixedTimeStep();
-
- virtual void setGravity(float x,float y,float z);
- virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,
- float axisX,float axisY,float axisZ);
-
- virtual void removeConstraint(void * constraintid);
- virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes) { return false; }
-
-
- //gamelogic callbacks
- virtual void addSensor(PHY_IPhysicsController* ctrl) {}
- virtual void removeSensor(PHY_IPhysicsController* ctrl) {}
- virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
- {
- }
- virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) {return false;}
- virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) {return false;}
- virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;}
- virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
-
-
-
- struct dxWorld* GetOdeWorld() { return m_OdeWorld; };
- struct dxSpace* GetOdeSpace() { return m_OdeSpace;};
-
-private:
-
-
- // ODE physics response
- struct dxWorld* m_OdeWorld;
- // ODE collision detection
- struct dxSpace* m_OdeSpace;
- void ClearOdeContactGroup();
- struct dxJointGroup* m_OdeContactGroup;
- struct dxJointGroup* m_JointGroup;
-
- static void OdeNearCallback(void *data, struct dxGeom* o1, struct dxGeom* o2);
- int GetNumOdeContacts();
-
-};
-
-#endif //_ODEPHYSICSENVIRONMENT
-
diff --git a/source/gameengine/Physics/BlOde/SConscript b/source/gameengine/Physics/BlOde/SConscript
deleted file mode 100644
index 90e949d2d86..00000000000
--- a/source/gameengine/Physics/BlOde/SConscript
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/python
-Import ('user_options_dict')
-Import ('library_env')
-
-phy_ode_env = library_env.Copy ()
-
-source_files = ['OdePhysicsController.cpp',
- 'OdePhysicsEnvironment.cpp']
-
-phy_ode_env.Append (CPPPATH=['.',
- '../common',
- ])
-phy_ode_env.Append (CPPPATH=user_options_dict['ODE_INCLUDE'])
-
-phy_ode_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/PHY_Ode', source=source_files)
diff --git a/source/gameengine/Physics/Dummy/Makefile b/source/gameengine/Physics/Dummy/Makefile
index b0c1b855322..c016a0bebcb 100644
--- a/source/gameengine/Physics/Dummy/Makefile
+++ b/source/gameengine/Physics/Dummy/Makefile
@@ -39,7 +39,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I../../Physics/common
CPPFLAGS += -I../../Physics/Dummy
diff --git a/source/gameengine/Physics/Makefile b/source/gameengine/Physics/Makefile
index b192e497f35..da0d4cafd2e 100644
--- a/source/gameengine/Physics/Makefile
+++ b/source/gameengine/Physics/Makefile
@@ -32,7 +32,6 @@ include nan_definitions.mk
SOURCEDIR = source/gameengine/Physics
DIR = $(OCGDIR)/gameengine/blphys
-DIRS = common Sumo Dummy Bullet
-#DIRS += BlOde
+DIRS = common Dummy Bullet
include nan_subdirs.mk
diff --git a/source/gameengine/Physics/Sumo/CMakeLists.txt b/source/gameengine/Physics/Sumo/CMakeLists.txt
deleted file mode 100644
index c57a4af6706..00000000000
--- a/source/gameengine/Physics/Sumo/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# $Id$
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# The Original Code is Copyright (C) 2006, Blender Foundation
-# All rights reserved.
-#
-# The Original Code is: all of this file.
-#
-# Contributor(s): Jacques Beaurain.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-SET(SRC
- SumoPHYCallbackBridge.cpp
- SumoPhysicsController.cpp
- SumoPhysicsEnvironment.cpp
- Fuzzics/src/SM_FhObject.cpp
- Fuzzics/src/SM_Object.cpp
- Fuzzics/src/SM_Scene.cpp
- Fuzzics/src/SM_MotionState.cpp
-)
-
-SET(INC
- .
- ../common
- Fuzzics/include
- ../../../../intern/moto/include
- ../../../../extern/solid
-)
-
-BLENDERLIB(bf_sumo "${SRC}" "${INC}")
-#env.BlenderLib ( 'bf_sumo', sources, incs, [], libtype=['game2','player'], priority=[30, 70] , compileflags=cflags)
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/Makefile b/source/gameengine/Physics/Sumo/Fuzzics/Makefile
deleted file mode 100644
index 5ed2c31a1d0..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-# Bounces make to subdirectories.
-
-SOURCEDIR = source/gameengine/Physics/Sumo/Fuzzics
-DIRS = src
-
-include nan_subdirs.mk
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h
deleted file mode 100644
index 42b5ab48ab6..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef SM_CALLBACK_H
-#define SM_CALLBACK_H
-
-class SM_Callback {
-public:
- virtual void do_me() = 0;
- virtual ~SM_Callback() {}
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h
deleted file mode 100644
index 6749e7957ec..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_ClientObjectInfo.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __SM_CLIENTOBJECT_INFO_H
-#define __SM_CLIENTOBJECT_INFO_H
-
-/**
- * Client Type and Additional Info. This structure can be use instead of a bare void* pointer, for safeness, and additional info for callbacks
- */
-
-struct SM_ClientObjectInfo
-{
- int m_type;
- void* m_clientobject1;
- void* m_auxilary_info;
-};
-
-#endif //__SM_CLIENTOBJECT_INFO_H
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h
deleted file mode 100644
index 48d5906e53d..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Debug.h
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-#ifndef __SM_DEBUG_H__
-#define __SM_DEBUG_H__
-
-/* Comment this to disable all SUMO debugging printfs */
-
-#define SM_DEBUG
-
-#ifdef SM_DEBUG
-
-#include <stdio.h>
-
-/* Uncomment this to printf all ray casts */
-//#define SM_DEBUG_RAYCAST
-
-/* Uncomment this to printf collision callbacks */
-//#define SM_DEBUG_BOING
-
-/* Uncomment this to printf Xform matrix calculations */
-//#define SM_DEBUG_XFORM
-
-#endif /* SM_DEBUG */
-
-#endif /* __SM_DEBUG_H__ */
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h
deleted file mode 100644
index b03612ed15e..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_FHOBJECT_H
-#define SM_FHOBJECT_H
-
-#include "SM_Object.h"
-
-class SM_FhObject : public SM_Object {
-public:
- virtual ~SM_FhObject();
- SM_FhObject(DT_ShapeHandle rayshape, MT_Vector3 ray, SM_Object *parent_object);
-
- const MT_Vector3& getRay() const { return m_ray; }
- MT_Point3 getSpot() const { return getPosition() + m_ray; }
- const MT_Vector3& getRayDirection() const { return m_ray_direction; }
- SM_Object *getParentObject() const { return m_parent_object; }
-
- static DT_Bool ray_hit(void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data);
-
-private:
- MT_Vector3 m_ray;
- MT_Vector3 m_ray_direction;
- SM_Object *m_parent_object;
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h
deleted file mode 100644
index fdc45af5225..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_MOTIONSTATE_H
-#define SM_MOTIONSTATE_H
-
-#include "MT_Transform.h"
-
-class SM_MotionState {
-public:
- SM_MotionState() :
- m_time(0.0),
- m_pos(0.0, 0.0, 0.0),
- m_orn(0.0, 0.0, 0.0, 1.0),
- m_lin_vel(0.0, 0.0, 0.0),
- m_ang_vel(0.0, 0.0, 0.0)
- {}
-
- void setPosition(const MT_Point3& pos) { m_pos = pos; }
- void setOrientation(const MT_Quaternion& orn) { m_orn = orn; }
- void setLinearVelocity(const MT_Vector3& lin_vel) { m_lin_vel = lin_vel; }
- void setAngularVelocity(const MT_Vector3& ang_vel) { m_ang_vel = ang_vel; }
- void setTime(MT_Scalar time) { m_time = time; }
-
- const MT_Point3& getPosition() const { return m_pos; }
- const MT_Quaternion& getOrientation() const { return m_orn; }
- const MT_Vector3& getLinearVelocity() const { return m_lin_vel; }
- const MT_Vector3& getAngularVelocity() const { return m_ang_vel; }
-
- MT_Scalar getTime() const { return m_time; }
-
- void integrateMidpoint(MT_Scalar timeStep, const SM_MotionState &prev_state, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel);
- void integrateBackward(MT_Scalar timeStep, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel);
- void integrateForward(MT_Scalar timeStep, const SM_MotionState &prev_state);
-
- void lerp(const SM_MotionState &prev, const SM_MotionState &next);
- void lerp(MT_Scalar t, const SM_MotionState &other);
-
- virtual MT_Transform getTransform() const {
- return MT_Transform(m_pos, m_orn);
- }
-
-protected:
- MT_Scalar m_time;
- MT_Point3 m_pos;
- MT_Quaternion m_orn;
- MT_Vector3 m_lin_vel;
- MT_Vector3 m_ang_vel;
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
deleted file mode 100644
index 2d748a0f251..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
+++ /dev/null
@@ -1,393 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_OBJECT_H
-#define SM_OBJECT_H
-
-#include <vector>
-
-#include <SOLID/SOLID.h>
-
-#include "SM_Callback.h"
-#include "SM_MotionState.h"
-#include <stdio.h>
-
-class SM_FhObject;
-
-/** Properties of dynamic objects */
-struct SM_ShapeProps {
- MT_Scalar m_mass; ///< Total mass
- MT_Scalar m_radius; ///< Bound sphere size
- MT_Vector3 m_inertia; ///< Inertia, should be a tensor some time
- MT_Scalar m_lin_drag; ///< Linear drag (air, water) 0 = concrete, 1 = vacuum
- MT_Scalar m_ang_drag; ///< Angular drag
- MT_Scalar m_friction_scaling[3]; ///< Scaling for anisotropic friction. Component in range [0, 1]
- bool m_do_anisotropic; ///< Should I do anisotropic friction?
- bool m_do_fh; ///< Should the object have a linear Fh spring?
- bool m_do_rot_fh; ///< Should the object have an angular Fh spring?
-};
-
-
-/** Properties of collidable objects (non-ghost objects) */
-struct SM_MaterialProps {
- MT_Scalar m_restitution; ///< restitution of energy after a collision 0 = inelastic, 1 = elastic
- MT_Scalar m_friction; ///< Coulomb friction (= ratio between the normal en maximum friction force)
- MT_Scalar m_fh_spring; ///< Spring constant (both linear and angular)
- MT_Scalar m_fh_damping; ///< Damping factor (linear and angular) in range [0, 1]
- MT_Scalar m_fh_distance; ///< The range above the surface where Fh is active.
- bool m_fh_normal; ///< Should the object slide off slopes?
-};
-
-class SM_ClientObject
-{
-public:
- SM_ClientObject() {}
- virtual ~SM_ClientObject() {}
-
- virtual bool hasCollisionCallback() = 0;
-};
-
-/**
- * SM_Object is an internal part of the Sumo physics engine.
- *
- * It encapsulates an object in the physics scene, and is responsible
- * for calculating the collision response of objects.
- */
-class SM_Object
-{
-public:
- SM_Object() ;
- SM_Object(
- DT_ShapeHandle shape,
- const SM_MaterialProps *materialProps,
- const SM_ShapeProps *shapeProps,
- SM_Object *dynamicParent
- );
- virtual ~SM_Object();
-
- bool isDynamic() const;
-
- /* nzc experimental. There seem to be two places where kinematics
- * are evaluated: proceedKinematic (called from SM_Scene) and
- * proceed() in this object. I'll just try and bunge these out for
- * now. */
-
- void suspend(void);
- void resume(void);
-
- void suspendDynamics();
-
- void restoreDynamics();
-
- bool isGhost() const;
-
- void suspendMaterial();
-
- void restoreMaterial();
-
- SM_FhObject *getFhObject() const;
-
- void registerCallback(SM_Callback& callback);
-
- void calcXform();
- void notifyClient();
- void updateInvInertiaTensor();
-
-
- // Save the current state information for use in the
- // velocity computation in the next frame.
-
- void proceedKinematic(MT_Scalar timeStep);
-
- void saveReactionForce(MT_Scalar timeStep) ;
-
- void clearForce() ;
-
- void clearMomentum() ;
-
- void setMargin(MT_Scalar margin) ;
-
- MT_Scalar getMargin() const ;
-
- const SM_MaterialProps *getMaterialProps() const ;
-
- const SM_ShapeProps *getShapeProps() const ;
-
- void setPosition(const MT_Point3& pos);
- void setOrientation(const MT_Quaternion& orn);
- void setScaling(const MT_Vector3& scaling);
-
- /**
- * set an external velocity. This velocity complements
- * the physics velocity. So setting it does not override the
- * physics velocity. It is your responsibility to clear
- * this external velocity. This velocity is not subject to
- * friction or damping.
- */
- void setExternalLinearVelocity(const MT_Vector3& lin_vel) ;
- void addExternalLinearVelocity(const MT_Vector3& lin_vel) ;
-
- /** Override the physics velocity */
- void addLinearVelocity(const MT_Vector3& lin_vel);
- void setLinearVelocity(const MT_Vector3& lin_vel);
-
- /**
- * Set an external angular velocity. This velocity complemetns
- * the physics angular velocity so does not override it. It is
- * your responsibility to clear this velocity. This velocity
- * is not subject to friction or damping.
- */
- void setExternalAngularVelocity(const MT_Vector3& ang_vel) ;
- void addExternalAngularVelocity(const MT_Vector3& ang_vel);
-
- /** Override the physics angular velocity */
- void addAngularVelocity(const MT_Vector3& ang_vel);
- void setAngularVelocity(const MT_Vector3& ang_vel);
-
- /** Clear the external velocities */
- void clearCombinedVelocities();
-
- /**
- * Tell the physics system to combine the external velocity
- * with the physics velocity.
- */
- void resolveCombinedVelocities(
- const MT_Vector3 & lin_vel,
- const MT_Vector3 & ang_vel
- ) ;
-
-
-
- MT_Scalar getInvMass() const;
-
- const MT_Vector3& getInvInertia() const ;
-
- const MT_Matrix3x3& getInvInertiaTensor() const;
-
- void applyForceField(const MT_Vector3& accel) ;
-
- void applyCenterForce(const MT_Vector3& force) ;
-
- void applyTorque(const MT_Vector3& torque) ;
-
- /**
- * Apply an impulse to the object. The impulse will be split into
- * angular and linear components.
- * @param attach point to apply the impulse to (in world coordinates)
- */
- void applyImpulse(const MT_Point3& attach, const MT_Vector3& impulse) ;
-
- /**
- * Applies an impulse through the center of this object. (ie the angular
- * velocity will not change.
- */
- void applyCenterImpulse(const MT_Vector3& impulse);
- /**
- * Applies an angular impulse.
- */
- void applyAngularImpulse(const MT_Vector3& impulse);
-
- MT_Point3 getWorldCoord(const MT_Point3& local) const;
- MT_Point3 getLocalCoord(const MT_Point3& world) const;
-
- MT_Vector3 getVelocity(const MT_Point3& local) const;
-
-
- const MT_Vector3& getReactionForce() const ;
-
- void getMatrix(double *m) const ;
-
- const double *getMatrix() const ;
-
- // Still need this???
- const MT_Transform& getScaledTransform() const;
-
- DT_ObjectHandle getObjectHandle() const ;
- DT_ShapeHandle getShapeHandle() const ;
-
- SM_Object *getDynamicParent() ;
-
- void integrateForces(MT_Scalar timeStep);
- void integrateMomentum(MT_Scalar timeSteo);
-
- void setRigidBody(bool is_rigid_body) ;
-
- bool isRigidBody() const ;
-
- // This is the callback for handling collisions of dynamic objects
- static
- DT_Bool
- boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
- );
-
- static
- DT_Bool
- fix(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
- );
-
-
- SM_ClientObject *getClientObject() { return m_client_object; }
- void setClientObject(SM_ClientObject *client_object) { m_client_object = client_object; }
- void setPhysicsClientObject(void* physicsClientObject)
- {
- m_physicsClientObject = physicsClientObject;
- }
- void* getPhysicsClientObject() {
- return m_physicsClientObject;
- }
- void relax();
-
- SM_MotionState &getCurrentFrame();
- SM_MotionState &getPreviousFrame();
- SM_MotionState &getNextFrame();
-
- const SM_MotionState &getCurrentFrame() const;
- const SM_MotionState &getPreviousFrame() const;
- const SM_MotionState &getNextFrame() const;
-
- // Motion state functions
- const MT_Point3& getPosition() const;
- const MT_Quaternion& getOrientation() const;
- const MT_Vector3& getLinearVelocity() const;
- const MT_Vector3& getAngularVelocity() const;
-
- MT_Scalar getTime() const;
-
- void setTime(MT_Scalar time);
-
- void interpolate(MT_Scalar timeStep);
- void endFrame();
-
-private:
- friend class Contact;
- // Tweak parameters
- static MT_Scalar ImpulseThreshold;
-
- // return the actual linear_velocity of this object this
- // is the addition of m_combined_lin_vel and m_lin_vel.
-
- const
- MT_Vector3
- actualLinVelocity(
- ) const ;
-
- const
- MT_Vector3
- actualAngVelocity(
- ) const ;
-
- void dynamicCollision(const MT_Point3 &local2,
- const MT_Vector3 &normal,
- MT_Scalar dist,
- const MT_Vector3 &rel_vel,
- MT_Scalar restitution,
- MT_Scalar friction_factor,
- MT_Scalar invMass
- );
-
- typedef std::vector<SM_Callback *> T_CallbackList;
-
-
- T_CallbackList m_callbackList; // Each object can have multiple callbacks from the client (=game engine)
- SM_Object *m_dynamicParent; // Collisions between parent and children are ignored
-
- // as the collision callback now has only information
- // on an SM_Object, there must be a way that the SM_Object client
- // can identify it's clientdata after a collision
- SM_ClientObject *m_client_object;
-
- void* m_physicsClientObject;
-
- DT_ShapeHandle m_shape; // Shape for collision detection
-
- // Material and shape properties are not owned by this class.
-
- const SM_MaterialProps *m_materialProps;
- const SM_MaterialProps *m_materialPropsBackup; // Backup in case the object temporarily becomes a ghost.
- const SM_ShapeProps *m_shapeProps;
- const SM_ShapeProps *m_shapePropsBackup; // Backup in case the object's dynamics is temporarily suspended
- DT_ObjectHandle m_object; // A handle to the corresponding object in SOLID.
- MT_Scalar m_margin; // Offset for the object's shape (also for collision detection)
- MT_Vector3 m_scaling; // Non-uniform scaling of the object's shape
-
- double m_ogl_matrix[16]; // An OpenGL-type 4x4 matrix
- MT_Transform m_xform; // The object's local coordinate system
- MT_Transform m_prev_xform; // The object's local coordinate system in the previous frame
- SM_MotionState m_prev_state; // The object's motion state in the previous frame
- MT_Scalar m_timeStep; // The duration of the last frame
-
- MT_Vector3 m_reaction_impulse; // The accumulated impulse resulting from collisions
- MT_Vector3 m_reaction_force; // The reaction force derived from the reaction impulse
-
- MT_Vector3 m_lin_mom; // Linear momentum (linear velocity times mass)
- MT_Vector3 m_ang_mom; // Angular momentum (angualr velocity times inertia)
- MT_Vector3 m_force; // Force on center of mass (afffects linear momentum)
- MT_Vector3 m_torque; // Torque around center of mass (affects angular momentum)
-
- SM_MotionState m_frames[3];
-
- MT_Vector3 m_error; // Error in position:- amount object must be moved to prevent intersection with scene
-
- // Here are the values of externally set linear and angular
- // velocity. These are updated from the outside
- // (actuators and python) each frame and combined with the
- // physics values. At the end of each frame (at the end of a
- // call to proceed) they are set to zero. This allows the
- // outside world to contribute to the velocity of an object
- // but still have it react to physics.
-
- MT_Vector3 m_combined_lin_vel;
- MT_Vector3 m_combined_ang_vel;
-
- // The force and torque are the accumulated forces and torques applied by the client (game logic, python).
-
- SM_FhObject *m_fh_object; // The ray object used for Fh
- bool m_suspended; // Is this object frozen?
-
- // Mass properties
- MT_Scalar m_inv_mass; // 1/mass
- MT_Vector3 m_inv_inertia; // [1/inertia_x, 1/inertia_y, 1/inertia_z]
- MT_Matrix3x3 m_inv_inertia_tensor; // Inverse Inertia Tensor
-
- bool m_kinematic; // Have I been displaced (translated, rotated, scaled) in this frame?
- bool m_prev_kinematic; // Have I been displaced (translated, rotated, scaled) in the previous frame?
- bool m_is_rigid_body; // Should friction give me a change in angular momentum?
- int m_static; // temporarily static.
-
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h
deleted file mode 100644
index 81b4cb55b45..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_PROPSH
-#define SM_PROPSH
-
-#include <MT_Scalar.h>
-
-// Properties of dynamic objects
-struct SM_ShapeProps {
- MT_Scalar m_mass; // Total mass
- MT_Scalar m_inertia; // Inertia, should be a tensor some time
- MT_Scalar m_lin_drag; // Linear drag (air, water) 0 = concrete, 1 = vacuum
- MT_Scalar m_ang_drag; // Angular drag
- MT_Scalar m_friction_scaling[3]; // Scaling for anisotropic friction. Component in range [0, 1]
- bool m_do_anisotropic; // Should I do anisotropic friction?
- bool m_do_fh; // Should the object have a linear Fh spring?
- bool m_do_rot_fh; // Should the object have an angular Fh spring?
-};
-
-
-// Properties of collidable objects (non-ghost objects)
-struct SM_MaterialProps {
- MT_Scalar m_restitution; // restitution of energie after a collision 0 = inelastic, 1 = elastic
- MT_Scalar m_friction; // Coulomb friction (= ratio between the normal en maximum friction force)
- MT_Scalar m_fh_spring; // Spring constant (both linear and angular)
- MT_Scalar m_fh_damping; // Damping factor (linear and angular) in range [0, 1]
- MT_Scalar m_fh_distance; // The range above the surface where Fh is active.
- bool m_fh_normal; // Should the object slide off slopes?
-};
-
-#endif //SM_PROPSH
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
deleted file mode 100644
index 3d8eef2bae0..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * $Id$
- * Copyright (C) 2001 NaN Technologies B.V.
- * The physics scene.
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef SM_SCENE_H
-#define SM_SCENE_H
-
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#endif
-
-#include <vector>
-#include <set>
-#include <utility> //needed for pair
-
-#include <SOLID/SOLID.h>
-
-#include "MT_Vector3.h"
-#include "MT_Point3.h"
-
-#include "SM_Object.h"
-
-enum
-{
- FH_RESPONSE,
- SENSOR_RESPONSE, /* Touch Sensors */
- CAMERA_RESPONSE, /* Visibility Culling */
- OBJECT_RESPONSE, /* Object Dynamic Geometry Response */
- STATIC_RESPONSE, /* Static Geometry Response */
-
- NUM_RESPONSE
-};
-
-class SM_Scene {
-public:
- SM_Scene();
-
- ~SM_Scene();
-
- DT_RespTableHandle getRespTableHandle() const {
- return m_respTable;
- }
-
- const MT_Vector3& getForceField() const {
- return m_forceField;
- }
-
- MT_Vector3& getForceField() {
- return m_forceField;
- }
-
- void setForceField(const MT_Vector3& forceField) {
- m_forceField = forceField;
- }
-
- void addTouchCallback(int response_class, DT_ResponseCallback callback, void *user);
-
- void addSensor(SM_Object& object);
- void add(SM_Object& object);
- void remove(SM_Object& object);
-
- void notifyCollision(SM_Object *obj1, SM_Object *obj2);
-
- void setSecondaryRespTable(DT_RespTableHandle secondaryRespTable);
- DT_RespTableHandle getSecondaryRespTable() { return m_secondaryRespTable; }
-
- void requestCollisionCallback(SM_Object &object);
-
- void beginFrame();
- void endFrame();
-
- // Perform an integration step of duration 'timeStep'.
- // 'subSampling' is the maximum duration of a substep, i.e.,
- // The maximum time interval between two collision checks.
- // 'subSampling' can be used to control aliasing effects
- // (fast moving objects traversing through walls and such).
- bool proceed(MT_Scalar curtime, MT_Scalar ticrate);
- void proceed(MT_Scalar subStep);
-
- /**
- * Test whether any objects lie on the line defined by from and
- * to. The search returns the first such bject starting at from,
- * or NULL if there was none.
- * @returns A reference to the object, or NULL if there was none.
- * @param ignore_client Do not look for collisions with this
- * object. This can be useful to avoid self-hits if
- * starting from the location of an object.
- * @param from The start point, in world coordinates, of the search.
- * @param to The end point, in world coordinates, of the search.
- * @param result A store to return the point where intersection
- * took place (if there was an intersection).
- * @param normal A store to return the normal of the hit object on
- * the location of the intersection, if it took place.
- */
- SM_Object *rayTest(void *ignore_client,
- const MT_Point3& from, const MT_Point3& to,
- MT_Point3& result, MT_Vector3& normal) const;
-
-private:
-
- // Clear the user set velocities.
- void clearObjectCombinedVelocities();
- // This is the callback for handling collisions of dynamic objects
- static
- DT_Bool
- boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
- );
-
- /** internal type */
- typedef std::vector<SM_Object *> T_ObjectList;
-
- /** Handle to the scene in SOLID */
- DT_SceneHandle m_scene;
- /** Following response table contains the callbacks for the dynmics */
- DT_RespTableHandle m_respTable;
- DT_ResponseClass m_ResponseClass[NUM_RESPONSE];
- /**
- * Following response table contains callbacks for the client (=
- * game engine) */
- DT_RespTableHandle m_secondaryRespTable; // Handle
- DT_ResponseClass m_secondaryResponseClass[NUM_RESPONSE];
-
- /**
- * Following resposne table contains callbacks for fixing the simulation
- * ie making sure colliding objects do not intersect.
- */
- DT_RespTableHandle m_fixRespTable;
- DT_ResponseClass m_fixResponseClass[NUM_RESPONSE];
-
- /** The acceleration from the force field */
- MT_Vector3 m_forceField;
-
- /**
- * The list of objects that receive motion updates and do
- * collision tests. */
- T_ObjectList m_objectList;
-
- unsigned int m_frames;
-};
-
-#endif
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile b/source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile
deleted file mode 100644
index 672dff39028..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/sample/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# $Id$
-# Copyright (C) 2001 NaN Technologies B.V.
-
-DIR = $(OCGDIR)/sumo
-ALLTARGETS = $(OBJS) $(DIR)/$(DEBUG_DIR)particle $(DIR)/$(DEBUG_DIR)particle0
-
-include nan_compile.mk
-
-CPPFLAGS = -I../../include -I../include -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(OPENGL_HEADERS)
-
-clean::
- @$(RM) $(DIR)/particle $(DIR)/particle0
- @$(RM) $(DIR)/debug/particle $(DIR)/debug/particle0
-
-LDFLAGS = -L$(DIR) -L/usr/X11R6/lib
-OGL_LDLIBS = -lglut -lGLU -lGL -pthread
-LDLIBS = -lfuzzics -lsolid $(NAN_MOTO)/lib/libmoto.a $(OGL_LDLIBS)
-
-$(DIR)/$(DEBUG_DIR)particle: particle.o $(DIR)/$(DEBUG_DIR)libfuzzics.a $(DIR)/$(DEBUG_DIR)libsolid.a
- $(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
-
-$(DIR)/$(DEBUG_DIR)particle0: particle0.o $(DIR)/$(DEBUG_DIR)libfuzzics.a $(DIR)/$(DEBUG_DIR)libsolid.a
- $(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ $(LDLIBS)
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp b/source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp
deleted file mode 100644
index d7aca326b42..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle.cpp
+++ /dev/null
@@ -1,709 +0,0 @@
-//#define FAKE_IT
-#define USE_COMPLEX
-#define QUADS
-
-#include <algorithm>
-#include <new>
-#include <GL/glut.h>
-
-#include "MT_MinMax.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-#include "MT_Quaternion.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Transform.h"
-
-#include "SM_Object.h"
-#include "SM_FhObject.h"
-#include "SM_Scene.h"
-
-#include <SOLID/SOLID.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-const MT_Scalar bowl_curv = 0.10;
-const MT_Scalar timeStep = 0.02;
-const MT_Scalar ground_margin = 0.0;
-const MT_Scalar sphere_radius = 0.5;
-
-const MT_Vector3 gravity(0, -9.8, 0);
-
-static MT_Scalar DISTANCE = 5;
-
-static MT_Scalar ele = 0, azi = 0;
-static MT_Point3 eye(0, 0, DISTANCE);
-static MT_Point3 center(0, 0, 0);
-
-inline double irnd() { return 2 * MT_random() - 1; }
-
-static const double SCALE_BOTTOM = 0.5;
-static const double SCALE_FACTOR = 2.0;
-
-SM_ShapeProps g_shapeProps = {
- 1.0, // mass
- 1.0, // inertia
- 0.1, // linear drag
- 0.1, // angular drag
- { 1.0, 0.0, 0.0 }, // anisotropic friction
- false, // do anisotropic friction?
- true, // do fh?
- true // do rot fh?
-};
-
-SM_MaterialProps g_materialProps = {
- 0.7, // restitution
- 0.0, // friction
- 10.0, // Fh spring constant
- 1.0, // Fh damping
- 0.5, // Fh distance
- true // Fh leveling
-};
-
-
-void toggleIdle();
-
-
-void newRandom();
-
-void coordSystem() {
- glDisable(GL_LIGHTING);
- glBegin(GL_LINES);
- glColor3f(1, 0, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(10, 0, 0);
- glColor3f(0, 1, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 10, 0);
- glColor3f(0, 0, 1);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 0, 10);
- glEnd();
- glEnable(GL_LIGHTING);
-}
-
-
-void display_bbox(const MT_Point3& min, const MT_Point3& max) {
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(0, 1, 1);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- glBegin(GL_QUAD_STRIP);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glVertex3d(max[0], min[1], min[2]);
- glVertex3d(max[0], min[1], max[2]);
- glVertex3d(max[0], max[1], min[2]);
- glVertex3d(max[0], max[1], max[2]);
- glVertex3d(min[0], max[1], min[2]);
- glVertex3d(min[0], max[1], max[2]);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glEnd();
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-}
-
-
-
-
-class GLShape {
-public:
- virtual void paint(GLdouble *m) const = 0;
-};
-
-
-class GLSphere : public GLShape {
- MT_Scalar radius;
-public:
- GLSphere(MT_Scalar r) : radius(r) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glutSolidSphere(radius, 20, 20);
- glPopMatrix();
- }
-};
-
-
-class GLBox : public GLShape {
- MT_Vector3 extent;
-public:
- GLBox(MT_Scalar x, MT_Scalar y, MT_Scalar z) :
- extent(x, y, z) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glPushMatrix();
- glScaled(extent[0], extent[1], extent[2]);
- glutSolidCube(1.0);
- glPopMatrix();
- glPopMatrix();
- }
-};
-
-
-class GLCone : public GLShape {
- MT_Scalar bottomRadius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCone(MT_Scalar r, MT_Scalar h) :
- bottomRadius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, bottomRadius, 0, height, 15, 10);
- glPopMatrix();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class GLCylinder : public GLShape {
- MT_Scalar radius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCylinder(MT_Scalar r, MT_Scalar h) :
- radius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, radius, radius, height, 15, 10);
- glPopMatrix ();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class Object;
-
-class Callback : public SM_Callback {
-public:
- Callback(Object& object) : m_object(object) {}
-
- virtual void do_me();
-
-private:
- Object& m_object;
-};
-
-
-class Object {
-public:
- Object(GLShape *gl_shape, SM_Object& object) :
- m_gl_shape(gl_shape),
- m_object(object),
- m_callback(*this)
- {
- m_object.registerCallback(m_callback);
- }
-
- ~Object() {}
-
- void paint() {
- if (m_gl_shape) {
- m_gl_shape->paint(m);
- // display_bbox(m_bbox.lower(), m_bbox.upper());
- }
- }
-
- void print_reaction_force() const {
- std::cout << m_object.getReactionForce() << std::endl;
- }
-
- MT_Vector3 getAhead() {
- return MT_Vector3(&m[4]);
- }
-
- MT_Vector3 getUp() {
- return MT_Vector3(&m[8]);
- }
-
- void clearMomentum() {
- m_object.clearMomentum();
- }
-
- void setMargin(MT_Scalar margin) {
- m_object.setMargin(margin);
- }
-
- void setScaling(const MT_Vector3& scaling) {
- m_object.setScaling(scaling);
- }
-
- const MT_Point3& getPosition() {
- return m_object.getPosition();
- }
-
- void setPosition(const MT_Point3& pos) {
- m_object.setPosition(pos);
- }
-
- void setOrientation(const MT_Quaternion& orn) {
- m_object.setOrientation(orn);
- }
-
- void applyCenterForce(const MT_Vector3& force) {
- m_object.applyCenterForce(force);
- }
-
- void applyTorque(const MT_Vector3& torque) {
- m_object.applyTorque(torque);
- }
-
- MT_Point3 getWorldCoord(const MT_Point3& local) const {
- return m_object.getWorldCoord(local);
- }
-
- MT_Vector3 getLinearVelocity() const {
- return m_object.getLinearVelocity();
- }
-
- MT_Vector3 getAngularVelocity() const {
- return m_object.getAngularVelocity();
- }
-
- void setMatrix() {
- m_object.calcXform();
- m_object.getMatrix(m);
- }
-
- const double *getMatrix() {
- m_object.calcXform();
- return m_object.getMatrix();
- }
-
-private:
- GLShape *m_gl_shape;
- SM_Object& m_object;
- DT_Scalar m[16];
- Callback m_callback;
-};
-
-
-
-const MT_Scalar SPACE_SIZE = 2;
-
-static GLSphere gl_sphere(sphere_radius);
-static GLBox gl_ground(50.0, 0.0, 50.0);
-
-
-
-#ifdef USE_COMPLEX
-
-const int GRID_SCALE = 10;
-const MT_Scalar GRID_UNIT = 25.0 / GRID_SCALE;
-
-DT_ShapeHandle createComplex() {
- DT_ShapeHandle shape = DT_NewComplexShape();
- for (int i0 = -GRID_SCALE; i0 != GRID_SCALE; ++i0) {
- for (int j0 = -GRID_SCALE; j0 != GRID_SCALE; ++j0) {
- int i1 = i0 + 1;
- int j1 = j0 + 1;
-#ifdef QUADS
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j0);
- DT_End();
-#else
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_End();
-
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j0);
- DT_End();
-#endif
-
- }
- }
- DT_EndComplexShape();
- return shape;
-}
-
-
-static DT_ShapeHandle ground_shape = createComplex();
-
-#else
-
-static DT_ShapeHandle ground_shape = DT_Box(50, 0, 50);
-
-#endif
-
-static SM_Object sm_ground(ground_shape, &g_materialProps, 0, 0);
-static Object ground(&gl_ground, sm_ground);
-
-static SM_Object sm_sphere(DT_Sphere(0.0), &g_materialProps, &g_shapeProps, 0);
-static Object object(&gl_sphere, sm_sphere);
-
-
-static SM_Scene g_scene;
-
-
-bool g_hit = false;
-MT_Point3 g_spot;
-MT_Vector3 g_normal;
-
-
-void Callback::do_me()
-{
- m_object.setMatrix();
- m_object.print_reaction_force();
-}
-
-void myinit(void) {
-
- GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
- GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
- GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
-
- /* light_position is NOT default value */
- GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
- GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
-
- glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
-
- glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
-
-
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnable(GL_LIGHT1);
-
- glShadeModel(GL_SMOOTH);
-
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
-
- // glEnable(GL_CULL_FACE);
- // glCullFace(GL_BACK);
-
- ground.setPosition(MT_Point3(0, -10, 0));
- ground.setOrientation(MT_Quaternion(0, 0, 0, 1));
- ground.setMatrix();
- center.setValue(0.0, 0.0, 0.0);
- sm_ground.setMargin(ground_margin);
-
- g_scene.setForceField(gravity);
- g_scene.add(sm_ground);
-
- object.setMargin(sphere_radius);
-
- g_scene.add(sm_sphere);
-
-
- newRandom();
-}
-
-
-//MT_Point3 cp1, cp2;
-//bool intersection;
-
-void display(void) {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- ground.paint();
- object.paint();
-
- if (g_hit) {
- glDisable(GL_LIGHTING);
- glColor3f(1, 0, 0);
-
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(g_spot[0], g_spot[1], g_spot[2]);
- glEnd();
- glPointSize(1);
-
- glColor3f(1, 1, 0);
- glBegin(GL_LINES);
- glVertex3d(g_spot[0], g_spot[1], g_spot[2]);
- glVertex3d(g_spot[0] + g_normal[0],
- g_spot[1] + g_normal[1],
- g_spot[2] + g_normal[2]);
- glEnd();
- glEnable(GL_LIGHTING);
- }
-
-
-
-#ifdef COLLISION
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(1, 1, 0);
- if (intersection) {
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glEnd();
- glPointSize(1);
- }
- else {
- glBegin(GL_LINES);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glVertex3d(cp2[0], cp2[1], cp2[2]);
- glEnd();
- }
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-#endif
-
- glFlush();
- glutSwapBuffers();
-}
-
-
-
-
-
-void newRandom() {
- object.setPosition(MT_Point3(0, 0, 0));
- object.setOrientation(MT_Quaternion::random());
- object.clearMomentum();
- object.setMatrix();
-
- display();
-}
-
-void moveAndDisplay() {
- g_scene.proceed(timeStep, 0.01);
-
- display();
- g_hit = false;
-}
-
-
-void turn_left() {
- object.applyTorque(5.0 * object.getUp());
-}
-
-void turn_right() {
- object.applyTorque(-5.0 * object.getUp());
-}
-
-void forward() {
- object.applyCenterForce(10.0 * object.getAhead());
-}
-
-void backward() {
- object.applyCenterForce(-10.0 * object.getAhead());
-}
-
-void jump() {
- object.applyCenterForce(MT_Vector3(0.0, 200.0, 0.0));
-}
-
-
-void toggleIdle() {
- static bool idle = true;
- if (idle) {
- glutIdleFunc(moveAndDisplay);
- idle = false;
- }
- else {
- glutIdleFunc(NULL);
- idle = true;
- }
-}
-
-
-void setCamera() {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 200.0);
- MT_Scalar rele = MT_radians(ele);
- MT_Scalar razi = MT_radians(azi);
- eye.setValue(DISTANCE * sin(razi) * cos(rele),
- DISTANCE * sin(rele),
- DISTANCE * cos(razi) * cos(rele));
- gluLookAt(eye[0], eye[1], eye[2],
- center[0], center[1], center[2],
- 0, 1, 0);
- glMatrixMode(GL_MODELVIEW);
- display();
-}
-
-const MT_Scalar STEPSIZE = 5;
-
-void stepLeft() { azi -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void stepRight() { azi += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepFront() { ele += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepBack() { ele -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void zoomIn() { DISTANCE -= 1; setCamera(); }
-void zoomOut() { DISTANCE += 1; setCamera(); }
-
-
-void myReshape(int w, int h) {
- glViewport(0, 0, w, h);
- setCamera();
-}
-
-void myKeyboard(unsigned char key, int x, int y)
-{
- switch (key)
- {
- case 'w': forward(); break;
- case 's': backward(); break;
- case 'a': turn_left(); break;
- case 'd': turn_right(); break;
- case 'e': jump(); break;
- case 'l' : stepLeft(); break;
- case 'r' : stepRight(); break;
- case 'f' : stepFront(); break;
- case 'b' : stepBack(); break;
- case 'z' : zoomIn(); break;
- case 'x' : zoomOut(); break;
- case 'i' : toggleIdle(); break;
- case ' ' : newRandom(); break;
- default:
-// std::cout << "unused key : " << key << std::endl;
- break;
- }
-}
-
-void mySpecial(int key, int x, int y)
-{
- switch (key)
- {
- case GLUT_KEY_LEFT : stepLeft(); break;
- case GLUT_KEY_RIGHT : stepRight(); break;
- case GLUT_KEY_UP : stepFront(); break;
- case GLUT_KEY_DOWN : stepBack(); break;
- case GLUT_KEY_PAGE_UP : zoomIn(); break;
- case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
- case GLUT_KEY_HOME : toggleIdle(); break;
- default:
-// std::cout << "unused (special) key : " << key << std::endl;
- break;
- }
-}
-
-void goodbye( void)
-{
- g_scene.remove(sm_ground);
- g_scene.remove(sm_sphere);
-
- std::cout << "goodbye ..." << std::endl;
- exit(0);
-}
-
-void menu(int choice)
-{
-
- static int fullScreen = 0;
- static int px, py, sx, sy;
-
- switch(choice) {
- case 1:
- if (fullScreen == 1) {
- glutPositionWindow(px,py);
- glutReshapeWindow(sx,sy);
- glutChangeToMenuEntry(1,"Full Screen",1);
- fullScreen = 0;
- } else {
- px=glutGet((GLenum)GLUT_WINDOW_X);
- py=glutGet((GLenum)GLUT_WINDOW_Y);
- sx=glutGet((GLenum)GLUT_WINDOW_WIDTH);
- sy=glutGet((GLenum)GLUT_WINDOW_HEIGHT);
- glutFullScreen();
- glutChangeToMenuEntry(1,"Close Full Screen",1);
- fullScreen = 1;
- }
- break;
- case 2:
- toggleIdle();
- break;
- case 3:
- goodbye();
- break;
- default:
- break;
- }
-}
-
-void createMenu()
-{
- glutCreateMenu(menu);
- glutAddMenuEntry("Full Screen", 1);
- glutAddMenuEntry("Toggle Idle (Start/Stop)", 2);
- glutAddMenuEntry("Quit", 3);
- glutAttachMenu(GLUT_RIGHT_BUTTON);
-}
-
-int main(int argc, char **argv) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(500, 500);
- glutCreateWindow("Physics demo");
-
- myinit();
- glutKeyboardFunc(myKeyboard);
- glutSpecialFunc(mySpecial);
- glutReshapeFunc(myReshape);
- createMenu();
- glutIdleFunc(NULL);
-
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
-}
-
-
-
-
-
-
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp b/source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp
deleted file mode 100644
index cdf0a2d8f64..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/sample/particle0.cpp
+++ /dev/null
@@ -1,695 +0,0 @@
-//#define FAKE_IT
-#define USE_COMPLEX
-#define QUADS
-
-#include <algorithm>
-#include <new>
-#include <GL/glut.h>
-
-#include "MT_MinMax.h"
-#include "MT_Point3.h"
-#include "MT_Vector3.h"
-#include "MT_Quaternion.h"
-#include "MT_Matrix3x3.h"
-#include "MT_Transform.h"
-
-#include "SM_Object.h"
-#include "SM_Scene.h"
-
-#include "solid.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-const MT_Scalar bowl_curv = 0.10;
-const MT_Scalar timeStep = 0.04;
-const MT_Scalar ground_margin = 0.0;
-const MT_Scalar sphere_radius = 0.5;
-
-const MT_Vector3 gravity(0, -9.8, 0);
-
-static MT_Scalar DISTANCE = 5;
-
-static MT_Scalar ele = 0, azi = 0;
-static MT_Point3 eye(0, 0, DISTANCE);
-static MT_Point3 center(0, 0, 0);
-
-inline double irnd() { return 2 * MT_random() - 1; }
-
-static const double SCALE_BOTTOM = 0.5;
-static const double SCALE_FACTOR = 2.0;
-
-SM_ShapeProps g_shapeProps = {
- 1.0, // mass
- 1.0, // inertia
- 0.9, // linear drag
- 0.9 // angular drag
-};
-
-SM_MaterialProps g_materialProps = {
- 0.7, // restitution
- 0.0, // friction
- 0.0, // spring constant
- 0.0 // damping
-};
-
-
-void toggleIdle();
-
-
-void newRandom();
-
-void coordSystem() {
- glDisable(GL_LIGHTING);
- glBegin(GL_LINES);
- glColor3f(1, 0, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(10, 0, 0);
- glColor3f(0, 1, 0);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 10, 0);
- glColor3f(0, 0, 1);
- glVertex3d(0, 0, 0);
- glVertex3d(0, 0, 10);
- glEnd();
- glEnable(GL_LIGHTING);
-}
-
-
-void display_bbox(const MT_Point3& min, const MT_Point3& max) {
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(0, 1, 1);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- glBegin(GL_QUAD_STRIP);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glVertex3d(max[0], min[1], min[2]);
- glVertex3d(max[0], min[1], max[2]);
- glVertex3d(max[0], max[1], min[2]);
- glVertex3d(max[0], max[1], max[2]);
- glVertex3d(min[0], max[1], min[2]);
- glVertex3d(min[0], max[1], max[2]);
- glVertex3d(min[0], min[1], min[2]);
- glVertex3d(min[0], min[1], max[2]);
- glEnd();
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-}
-
-
-
-
-class GLShape {
-public:
- virtual void paint(GLdouble *m) const = 0;
-};
-
-
-class GLSphere : public GLShape {
- MT_Scalar radius;
-public:
- GLSphere(MT_Scalar r) : radius(r) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glutSolidSphere(radius, 20, 20);
- glPopMatrix();
- }
-};
-
-
-class GLBox : public GLShape {
- MT_Vector3 extent;
-public:
- GLBox(MT_Scalar x, MT_Scalar y, MT_Scalar z) :
- extent(x, y, z) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- glPushMatrix();
- glScaled(extent[0], extent[1], extent[2]);
- glutSolidCube(1.0);
- glPopMatrix();
- glPopMatrix();
- }
-};
-
-
-class GLCone : public GLShape {
- MT_Scalar bottomRadius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCone(MT_Scalar r, MT_Scalar h) :
- bottomRadius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, bottomRadius, 0, height, 15, 10);
- glPopMatrix();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class GLCylinder : public GLShape {
- MT_Scalar radius;
- MT_Scalar height;
- mutable GLuint displayList;
-
-public:
- GLCylinder(MT_Scalar r, MT_Scalar h) :
- radius(r),
- height(h),
- displayList(0) {}
-
- void paint(GLdouble *m) const {
- glPushMatrix();
- glLoadMatrixd(m);
- coordSystem();
- if (displayList) glCallList(displayList);
- else {
- GLUquadricObj *quadObj = gluNewQuadric();
- displayList = glGenLists(1);
- glNewList(displayList, GL_COMPILE_AND_EXECUTE);
- glPushMatrix();
- glRotatef(-90.0, 1.0, 0.0, 0.0);
- glTranslatef(0.0, 0.0, -1.0);
- gluQuadricDrawStyle(quadObj, (GLenum)GLU_FILL);
- gluQuadricNormals(quadObj, (GLenum)GLU_SMOOTH);
- gluCylinder(quadObj, radius, radius, height, 15, 10);
- glPopMatrix ();
- glEndList();
- }
- glPopMatrix();
- }
-};
-
-class Object;
-
-class Callback : public SM_Callback {
-public:
- Callback(Object& object) : m_object(object) {}
-
- virtual void do_me();
-
-private:
- Object& m_object;
-};
-
-
-class Object {
-public:
- Object(GLShape *gl_shape, SM_Object& object) :
- m_gl_shape(gl_shape),
- m_object(object),
- m_callback(*this)
- {
- m_object.registerCallback(m_callback);
- }
-
- ~Object() {}
-
- void paint() {
- m_gl_shape->paint(m);
- // display_bbox(m_bbox.lower(), m_bbox.upper());
- }
-
- MT_Vector3 getAhead() {
- return MT_Vector3(-m[8], -m[9], -m[10]);
- }
-
- void clearMomentum() {
- m_object.clearMomentum();
- }
-
- void setMargin(MT_Scalar margin) {
- m_object.setMargin(margin);
- }
-
- void setScaling(const MT_Vector3& scaling) {
- m_object.setScaling(scaling);
- }
-
- void setPosition(const MT_Point3& pos) {
- m_object.setPosition(pos);
- }
-
- void setOrientation(const MT_Quaternion& orn) {
- m_object.setOrientation(orn);
- }
-
- void applyCenterForce(const MT_Vector3& force) {
- m_object.applyCenterForce(force);
- }
-
- void applyTorque(const MT_Vector3& torque) {
- m_object.applyTorque(torque);
- }
-
- MT_Point3 getWorldCoord(const MT_Point3& local) const {
- return m_object.getWorldCoord(local);
- }
-
- MT_Vector3 getLinearVelocity() const {
- return m_object.getLinearVelocity();
- }
-
- void setMatrix() {
- m_object.getMatrix(m);
- }
-
-private:
- GLShape *m_gl_shape;
- SM_Object& m_object;
- DT_Scalar m[16];
- Callback m_callback;
-};
-
-
-void Callback::do_me()
-{
- m_object.setMatrix();
-}
-
-
-const MT_Scalar SPACE_SIZE = 2;
-
-static GLSphere gl_sphere(sphere_radius);
-static GLBox gl_ground(50.0, 0.0, 50.0);
-
-
-
-#ifdef USE_COMPLEX
-
-const int GRID_SCALE = 10;
-const MT_Scalar GRID_UNIT = 25.0 / GRID_SCALE;
-
-DT_ShapeHandle createComplex() {
- DT_ShapeHandle shape = DT_NewComplexShape();
- for (int i0 = -GRID_SCALE; i0 != GRID_SCALE; ++i0) {
- for (int j0 = -GRID_SCALE; j0 != GRID_SCALE; ++j0) {
- int i1 = i0 + 1;
- int j1 = j0 + 1;
-#ifdef QUADS
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, bowl_curv * i0*i0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, bowl_curv * i1*i1, GRID_UNIT * j0);
- DT_End();
-#else
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j0);
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_End();
-
- DT_Begin();
- DT_Vertex(GRID_UNIT * i0, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j1);
- DT_Vertex(GRID_UNIT * i1, 0, GRID_UNIT * j0);
- DT_End();
-#endif
-
- }
- }
- DT_EndComplexShape();
- return shape;
-}
-
-
-static DT_ShapeHandle ground_shape = createComplex();
-
-#else
-
-static DT_ShapeHandle ground_shape = DT_Box(50, 0, 50);
-
-#endif
-
-static SM_Object sm_ground(ground_shape, &g_materialProps, 0, 0);
-static Object ground(&gl_ground, sm_ground);
-
-static SM_Object sm_sphere(DT_Sphere(0.0), &g_materialProps, &g_shapeProps, 0);
-static Object object(&gl_sphere, sm_sphere);
-
-
-static SM_Object sm_ray(DT_Ray(0.0, -1.0, 0.0), 0, 0, 0);
-
-static SM_Scene g_scene;
-
-
-void myinit(void) {
-
- GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
- GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
- GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
-
- /* light_position is NOT default value */
- GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 };
- GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 };
-
- glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
-
- glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
- glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
- glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);
- glLightfv(GL_LIGHT1, GL_POSITION, light_position1);
-
-
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnable(GL_LIGHT1);
-
- glShadeModel(GL_SMOOTH);
-
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
-
- // glEnable(GL_CULL_FACE);
- // glCullFace(GL_BACK);
-
- g_scene.setForceField(gravity);
- g_scene.add(sm_ground);
- sm_ground.setMargin(ground_margin);
-
- new(&object) Object(&gl_sphere, sm_sphere);
-
-
- object.setMargin(sphere_radius);
-
- g_scene.add(sm_sphere);
-
- ground.setPosition(MT_Point3(0, -10, 0));
- ground.setOrientation(MT_Quaternion(0, 0, 0, 1));
- ground.setMatrix();
- center.setValue(0.0, 0.0, 0.0);
-
- newRandom();
-}
-
-
-//MT_Point3 cp1, cp2;
-//bool intersection;
-
-bool g_hit = false;
-MT_Point3 g_spot;
-MT_Vector3 g_normal;
-
-
-void display(void) {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- ground.paint();
- object.paint();
-
- if (g_hit) {
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(g_spot[0], g_spot[1], g_spot[2]);
- glEnd();
- glPointSize(1);
- }
-
-
-
-#ifdef COLLISION
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LIGHTING);
- glColor3f(1, 1, 0);
- if (intersection) {
- glPointSize(5);
- glBegin(GL_POINTS);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glEnd();
- glPointSize(1);
- }
- else {
- glBegin(GL_LINES);
- glVertex3d(cp1[0], cp1[1], cp1[2]);
- glVertex3d(cp2[0], cp2[1], cp2[2]);
- glEnd();
- }
- glEnable(GL_LIGHTING);
- glEnable(GL_DEPTH_TEST);
-#endif
-
- glFlush();
- glutSwapBuffers();
-}
-
-
-
-
-
-void newRandom() {
- object.setPosition(MT_Point3(0, 0, 0));
- object.clearMomentum();
- object.setMatrix();
-
- display();
-}
-
-void moveAndDisplay() {
- g_scene.proceed(timeStep, 0.01);
-
- MT_Vector3 normal(0, 1, 0);
-
- MT_Point3 from = object.getWorldCoord(MT_Point3(0, 0, 0));
- MT_Point3 to = from - normal * 10.0;
-
- g_hit = DT_ObjectRayTest(sm_ground.getObjectHandle(),
- from.getValue(),
- to.getValue(), g_spot.getValue(),
- g_normal.getValue());
-
- // Scrap
-#define DO_FH
-#ifdef DO_FH
- MT_Scalar dist = MT_distance(from, g_spot);
- if (dist < 5.0) {
- MT_Vector3 lin_vel = object.getLinearVelocity();
- MT_Scalar lin_vel_normal = lin_vel.dot(normal);
-
- MT_Scalar spring_extent = dist + lin_vel_normal * (timeStep * 0.5);
-
- MT_Scalar f_spring = (5.0 - spring_extent) * 3.0;
- object.applyCenterForce(normal * f_spring);
- object.applyCenterForce(-lin_vel_normal * normal);
- }
-
-#endif
-
-
- display();
-}
-
-
-void turn_left() {
- object.applyTorque(MT_Vector3(0.0, 10.0, 0.0));
-}
-
-void turn_right() {
- object.applyTorque(MT_Vector3(0.0, -10.0, 0.0));
-}
-
-void forward() {
- object.applyCenterForce(20.0 * object.getAhead());
-}
-
-void backward() {
- object.applyCenterForce(-20.0 * object.getAhead());
-}
-
-void jump() {
- object.applyCenterForce(MT_Vector3(0.0, 200.0, 0.0));
-}
-
-
-void toggleIdle() {
- static bool idle = true;
- if (idle) {
- glutIdleFunc(moveAndDisplay);
- idle = false;
- }
- else {
- glutIdleFunc(NULL);
- idle = true;
- }
-}
-
-
-void setCamera() {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 200.0);
- MT_Scalar rele = MT_radians(ele);
- MT_Scalar razi = MT_radians(azi);
- eye.setValue(DISTANCE * sin(razi) * cos(rele),
- DISTANCE * sin(rele),
- DISTANCE * cos(razi) * cos(rele));
- gluLookAt(eye[0], eye[1], eye[2],
- center[0], center[1], center[2],
- 0, 1, 0);
- glMatrixMode(GL_MODELVIEW);
- display();
-}
-
-const MT_Scalar STEPSIZE = 5;
-
-void stepLeft() { azi -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void stepRight() { azi += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepFront() { ele += STEPSIZE; if (azi >= 360) azi -= 360; setCamera(); }
-void stepBack() { ele -= STEPSIZE; if (azi < 0) azi += 360; setCamera(); }
-void zoomIn() { DISTANCE -= 1; setCamera(); }
-void zoomOut() { DISTANCE += 1; setCamera(); }
-
-
-void myReshape(int w, int h) {
- glViewport(0, 0, w, h);
- setCamera();
-}
-
-void myKeyboard(unsigned char key, int x, int y)
-{
- switch (key)
- {
- case 'w': forward(); break;
- case 's': backward(); break;
- case 'a': turn_left(); break;
- case 'd': turn_right(); break;
- case 'e': jump(); break;
- case 'l' : stepLeft(); break;
- case 'r' : stepRight(); break;
- case 'f' : stepFront(); break;
- case 'b' : stepBack(); break;
- case 'z' : zoomIn(); break;
- case 'x' : zoomOut(); break;
- case 'i' : toggleIdle(); break;
- case ' ' : newRandom(); break;
- default:
-// std::cout << "unused key : " << key << std::endl;
- break;
- }
-}
-
-void mySpecial(int key, int x, int y)
-{
- switch (key)
- {
- case GLUT_KEY_LEFT : stepLeft(); break;
- case GLUT_KEY_RIGHT : stepRight(); break;
- case GLUT_KEY_UP : stepFront(); break;
- case GLUT_KEY_DOWN : stepBack(); break;
- case GLUT_KEY_PAGE_UP : zoomIn(); break;
- case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
- case GLUT_KEY_HOME : toggleIdle(); break;
- default:
-// std::cout << "unused (special) key : " << key << std::endl;
- break;
- }
-}
-
-void goodbye( void)
-{
- g_scene.remove(sm_ground);
- g_scene.remove(sm_sphere);
-
- std::cout << "goodbye ..." << std::endl;
- exit(0);
-}
-
-void menu(int choice)
-{
-
- static int fullScreen = 0;
- static int px, py, sx, sy;
-
- switch(choice) {
- case 1:
- if (fullScreen == 1) {
- glutPositionWindow(px,py);
- glutReshapeWindow(sx,sy);
- glutChangeToMenuEntry(1,"Full Screen",1);
- fullScreen = 0;
- } else {
- px=glutGet((GLenum)GLUT_WINDOW_X);
- py=glutGet((GLenum)GLUT_WINDOW_Y);
- sx=glutGet((GLenum)GLUT_WINDOW_WIDTH);
- sy=glutGet((GLenum)GLUT_WINDOW_HEIGHT);
- glutFullScreen();
- glutChangeToMenuEntry(1,"Close Full Screen",1);
- fullScreen = 1;
- }
- break;
- case 2:
- toggleIdle();
- break;
- case 3:
- goodbye();
- break;
- default:
- break;
- }
-}
-
-void createMenu()
-{
- glutCreateMenu(menu);
- glutAddMenuEntry("Full Screen", 1);
- glutAddMenuEntry("Toggle Idle (Start/Stop)", 2);
- glutAddMenuEntry("Quit", 3);
- glutAttachMenu(GLUT_RIGHT_BUTTON);
-}
-
-int main(int argc, char **argv) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(500, 500);
- glutCreateWindow("Physics demo");
-
- myinit();
- glutKeyboardFunc(myKeyboard);
- glutSpecialFunc(mySpecial);
- glutReshapeFunc(myReshape);
- createMenu();
- glutIdleFunc(NULL);
-
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
-}
-
-
-
-
-
-
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/Makefile b/source/gameengine/Physics/Sumo/Fuzzics/src/Makefile
deleted file mode 100644
index b2744c5496a..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# $Id$
-# Copyright (C) 2001 NaN Technologies B.V.
-
-LIBNAME = fuzzics
-DIR = $(OCGDIR)/gameengine/blphys/$(LIBNAME)
-
-include nan_compile.mk
-
-CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-
-CPPFLAGS += -I../include -I$(NAN_MOTO)/include -I../../include
-CPPFLAGS += -I$(NAN_SOLID)/include
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp
deleted file mode 100644
index d866cdb4922..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include "SM_FhObject.h"
-#include "MT_MinMax.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-SM_FhObject::SM_FhObject(DT_ShapeHandle rayshape, MT_Vector3 ray, SM_Object *parent_object) :
- SM_Object(rayshape, NULL, NULL, NULL),
- m_ray(ray),
- m_ray_direction(ray.normalized()),
- m_parent_object(parent_object)
-{
-}
-
-SM_FhObject::~SM_FhObject()
-{
- DT_DeleteShape(getShapeHandle());
-}
-
-DT_Bool SM_FhObject::ray_hit(void *client_data,
- void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data)
-{
-
- SM_FhObject *fh_object = dynamic_cast<SM_FhObject *>((SM_Object *)client_object2);
- if (!fh_object)
- {
- std::swap(client_object1, client_object2);
- fh_object = dynamic_cast<SM_FhObject *>((SM_Object *)client_object2);
- }
-
- SM_Object *hit_object = (SM_Object *)client_object1;
- const SM_MaterialProps *matProps = hit_object->getMaterialProps();
-
- if ((matProps == 0) || (matProps->m_fh_distance < MT_EPSILON)) {
- return DT_CONTINUE;
- }
-
- SM_Object *cl_object = fh_object->getParentObject();
-
- assert(fh_object);
-
- if (hit_object == cl_object) {
- // Shot myself in the foot...
- return DT_CONTINUE;
- }
-
- const SM_ShapeProps *shapeProps = cl_object->getShapeProps();
-
- // Exit if the client object is not dynamic.
- if (shapeProps == 0) {
- return DT_CONTINUE;
- }
-
- MT_Point3 lspot;
- MT_Vector3 normal;
-
- DT_Vector3 from, to, dnormal;
- DT_Scalar dlspot;
- fh_object->getPosition().getValue(from);
- fh_object->getSpot().getValue(to);
-
-
- if (DT_ObjectRayCast(hit_object->getObjectHandle(),
- from,
- to,
- 1.,
- &dlspot,
- dnormal)) {
-
- lspot = fh_object->getPosition() + (fh_object->getSpot() - fh_object->getPosition()) * dlspot;
- const MT_Vector3& ray_dir = fh_object->getRayDirection();
- MT_Scalar dist = MT_distance(fh_object->getPosition(), lspot) -
- cl_object->getMargin() - shapeProps->m_radius;
-
- normal = MT_Vector3(dnormal).safe_normalized();
-
- if (dist < matProps->m_fh_distance) {
-
- if (shapeProps->m_do_fh) {
- lspot -= hit_object->getPosition();
- MT_Vector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocity(lspot);
- MT_Scalar rel_vel_ray = ray_dir.dot(rel_vel);
- MT_Scalar spring_extent = 1.0 - dist / matProps->m_fh_distance;
-
- MT_Scalar i_spring = spring_extent * matProps->m_fh_spring;
- MT_Scalar i_damp = rel_vel_ray * matProps->m_fh_damping;
-
- cl_object->addLinearVelocity(-(i_spring + i_damp) * ray_dir);
- if (matProps->m_fh_normal) {
- cl_object->addLinearVelocity(
- (i_spring + i_damp) *
- (normal - normal.dot(ray_dir) * ray_dir));
- }
-
- MT_Vector3 lateral = rel_vel - rel_vel_ray * ray_dir;
- const SM_ShapeProps *shapeProps = cl_object->getShapeProps();
-
- if (shapeProps->m_do_anisotropic) {
- MT_Matrix3x3 lcs(cl_object->getOrientation());
- MT_Vector3 loc_lateral = lateral * lcs;
- const MT_Vector3& friction_scaling =
- shapeProps->m_friction_scaling;
-
- loc_lateral.scale(friction_scaling[0],
- friction_scaling[1],
- friction_scaling[2]);
- lateral = lcs * loc_lateral;
- }
-
-
- MT_Scalar rel_vel_lateral = lateral.length();
-
- if (rel_vel_lateral > MT_EPSILON) {
- MT_Scalar friction_factor = matProps->m_friction;
- MT_Scalar max_friction = friction_factor * MT_max(MT_Scalar(0.0), i_spring);
-
- MT_Scalar rel_mom_lateral = rel_vel_lateral /
- cl_object->getInvMass();
-
- MT_Vector3 friction =
- (rel_mom_lateral > max_friction) ?
- -lateral * (max_friction / rel_vel_lateral) :
- -lateral;
-
- cl_object->applyCenterImpulse(friction);
- }
- }
-
- if (shapeProps->m_do_rot_fh) {
- const double *ogl_mat = cl_object->getMatrix();
- MT_Vector3 up(&ogl_mat[8]);
- MT_Vector3 t_spring = up.cross(normal) * matProps->m_fh_spring;
- MT_Vector3 ang_vel = cl_object->getAngularVelocity();
-
- // only rotations that tilt relative to the normal are damped
- ang_vel -= ang_vel.dot(normal) * normal;
-
- MT_Vector3 t_damp = ang_vel * matProps->m_fh_damping;
-
- cl_object->addAngularVelocity(t_spring - t_damp);
- }
- }
- }
-
- return DT_CONTINUE;
-}
-
-
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp
deleted file mode 100644
index b8f4e0c591c..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include <MT_Scalar.h>
-#include <MT_Vector3.h>
-#include <MT_Quaternion.h>
-
-#include "SM_MotionState.h"
-
-void SM_MotionState::integrateMidpoint(MT_Scalar timeStep, const SM_MotionState &prev_state, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel)
-{
- m_pos += (prev_state.getLinearVelocity() + velocity) * (timeStep * 0.5);
- m_orn += (prev_state.getAngularVelocity() * prev_state.getOrientation() + ang_vel * m_orn) * (timeStep * 0.25);
- m_orn.normalize();
-}
-
-void SM_MotionState::integrateBackward(MT_Scalar timeStep, const MT_Vector3 &velocity, const MT_Quaternion& ang_vel)
-{
- m_pos += velocity * timeStep;
- m_orn += ang_vel * m_orn * (timeStep * 0.5);
- m_orn.normalize();
-}
-
-void SM_MotionState::integrateForward(MT_Scalar timeStep, const SM_MotionState &prev_state)
-{
- m_pos += prev_state.getLinearVelocity() * timeStep;
- m_orn += prev_state.getAngularVelocity() * m_orn * (timeStep * 0.5);
- m_orn.normalize();
-}
-
-/*
-// Newtonian lerp: interpolate based on Newtonian motion
-void SM_MotionState::nlerp(const SM_MotionState &prev, const SM_MotionState &next)
-{
- MT_Scalar dt = next.getTime() - prev.getTime();
- MT_Scalar t = getTime() - prev.getTime();
- MT_Vector3 dx = next.getPosition() - prev.getPosition();
- MT_Vector3 a = dx/(dt*dt) - prev.getLinearVelocity()/dt;
-
- m_pos = prev.getPosition() + prev.getLinearVelocity()*t + a*t*t;
-}
-*/
-
-void SM_MotionState::lerp(const SM_MotionState &prev, const SM_MotionState &next)
-{
- MT_Scalar dt = next.getTime() - prev.getTime();
- if (MT_fuzzyZero(dt))
- {
- *this = next;
- return;
- }
-
- MT_Scalar x = (getTime() - prev.getTime())/dt;
-
- m_pos = x*next.getPosition() + (1-x)*prev.getPosition();
-
- m_orn = prev.getOrientation().slerp(next.getOrientation(), 1-x);
-
- m_lin_vel = x*next.getLinearVelocity() + (1-x)*prev.getLinearVelocity();
- m_ang_vel = x*next.getAngularVelocity() + (1-x)*prev.getAngularVelocity();
-}
-
-void SM_MotionState::lerp(MT_Scalar t, const SM_MotionState &other)
-{
- MT_Scalar x = (t - getTime())/(other.getTime() - getTime());
- m_pos = (1-x)*m_pos + x*other.getPosition();
-
- m_orn = other.getOrientation().slerp(m_orn, x);
-
- m_lin_vel = (1-x)*m_lin_vel + x*other.getLinearVelocity();
- m_ang_vel = (1-x)*m_ang_vel + x*other.getAngularVelocity();
-
- m_time = t;
-}
-
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
deleted file mode 100644
index 4b2c7cae008..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
+++ /dev/null
@@ -1,1298 +0,0 @@
-/**
- * $Id$
- * Copyright (C) 2001 NaN Technologies B.V.
- * The basic physics object.
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WIN32
-// This warning tells us about truncation of __long__ stl-generated names.
-// It can occasionally cause DevStudio to have internal compiler warnings.
-#pragma warning( disable : 4786 )
-#endif
-
-#include "MT_assert.h"
-
-#include "SM_Object.h"
-#include "SM_Scene.h"
-#include "SM_FhObject.h"
-#include "SM_Debug.h"
-
-#include "MT_MinMax.h"
-
-MT_Scalar SM_Object::ImpulseThreshold = -1.0;
-
-struct Contact
-{
- SM_Object *obj1;
- SM_Object *obj2;
- MT_Vector3 normal;
- MT_Point3 pos;
-
- // Sort objects by height
- bool operator()(const Contact *a, const Contact *b)
- {
- return a->pos[2] < b->pos[2];
- }
-
- Contact(SM_Object *o1, SM_Object *o2, const MT_Vector3 nor, const MT_Point3 p)
- : obj1(o1),
- obj2(o2),
- normal(nor),
- pos(p)
- {
- }
-
- Contact()
- {
- }
-
- void resolve()
- {
- if (obj1->m_static || obj2->m_static)
- {
- if (obj1->isDynamic())
- {
- if (obj1->m_static && obj2->m_static)
- {
- if (obj1->m_static < obj2->m_static)
- {
- obj2->m_error -= normal;
- obj2->m_static = obj1->m_static + 1;
- }
- else
- {
- obj1->m_error += normal;
- obj1->m_static = obj2->m_static + 1;
- }
- }
- else
- {
- if (obj1->m_static)
- {
- obj2->m_error -= normal;
- obj2->m_static = obj1->m_static + 1;
- }
- else
- {
- obj1->m_error += normal;
- obj1->m_static = obj2->m_static + 1;
- }
- }
- }
- else
- {
- obj2->m_error -= normal;
- obj2->m_static = 1;
- }
- }
- else
- {
- // This distinction between dynamic and non-dynamic objects should not be
- // necessary. Non-dynamic objects are assumed to have infinite mass.
- if (obj1->isDynamic()) {
- MT_Vector3 error = normal * 0.5f;
- obj1->m_error += error;
- obj2->m_error -= error;
- }
- else {
- // Same again but now obj1 is non-dynamic
- obj2->m_error -= normal;
- obj2->m_static = obj1->m_static + 1;
- }
- }
-
- }
-
-
- typedef std::set<Contact*, Contact> Set;
-};
-
-static Contact::Set contacts;
-
-SM_Object::SM_Object(
- DT_ShapeHandle shape,
- const SM_MaterialProps *materialProps,
- const SM_ShapeProps *shapeProps,
- SM_Object *dynamicParent) :
-
- m_dynamicParent(dynamicParent),
- m_client_object(0),
- m_physicsClientObject(0),
- m_shape(shape),
- m_materialProps(materialProps),
- m_materialPropsBackup(0),
- m_shapeProps(shapeProps),
- m_shapePropsBackup(0),
- m_margin(0.0),
- m_scaling(1.0, 1.0, 1.0),
- m_reaction_impulse(0.0, 0.0, 0.0),
- m_reaction_force(0.0, 0.0, 0.0),
- m_lin_mom(0.0, 0.0, 0.0),
- m_ang_mom(0.0, 0.0, 0.0),
- m_force(0.0, 0.0, 0.0),
- m_torque(0.0, 0.0, 0.0),
- m_error(0.0, 0.0, 0.0),
- m_combined_lin_vel (0.0, 0.0, 0.0),
- m_combined_ang_vel (0.0, 0.0, 0.0),
- m_fh_object(0),
- m_inv_mass(0.0),
- m_inv_inertia(0., 0., 0.),
- m_kinematic(false),
- m_prev_kinematic(false),
- m_is_rigid_body(false),
- m_static(0)
-{
- m_object = DT_CreateObject(this, shape);
- m_xform.setIdentity();
- m_xform.getValue(m_ogl_matrix);
- if (shapeProps)
- {
- if (shapeProps->m_do_fh || shapeProps->m_do_rot_fh)
- {
- DT_Vector3 zero = {0., 0., 0.}, ray = {0.0, 0.0, -10.0};
- m_fh_object = new SM_FhObject(DT_NewLineSegment(zero, ray), MT_Vector3(ray), this);
- //printf("SM_Object:: WARNING! fh disabled.\n");
- }
- m_inv_mass = 1. / shapeProps->m_mass;
- m_inv_inertia = MT_Vector3(1./shapeProps->m_inertia[0], 1./shapeProps->m_inertia[1], 1./shapeProps->m_inertia[2]);
- }
- updateInvInertiaTensor();
- m_suspended = false;
-}
-
-
- void
-SM_Object::
-integrateForces(
- MT_Scalar timeStep
-){
- if (!m_suspended) {
- m_prev_state = getNextFrame();
- m_prev_state.setLinearVelocity(actualLinVelocity());
- m_prev_state.setAngularVelocity(actualAngVelocity());
- if (isDynamic()) {
- // Integrate momentum (forward Euler)
- m_lin_mom += m_force * timeStep;
- m_ang_mom += m_torque * timeStep;
- // Drain momentum because of air/water resistance
- m_lin_mom *= pow(m_shapeProps->m_lin_drag, timeStep);
- m_ang_mom *= pow(m_shapeProps->m_ang_drag, timeStep);
- // Set velocities according momentum
- getNextFrame().setLinearVelocity(m_lin_mom * m_inv_mass);
- getNextFrame().setAngularVelocity(m_inv_inertia_tensor * m_ang_mom);
- }
- }
-
-};
-
- void
-SM_Object::
-integrateMomentum(
- MT_Scalar timeStep
-){
- // Integrate position and orientation
-
- // only do it for objects with linear and/or angular velocity
- // else clients with hierarchies may get into trouble
- if (!actualLinVelocity().fuzzyZero() || !actualAngVelocity().fuzzyZero())
- {
-
- // those MIDPOINT and BACKWARD integration methods are
- // in this form not ok with some testfiles !
- // For a release build please use forward euler unless completely tested
-
-//#define MIDPOINT
-//#define BACKWARD
-#ifdef MIDPOINT
-// Midpoint rule
- getNextFrame().integrateMidpoint(timeStep, m_prev_state, actualLinVelocity(), actualAngVelocity());
-#elif defined BACKWARD
-// Backward Euler
- getNextFrame().integrateBackward(timeStep, actualLinVelocity(), actualAngVelocity());
-#else
-// Forward Euler
- getNextFrame().integrateForward(timeStep, m_prev_state);
-#endif
-
- calcXform();
- notifyClient();
-
- }
-}
-
-/**
- * dynamicCollision computes the response to a collision.
- *
- * @param local2 the contact point in local coordinates.
- * @param normal the contact normal.
- * @param dist the penetration depth of the contact. (unused)
- * @param rel_vel the relative velocity of the objects
- * @param restitution the amount of momentum conserved in the collision. Range: 0.0 - 1.0
- * @param friction_factor the amount of friction between the two surfaces.
- * @param invMass the inverse mass of the collision objects (1.0 / mass)
- */
-void SM_Object::dynamicCollision(const MT_Point3 &local2,
- const MT_Vector3 &normal,
- MT_Scalar dist,
- const MT_Vector3 &rel_vel,
- MT_Scalar restitution,
- MT_Scalar friction_factor,
- MT_Scalar invMass
-)
-{
- /**
- * rel_vel_normal is the relative velocity in the contact normal direction.
- */
- MT_Scalar rel_vel_normal = normal.dot(rel_vel);
-
- /**
- * if rel_vel_normal > 0, the objects are moving apart!
- */
- if (rel_vel_normal < -MT_EPSILON) {
- /**
- * if rel_vel_normal < ImpulseThreshold, scale the restitution down.
- * This should improve the simulation where the object is stacked.
- */
- restitution *= MT_min(MT_Scalar(1.0), rel_vel_normal/ImpulseThreshold);
-
- MT_Scalar impulse = -(1.0 + restitution) * rel_vel_normal;
-
- if (isRigidBody())
- {
- MT_Vector3 temp = getInvInertiaTensor() * local2.cross(normal);
- impulse /= invMass + normal.dot(temp.cross(local2));
-
- /**
- * Apply impulse at the collision point.
- * Take rotational inertia into account.
- */
- applyImpulse(local2 + getNextFrame().getPosition(), impulse * normal);
- } else {
- /**
- * Apply impulse through object center. (no rotation.)
- */
- impulse /= invMass;
- applyCenterImpulse( impulse * normal );
- }
-
- MT_Vector3 external = m_combined_lin_vel + m_combined_ang_vel.cross(local2);
- MT_Vector3 lateral = rel_vel - external - normal * (rel_vel_normal - external.dot(normal));
-#if 0
- // test - only do friction on the physics part of the
- // velocity.
- vel1 -= obj1->m_combined_lin_vel;
- vel2 -= obj2->m_combined_lin_vel;
-
- // This should look familiar....
- rel_vel = vel2 - vel1;
- rel_vel_normal = normal.dot(rel_vel);
-#endif
- /**
- * The friction part starts here!!!!!!!!
- *
- * Compute the lateral component of the relative velocity
- * lateral actually points in the opposite direction, i.e.,
- * into the direction of the friction force.
- */
- if (m_shapeProps->m_do_anisotropic) {
-
- /**
- * For anisotropic friction we scale the lateral component,
- * rather than compute a direction-dependent fricition
- * factor. For this the lateral component is transformed to
- * local coordinates.
- */
-
- MT_Matrix3x3 lcs(getNextFrame().getOrientation());
-
- /**
- * We cannot use m_xform.getBasis() for the matrix, since
- * it might contain a non-uniform scaling.
- * OPT: it's a bit daft to compute the matrix since the
- * quaternion itself can be used to do the transformation.
- */
- MT_Vector3 loc_lateral = lateral * lcs;
-
- /**
- * lcs is orthogonal so lcs.inversed() == lcs.transposed(),
- * and lcs.transposed() * lateral == lateral * lcs.
- */
- const MT_Vector3& friction_scaling =
- m_shapeProps->m_friction_scaling;
-
- // Scale the local lateral...
- loc_lateral.scale(friction_scaling[0],
- friction_scaling[1],
- friction_scaling[2]);
- // ... and transform it back to global coordinates
- lateral = lcs * loc_lateral;
- }
-
- /**
- * A tiny Coulomb friction primer:
- * The Coulomb friction law states that the magnitude of the
- * maximum possible friction force depends linearly on the
- * magnitude of the normal force.
- *
- * \f[
- F_max_friction = friction_factor * F_normal
- \f]
- *
- * (NB: independent of the contact area!!)
- *
- * The friction factor depends on the material.
- * We use impulses rather than forces but let us not be
- * bothered by this.
- */
- MT_Scalar rel_vel_lateral = lateral.length();
-
- if (rel_vel_lateral > MT_EPSILON) {
- lateral /= rel_vel_lateral;
-
- // Compute the maximum friction impulse
- MT_Scalar max_friction =
- friction_factor * MT_max(MT_Scalar(0.0), impulse);
-
- // I guess the GEN_max is not necessary, so let's check it
-
- MT_assert(impulse >= 0.0);
-
- /**
- * Here's the trick. We compute the impulse to make the
- * lateral velocity zero. (Make the objects stick together
- * at the contact point. If this impulse is larger than
- * the maximum possible friction impulse, then shrink its
- * magnitude to the maximum friction.
- */
-
- if (isRigidBody()) {
-
- /**
- * For rigid bodies we take the inertia into account,
- * since the friction impulse is going to change the
- * angular momentum as well.
- */
- MT_Vector3 temp = getInvInertiaTensor() * local2.cross(lateral);
- MT_Scalar impulse_lateral = rel_vel_lateral /
- (invMass + lateral.dot(temp.cross(local2)));
-
- MT_Scalar friction = MT_min(impulse_lateral, max_friction);
- applyImpulse(local2 + getNextFrame().getPosition(), -lateral * friction);
- }
- else {
- MT_Scalar impulse_lateral = rel_vel_lateral / invMass;
-
- MT_Scalar friction = MT_min(impulse_lateral, max_friction);
- applyCenterImpulse( -friction * lateral);
- }
-
-
- }
-
- //calcXform();
- //notifyClient();
-
- }
-}
-
-static void AddCallback(SM_Scene *scene, SM_Object *obj1, SM_Object *obj2)
-{
- // If we have callbacks on either of the client objects, do a collision test
- // and add a callback if they intersect.
- DT_Vector3 v;
- if ((obj1->getClientObject() && obj1->getClientObject()->hasCollisionCallback()) ||
- (obj2->getClientObject() && obj2->getClientObject()->hasCollisionCallback()) &&
- DT_GetIntersect(obj1->getObjectHandle(), obj2->getObjectHandle(), v))
- scene->notifyCollision(obj1, obj2);
-}
-
-DT_Bool SM_Object::boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
-){
- SM_Scene *scene = (SM_Scene *)client_data;
- SM_Object *obj1 = (SM_Object *)object1;
- SM_Object *obj2 = (SM_Object *)object2;
-
- // at this point it is unknown whether we are really intersecting (broad phase)
-
- DT_Vector3 p1, p2;
- if (!obj2->isDynamic()) {
- std::swap(obj1, obj2);
- }
-
- // If one of the objects is a ghost then ignore it for the dynamics
- if (obj1->isGhost() || obj2->isGhost()) {
- AddCallback(scene, obj1, obj2);
- return DT_CONTINUE;
- }
-
- // Objects do not collide with parent objects
- if (obj1->getDynamicParent() == obj2 || obj2->getDynamicParent() == obj1) {
- AddCallback(scene, obj1, obj2);
- return DT_CONTINUE;
- }
-
- if (!obj2->isDynamic()) {
- AddCallback(scene, obj1, obj2);
- return DT_CONTINUE;
- }
-
- // Get collision data from SOLID
- if (!DT_GetPenDepth(obj1->getObjectHandle(), obj2->getObjectHandle(), p1, p2))
- return DT_CONTINUE;
-
- MT_Point3 local1(p1), local2(p2);
- MT_Vector3 normal(local2 - local1);
- MT_Scalar dist = normal.length();
-
- if (dist < MT_EPSILON)
- return DT_CONTINUE;
-
- // Now we are definitely intersecting.
-
- // Set callbacks for game engine.
- if ((obj1->getClientObject() && obj1->getClientObject()->hasCollisionCallback()) ||
- (obj2->getClientObject() && obj2->getClientObject()->hasCollisionCallback()))
- scene->notifyCollision(obj1, obj2);
-
- local1 -= obj1->getNextFrame().getPosition();
- local2 -= obj2->getNextFrame().getPosition();
-
- // Calculate collision parameters
- MT_Vector3 rel_vel = obj1->getVelocity(local1) - obj2->getVelocity(local2);
-
- MT_Scalar restitution =
- MT_min(obj1->getMaterialProps()->m_restitution,
- obj2->getMaterialProps()->m_restitution);
-
- MT_Scalar friction_factor =
- MT_min(obj1->getMaterialProps()->m_friction,
- obj2->getMaterialProps()->m_friction);
-
- MT_Scalar invMass = obj1->getInvMass() + obj2->getInvMass();
-
- normal /= dist;
-
- // Calculate reactions
- if (obj1->isDynamic())
- obj1->dynamicCollision(local1, normal, dist, rel_vel, restitution, friction_factor, invMass);
-
- if (obj2->isDynamic())
- {
- obj2->dynamicCollision(local2, -normal, dist, -rel_vel, restitution, friction_factor, invMass);
- if (!obj1->isDynamic() || obj1->m_static)
- obj2->m_static = obj1->m_static + 1;
- }
-
- return DT_CONTINUE;
-}
-
-DT_Bool SM_Object::fix(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *coll_data
-){
- SM_Object *obj1 = (SM_Object *)object1;
- SM_Object *obj2 = (SM_Object *)object2;
-
- // If one of the objects is a ghost then ignore it for the dynamics
- if (obj1->isGhost() || obj2->isGhost()) {
- return DT_CONTINUE;
- }
-
- if (obj1->getDynamicParent() == obj2 || obj2->getDynamicParent() == obj1) {
- return DT_CONTINUE;
- }
-
- if (!obj2->isDynamic()) {
- std::swap(obj1, obj2);
- }
-
- if (!obj2->isDynamic()) {
- return DT_CONTINUE;
- }
-
- // obj1 points to a dynamic object
- DT_Vector3 p1, p2;
- if (!DT_GetPenDepth(obj1->getObjectHandle(), obj2->getObjectHandle(), p1, p2))
- return DT_CONTINUE;
- MT_Point3 local1(p1), local2(p2);
- // Get collision data from SOLID
- MT_Vector3 normal(local2 - local1);
-
- MT_Scalar dist = normal.dot(normal);
- if (dist < MT_EPSILON || dist > obj2->m_shapeProps->m_radius*obj2->m_shapeProps->m_radius)
- return DT_CONTINUE;
-
-
- if ((obj1->m_static || !obj1->isDynamic()) && obj1->m_static < obj2->m_static)
- {
- obj2->m_static = obj1->m_static + 1;
- } else if (obj2->m_static && obj2->m_static < obj1->m_static)
- {
- obj1->m_static = obj2->m_static + 1;
- }
-
- contacts.insert(new Contact(obj1, obj2, normal, MT_Point3(local1 + 0.5*(local2 - local1))));
-
-
- return DT_CONTINUE;
-}
-
-void SM_Object::relax(void)
-{
- for (Contact::Set::iterator csit = contacts.begin() ; csit != contacts.end(); ++csit)
- {
- (*csit)->resolve();
- delete (*csit);
- }
-
- contacts.clear();
- if (m_error.fuzzyZero())
- return;
- //std::cout << "SM_Object::relax: { " << m_error << " }" << std::endl;
-
- getNextFrame().setPosition(getNextFrame().getPosition() + m_error);
- m_error.setValue(0., 0., 0.);
- //calcXform();
- //notifyClient();
-}
-
-SM_Object::SM_Object() :
- m_dynamicParent(0),
- m_client_object(0),
- m_physicsClientObject(0),
- m_shape(0),
- m_materialProps(0),
- m_materialPropsBackup(0),
- m_shapeProps(0),
- m_shapePropsBackup(0),
- m_object(0),
- m_margin(0.0),
- m_scaling(1.0, 1.0, 1.0),
- m_reaction_impulse(0.0, 0.0, 0.0),
- m_reaction_force(0.0, 0.0, 0.0),
- m_lin_mom(0.0, 0.0, 0.0),
- m_ang_mom(0.0, 0.0, 0.0),
- m_force(0.0, 0.0, 0.0),
- m_torque(0.0, 0.0, 0.0),
- m_error(0.0, 0.0, 0.0),
- m_combined_lin_vel (0.0, 0.0, 0.0),
- m_combined_ang_vel (0.0, 0.0, 0.0),
- m_fh_object(0),
- m_kinematic(false),
- m_prev_kinematic(false),
- m_is_rigid_body(false)
-{
- // warning no initialization of variables done by moto.
-}
-
-SM_Object::
-~SM_Object() {
- if (m_fh_object)
- delete m_fh_object;
-
- DT_DestroyObject(m_object);
- m_object = NULL;
-}
-
- bool
-SM_Object::
-isDynamic(
-) const {
- return m_shapeProps != 0;
-}
-
-/* nzc experimental. There seem to be two places where kinematics
- * are evaluated: proceedKinematic (called from SM_Scene) and
- * proceed() in this object. I'll just try and bunge these out for
- * now. */
- void
-SM_Object::
-suspend(
-){
- if (!m_suspended) {
- m_suspended = true;
- suspendDynamics();
- }
-}
-
- void
-SM_Object::
-resume(
-) {
- if (m_suspended) {
- m_suspended = false;
- restoreDynamics();
- }
-}
-
- void
-SM_Object::
-suspendDynamics(
-) {
- if (m_shapeProps) {
- m_shapePropsBackup = m_shapeProps;
- m_shapeProps = 0;
- }
-}
-
- void
-SM_Object::
-restoreDynamics(
-) {
- if (m_shapePropsBackup) {
- m_shapeProps = m_shapePropsBackup;
- m_shapePropsBackup = 0;
- }
-}
-
- bool
-SM_Object::
-isGhost(
-) const {
- return m_materialProps == 0;
-}
-
- void
-SM_Object::
-suspendMaterial(
-) {
- if (m_materialProps) {
- m_materialPropsBackup = m_materialProps;
- m_materialProps = 0;
- }
-}
-
- void
-SM_Object::
-restoreMaterial(
-) {
- if (m_materialPropsBackup) {
- m_materialProps = m_materialPropsBackup;
- m_materialPropsBackup = 0;
- }
-}
-
- SM_FhObject *
-SM_Object::
-getFhObject(
-) const {
- return m_fh_object;
-}
-
- void
-SM_Object::
-registerCallback(
- SM_Callback& callback
-) {
- m_callbackList.push_back(&callback);
-}
-
-// Set the local coordinate system according to the current state
- void
-SM_Object::
-calcXform() {
-#ifdef SM_DEBUG_XFORM
- printf("SM_Object::calcXform m_pos = { %-0.5f, %-0.5f, %-0.5f }\n",
- m_pos[0], m_pos[1], m_pos[2]);
- printf(" m_orn = { %-0.5f, %-0.5f, %-0.5f, %-0.5f }\n",
- m_orn[0], m_orn[1], m_orn[2], m_orn[3]);
- printf(" m_scaling = { %-0.5f, %-0.5f, %-0.5f }\n",
- m_scaling[0], m_scaling[1], m_scaling[2]);
-#endif
- m_xform.setOrigin(getNextFrame().getPosition());
- m_xform.setBasis(MT_Matrix3x3(getNextFrame().getOrientation(), m_scaling));
- m_xform.getValue(m_ogl_matrix);
-
- /* Blender has been known to crash here.
- This usually means SM_Object *this has been deleted more than once. */
- DT_SetMatrixd(m_object, m_ogl_matrix);
- if (m_fh_object) {
- m_fh_object->setPosition(getNextFrame().getPosition());
- m_fh_object->calcXform();
- }
- updateInvInertiaTensor();
-#ifdef SM_DEBUG_XFORM
- printf("\n | %-0.5f %-0.5f %-0.5f %-0.5f |\n",
- m_ogl_matrix[0], m_ogl_matrix[4], m_ogl_matrix[ 8], m_ogl_matrix[12]);
- printf( " | %-0.5f %-0.5f %-0.5f %-0.5f |\n",
- m_ogl_matrix[1], m_ogl_matrix[5], m_ogl_matrix[ 9], m_ogl_matrix[13]);
- printf( "m_ogl_matrix = | %-0.5f %-0.5f %-0.5f %-0.5f |\n",
- m_ogl_matrix[2], m_ogl_matrix[6], m_ogl_matrix[10], m_ogl_matrix[14]);
- printf( " | %-0.5f %-0.5f %-0.5f %-0.5f |\n\n",
- m_ogl_matrix[3], m_ogl_matrix[7], m_ogl_matrix[11], m_ogl_matrix[15]);
-#endif
-}
-
- void
-SM_Object::updateInvInertiaTensor()
-{
- m_inv_inertia_tensor = m_xform.getBasis().scaled(m_inv_inertia[0], m_inv_inertia[1], m_inv_inertia[2]) * m_xform.getBasis().transposed();
-}
-
-// Call callbacks to notify the client of a change of placement
- void
-SM_Object::
-notifyClient() {
- T_CallbackList::iterator i;
- for (i = m_callbackList.begin(); i != m_callbackList.end(); ++i) {
- (*i)->do_me();
- }
-}
-
-
-// Save the current state information for use in the velocity computation in the next frame.
- void
-SM_Object::
-proceedKinematic(
- MT_Scalar timeStep
-) {
- /* nzc: need to bunge this for the logic bubbling as well? */
- if (!m_suspended) {
- m_prev_kinematic = m_kinematic;
- if (m_kinematic) {
- m_prev_xform = m_xform;
- m_timeStep = timeStep;
- calcXform();
- m_kinematic = false;
- }
- }
-}
-
- void
-SM_Object::
-saveReactionForce(
- MT_Scalar timeStep
-) {
- if (isDynamic()) {
- m_reaction_force = m_reaction_impulse / timeStep;
- m_reaction_impulse.setValue(0.0, 0.0, 0.0);
- }
-}
-
- void
-SM_Object::
-clearForce(
-) {
- m_force.setValue(0.0, 0.0, 0.0);
- m_torque.setValue(0.0, 0.0, 0.0);
-}
-
- void
-SM_Object::
-clearMomentum(
-) {
- m_lin_mom.setValue(0.0, 0.0, 0.0);
- m_ang_mom.setValue(0.0, 0.0, 0.0);
-}
-
- void
-SM_Object::
-setMargin(
- MT_Scalar margin
-) {
- m_margin = margin;
- DT_SetMargin(m_object, margin);
-}
-
- MT_Scalar
-SM_Object::
-getMargin(
-) const {
- return m_margin;
-}
-
-const
- SM_MaterialProps *
-SM_Object::
-getMaterialProps(
-) const {
- return m_materialProps;
-}
-
-const
- SM_ShapeProps *
-SM_Object::
-getShapeProps(
-) const {
- return m_shapeProps;
-}
-
- void
-SM_Object::
-setPosition(
- const MT_Point3& pos
-){
- m_kinematic = true;
- getNextFrame().setPosition(pos);
- endFrame();
-}
-
- void
-SM_Object::
-setOrientation(
- const MT_Quaternion& orn
-){
- MT_assert(!orn.fuzzyZero());
- m_kinematic = true;
- getNextFrame().setOrientation(orn);
- endFrame();
-}
-
- void
-SM_Object::
-setScaling(
- const MT_Vector3& scaling
-){
- m_kinematic = true;
- m_scaling = scaling;
-}
-
-/**
- * Functions to handle linear velocity
- */
-
- void
-SM_Object::
-setExternalLinearVelocity(
- const MT_Vector3& lin_vel
-) {
- m_combined_lin_vel=lin_vel;
-}
-
- void
-SM_Object::
-addExternalLinearVelocity(
- const MT_Vector3& lin_vel
-) {
- m_combined_lin_vel+=lin_vel;
-}
-
- void
-SM_Object::
-addLinearVelocity(
- const MT_Vector3& lin_vel
-){
- setLinearVelocity(getNextFrame().getLinearVelocity() + lin_vel);
-}
-
- void
-SM_Object::
-setLinearVelocity(
- const MT_Vector3& lin_vel
-){
- getNextFrame().setLinearVelocity(lin_vel);
- if (m_shapeProps) {
- m_lin_mom = getNextFrame().getLinearVelocity() * m_shapeProps->m_mass;
- }
-}
-
-/**
- * Functions to handle angular velocity
- */
-
- void
-SM_Object::
-setExternalAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- m_combined_ang_vel = ang_vel;
-}
-
- void
-SM_Object::
-addExternalAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- m_combined_ang_vel += ang_vel;
-}
-
- void
-SM_Object::
-setAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- getNextFrame().setAngularVelocity(ang_vel);
- if (m_shapeProps) {
- m_ang_mom = getNextFrame().getAngularVelocity() * m_shapeProps->m_inertia;
- }
-}
-
- void
-SM_Object::
-addAngularVelocity(
- const MT_Vector3& ang_vel
-) {
- setAngularVelocity(getNextFrame().getAngularVelocity() + ang_vel);
-}
-
-
- void
-SM_Object::
-clearCombinedVelocities(
-) {
- m_combined_lin_vel = MT_Vector3(0,0,0);
- m_combined_ang_vel = MT_Vector3(0,0,0);
-}
-
- void
-SM_Object::
-resolveCombinedVelocities(
- const MT_Vector3 & lin_vel,
- const MT_Vector3 & ang_vel
-) {
-
- // Different behaviours for dynamic and non-dynamic
- // objects. For non-dynamic we just set the velocity to
- // zero. For dynmic the physics velocity has to be
- // taken into account. We must make an arbitrary decision
- // on how to resolve the 2 velocities. Choices are
- // Add the physics velocity to the linear velocity. Objects
- // will just keep on moving in the direction they were
- // last set in - untill external forces affect them.
- // Set the combinbed linear and physics velocity to zero.
- // Set the physics velocity in the direction of the set velocity
- // zero.
- if (isDynamic()) {
-
-#if 1
- getNextFrame().setLinearVelocity(getNextFrame().getLinearVelocity() + lin_vel);
- getNextFrame().setAngularVelocity(getNextFrame().getAngularVelocity() + ang_vel);
-#else
-
- //compute the component of the physics velocity in the
- // direction of the set velocity and set it to zero.
- MT_Vector3 lin_vel_norm = lin_vel.normalized();
-
- setLinearVelocity(getNextFrame().getLinearVelocity() - (getNextFrame().getLinearVelocity().dot(lin_vel_norm) * lin_vel_norm));
-#endif
- m_lin_mom = getNextFrame().getLinearVelocity() * m_shapeProps->m_mass;
- m_ang_mom = getNextFrame().getAngularVelocity() * m_shapeProps->m_inertia;
- clearCombinedVelocities();
-
- }
-
-}
-
-
- MT_Scalar
-SM_Object::
-getInvMass(
-) const {
- return m_inv_mass;
- // OPT: cache the result of this division rather than compute it each call
-}
-
- const MT_Vector3&
-SM_Object::
-getInvInertia(
-) const {
- return m_inv_inertia;
- // OPT: cache the result of this division rather than compute it each call
-}
-
- const MT_Matrix3x3&
-SM_Object::
-getInvInertiaTensor(
-) const {
- return m_inv_inertia_tensor;
-}
-
- void
-SM_Object::
-applyForceField(
- const MT_Vector3& accel
-) {
- if (m_shapeProps) {
- m_force += m_shapeProps->m_mass * accel; // F = m * a
- }
-}
-
- void
-SM_Object::
-applyCenterForce(
- const MT_Vector3& force
-) {
- m_force += force;
-}
-
- void
-SM_Object::
-applyTorque(
- const MT_Vector3& torque
-) {
- m_torque += torque;
-}
-
- void
-SM_Object::
-applyImpulse(
- const MT_Point3& attach, const MT_Vector3& impulse
-) {
- applyCenterImpulse(impulse); // Change in linear momentum
- applyAngularImpulse((attach - getNextFrame().getPosition()).cross(impulse)); // Change in angular momentump
-}
-
- void
-SM_Object::
-applyCenterImpulse(
- const MT_Vector3& impulse
-) {
- if (m_shapeProps) {
- m_lin_mom += impulse;
- m_reaction_impulse += impulse;
- getNextFrame().setLinearVelocity(m_lin_mom * m_inv_mass);
-
- // The linear velocity is immedialtely updated since otherwise
- // simultaneous collisions will get a double impulse.
- }
-}
-
- void
-SM_Object::
-applyAngularImpulse(
- const MT_Vector3& impulse
-) {
- if (m_shapeProps) {
- m_ang_mom += impulse;
- getNextFrame().setAngularVelocity( m_inv_inertia_tensor * m_ang_mom);
- }
-}
-
- MT_Point3
-SM_Object::
-getWorldCoord(
- const MT_Point3& local
-) const {
- return m_xform(local);
-}
-
- MT_Vector3
-SM_Object::
-getVelocity(
- const MT_Point3& local
-) const {
- if (m_prev_kinematic && !isDynamic())
- {
- // For displaced objects the velocity is faked using the previous state.
- // Dynamic objects get their own velocity, not the faked velocity.
- // (Dynamic objects shouldn't be displaced in the first place!!)
- return (m_xform(local) - m_prev_xform(local)) / m_timeStep;
- }
-
- // NB: m_xform.getBasis() * local == m_xform(local) - m_xform.getOrigin()
- return actualLinVelocity() + actualAngVelocity().cross(local);
-}
-
-
-const
- MT_Vector3&
-SM_Object::
-getReactionForce(
-) const {
- return m_reaction_force;
-}
-
- void
-SM_Object::
-getMatrix(
- double *m
-) const {
- std::copy(&m_ogl_matrix[0], &m_ogl_matrix[16], &m[0]);
-}
-
-const
- double *
-SM_Object::
-getMatrix(
-) const {
- return m_ogl_matrix;
-}
-
-// Still need this???
-const
- MT_Transform&
-SM_Object::
-getScaledTransform(
-) const {
- return m_xform;
-}
-
- DT_ObjectHandle
-SM_Object::
-getObjectHandle(
-) const {
- return m_object;
-}
-
- DT_ShapeHandle
-SM_Object::
-getShapeHandle(
-) const {
- return m_shape;
-}
-
- SM_Object *
-SM_Object::
-getDynamicParent(
-) {
- return m_dynamicParent;
-}
-
- void
-SM_Object::
-setRigidBody(
- bool is_rigid_body
-) {
- m_is_rigid_body = is_rigid_body;
-}
-
- bool
-SM_Object::
-isRigidBody(
-) const {
- return m_is_rigid_body;
-}
-
-const
- MT_Vector3
-SM_Object::
-actualLinVelocity(
-) const {
- return m_combined_lin_vel + getNextFrame().getLinearVelocity();
-};
-
-const
- MT_Vector3
-SM_Object::
-actualAngVelocity(
-) const {
- return m_combined_ang_vel + getNextFrame().getAngularVelocity();
-}
-
-
-SM_MotionState&
-SM_Object::
-getCurrentFrame()
-{
- return m_frames[1];
-}
-
-SM_MotionState&
-SM_Object::
-getPreviousFrame()
-{
- return m_frames[0];
-}
-
-SM_MotionState &
-SM_Object::
-getNextFrame()
-{
- return m_frames[2];
-}
-
-const SM_MotionState &
-SM_Object::
-getCurrentFrame() const
-{
- return m_frames[1];
-}
-
-const SM_MotionState &
-SM_Object::
-getPreviousFrame() const
-{
- return m_frames[0];
-}
-
-const SM_MotionState &
-SM_Object::
-getNextFrame() const
-{
- return m_frames[2];
-}
-
-
-const MT_Point3&
-SM_Object::
-getPosition() const
-{
- return m_frames[1].getPosition();
-}
-
-const MT_Quaternion&
-SM_Object::
-getOrientation() const
-{
- return m_frames[1].getOrientation();
-}
-
-const MT_Vector3&
-SM_Object::
-getLinearVelocity() const
-{
- return m_frames[1].getLinearVelocity();
-}
-
-const MT_Vector3&
-SM_Object::
-getAngularVelocity() const
-{
- return m_frames[1].getAngularVelocity();
-}
-
-void
-SM_Object::
-interpolate(MT_Scalar timeStep)
-{
- if (!actualLinVelocity().fuzzyZero() || !actualAngVelocity().fuzzyZero())
- {
- getCurrentFrame().setTime(timeStep);
- getCurrentFrame().lerp(getPreviousFrame(), getNextFrame());
- notifyClient();
- }
-}
-
-void
-SM_Object::
-endFrame()
-{
- getPreviousFrame() = getNextFrame();
- getCurrentFrame() = getNextFrame();
- m_static = 0;
-}
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
deleted file mode 100644
index f0791bbf89f..00000000000
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-/**
- * $Id$
- * Copyright (C) 2001 NaN Technologies B.V.
- * The physics scene.
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WIN32
-#pragma warning(disable : 4786) // shut off 255 char limit debug template warning
-#endif
-
-#include "SM_Scene.h"
-#include "SM_Object.h"
-#include "SM_FhObject.h"
-
-#include "SM_Debug.h"
-
-#include <algorithm>
-
-SM_Scene::SM_Scene() :
- m_scene(DT_CreateScene()),
- m_respTable(DT_CreateRespTable()),
- m_secondaryRespTable(DT_CreateRespTable()),
- m_fixRespTable(DT_CreateRespTable()),
- m_forceField(0.0, 0.0, 0.0),
- m_frames(0)
-{
- for (int i = 0 ; i < NUM_RESPONSE; i++)
- {
- m_ResponseClass[i] = DT_GenResponseClass(m_respTable);
- m_secondaryResponseClass[i] = DT_GenResponseClass(m_secondaryRespTable);
- m_fixResponseClass[i] = DT_GenResponseClass(m_fixRespTable);
- }
-
- /* Sensor */
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[SENSOR_RESPONSE], m_ResponseClass[FH_RESPONSE], 0, DT_NO_RESPONSE, this);
-
- /* Static */
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[STATIC_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Object::boing, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[STATIC_RESPONSE], m_ResponseClass[FH_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
-
- /* Object */
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], SM_Scene::boing, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_Object::boing, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Object::boing, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[FH_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
-
- /* Fh Object */
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_FhObject::ray_hit, DT_SIMPLE_RESPONSE, this);
- DT_AddPairResponse(m_respTable, m_ResponseClass[FH_RESPONSE], m_ResponseClass[FH_RESPONSE], 0, DT_NO_RESPONSE, this);
-
- /* Object (Fix Pass) */
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[SENSOR_RESPONSE], 0, DT_NO_RESPONSE, this);
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[STATIC_RESPONSE], SM_Object::fix, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[OBJECT_RESPONSE], SM_Object::fix, DT_BROAD_RESPONSE, this);
- DT_AddPairResponse(m_fixRespTable, m_ResponseClass[OBJECT_RESPONSE], m_ResponseClass[FH_RESPONSE], 0, DT_NO_RESPONSE, this);
-}
-
-void SM_Scene::addTouchCallback(int response_class, DT_ResponseCallback callback, void *user)
-{
- DT_AddClassResponse(m_secondaryRespTable, m_secondaryResponseClass[response_class], callback, DT_BROAD_RESPONSE, user);
-}
-
-void SM_Scene::addSensor(SM_Object& object)
-{
- T_ObjectList::iterator i =
- std::find(m_objectList.begin(), m_objectList.end(), &object);
- if (i == m_objectList.end())
- {
- object.calcXform();
- m_objectList.push_back(&object);
- DT_AddObject(m_scene, object.getObjectHandle());
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass [SENSOR_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]);
- }
-}
-
-void SM_Scene::add(SM_Object& object) {
- object.calcXform();
- m_objectList.push_back(&object);
- DT_AddObject(m_scene, object.getObjectHandle());
- if (object.isDynamic()) {
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[OBJECT_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[OBJECT_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[OBJECT_RESPONSE]);
- } else {
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[STATIC_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[STATIC_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[STATIC_RESPONSE]);
- }
-
- SM_FhObject *fh_object = object.getFhObject();
-
- if (fh_object) {
- DT_AddObject(m_scene, fh_object->getObjectHandle());
- DT_SetResponseClass(m_respTable, fh_object->getObjectHandle(), m_ResponseClass[FH_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, fh_object->getObjectHandle(), m_secondaryResponseClass[FH_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, fh_object->getObjectHandle(), m_fixResponseClass[FH_RESPONSE]);
- }
-}
-
-void SM_Scene::requestCollisionCallback(SM_Object &object)
-{
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[OBJECT_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[OBJECT_RESPONSE]);
-// DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[OBJECT_RESPONSE]);
-}
-
-void SM_Scene::remove(SM_Object& object) {
- //std::cout << "SM_Scene::remove this =" << this << "object = " << &object << std::endl;
- T_ObjectList::iterator i =
- std::find(m_objectList.begin(), m_objectList.end(), &object);
- if (!(i == m_objectList.end()))
- {
- std::swap(*i, m_objectList.back());
- m_objectList.pop_back();
- DT_RemoveObject(m_scene, object.getObjectHandle());
-
- SM_FhObject *fh_object = object.getFhObject();
-
- if (fh_object) {
- DT_RemoveObject(m_scene, fh_object->getObjectHandle());
- }
- }
- else {
- // tried to remove an object that is not in the scene
- //assert(false);
- }
-}
-
-void SM_Scene::beginFrame()
-{
- T_ObjectList::iterator i;
- // Apply a forcefield (such as gravity)
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
- (*i)->applyForceField(m_forceField);
-
-}
-
-void SM_Scene::endFrame()
-{
- T_ObjectList::iterator i;
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
- (*i)->clearForce();
-}
-
-bool SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate)
-{
- if (!m_frames)
- {
- if (ticrate > 0.)
- m_frames = (unsigned int)(curtime*ticrate) + 1.0;
- else
- m_frames = (unsigned int)(curtime*65536.0);
- }
-
- // Divide the timeStep into a number of subsamples of size roughly
- // equal to subS (might be a little smaller).
- MT_Scalar subStep;
- int num_samples;
- int frames = m_frames;
-
- // Compute the number of steps to do this update.
- if (ticrate > 0.0)
- {
- // Fixed time step
- subStep = 1.0/ticrate;
- num_samples = (unsigned int)(curtime*ticrate + 1.0) - m_frames;
-
- if (num_samples > 4)
- {
- std::cout << "Dropping physics frames! frames:" << num_samples << " substep: " << subStep << std::endl;
- MT_Scalar tr = ticrate;
- do
- {
- frames = frames / 2;
- tr = tr / 2.0;
- num_samples = (unsigned int)(curtime*tr + 1.0) - frames;
- subStep *= 2.0;
- } while (num_samples > 8);
- std::cout << " frames:" << num_samples << " substep: " << subStep << std::endl;
- }
- }
- else
- {
- // Variable time step. (old update)
- // Integrate at least 100 Hz
- MT_Scalar timeStep = curtime - m_frames/65536.0;
- subStep = timeStep > 0.01 ? 0.01 : timeStep;
- num_samples = int(timeStep * 0.01);
- if (num_samples < 1)
- num_samples = 1;
- }
-
- // Do a physics timestep.
- T_ObjectList::iterator i;
- if (num_samples > 0)
- {
- // Do the integration steps per object.
- for (int step = 0; step != num_samples; ++step)
- {
- MT_Scalar time;
- if (ticrate > 0.)
- time = MT_Scalar(frames + step + 1) * subStep;
- else
- time = MT_Scalar(m_frames)/65536.0 + MT_Scalar(step + 1)*subStep;
-
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
- (*i)->endFrame();
- // Apply a forcefield (such as gravity)
- (*i)->integrateForces(subStep);
- // And second we update the object positions by performing
- // an integration step for each object
- (*i)->integrateMomentum(subStep);
- }
-
- // So now first we let the physics scene respond to
- // new forces, velocities set externally.
- // The collsion and friction impulses are computed here.
- // Collision phase
- DT_Test(m_scene, m_respTable);
-
- // Contact phase
- DT_Test(m_scene, m_fixRespTable);
-
- // Finish this timestep by saving al state information for the next
- // timestep and clearing the accumulated forces.
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
- (*i)->relax();
- (*i)->proceedKinematic(subStep);
- (*i)->saveReactionForce(subStep);
- (*i)->getNextFrame().setTime(time);
- //(*i)->clearForce();
- }
- }
- }
-
- if (ticrate > 0)
- {
- // Interpolate between time steps.
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
- (*i)->interpolate(curtime);
-
- //only update the m_frames after an actual physics timestep
- if (num_samples)
- {
- m_frames = (unsigned int)(curtime*ticrate) + 1.0;
- }
- }
- else
- {
- m_frames = (unsigned int)(curtime*65536.0);
- }
-
- return num_samples != 0;
-}
-
-void SM_Scene::notifyCollision(SM_Object *obj1, SM_Object *obj2)
-{
- // For each pair of object that collided, call the corresponding callback.
- if (m_secondaryRespTable)
- DT_CallResponse(m_secondaryRespTable, obj1->getObjectHandle(), obj2->getObjectHandle(), 0);
-}
-
-
-SM_Object *SM_Scene::rayTest(void *ignore_client,
- const MT_Point3& from, const MT_Point3& to,
- MT_Point3& result, MT_Vector3& normal) const {
-#ifdef SM_DEBUG_RAYCAST
- std::cout << "ray: { " << from << " } - { " << to << " }" << std::endl;
-#endif
-
- DT_Vector3 n, dfrom, dto;
- DT_Scalar param;
- from.getValue(dfrom);
- to.getValue(dto);
- SM_Object *hit_object = (SM_Object *)
- DT_RayCast(m_scene, ignore_client, dfrom, dto, 1., &param, n);
-
- if (hit_object) {
- //result = hit_object->getWorldCoord(from + (to - from)*param);
- result = from + (to - from) * param;
- normal.setValue(n);
-#ifdef SM_DEBUG_RAYCAST
- std::cout << "ray: { " << from << " } -> { " << to << " }: { " << result
- << " } (" << param << "), normal = { " << normal << " }" << std::endl;
-#endif
- }
-
- return hit_object;
-}
-
-void SM_Scene::clearObjectCombinedVelocities() {
-
- T_ObjectList::iterator i;
-
- for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
-
- (*i)->clearCombinedVelocities();
-
- }
-
-}
-
-
-void SM_Scene::setSecondaryRespTable(DT_RespTableHandle secondaryRespTable) {
- m_secondaryRespTable = secondaryRespTable;
-}
-
-
-DT_Bool SM_Scene::boing(
- void *client_data,
- void *object1,
- void *object2,
- const DT_CollData *
-){
- SM_Scene *scene = (SM_Scene *)client_data;
- SM_Object *obj1 = (SM_Object *)object1;
- SM_Object *obj2 = (SM_Object *)object2;
-
- scene->notifyCollision(obj1, obj2); // Record this collision for client callbacks
-
-#ifdef SM_DEBUG_BOING
- printf("SM_Scene::boing\n");
-#endif
-
- return DT_CONTINUE;
-}
-
-SM_Scene::~SM_Scene()
-{
- //std::cout << "SM_Scene::~ SM_Scene(): destroy " << this << std::endl;
-// if (m_objectList.begin() != m_objectList.end())
-// std::cout << "SM_Scene::~SM_Scene: There are still objects in the Sumo scene!" << std::endl;
- for (T_ObjectList::iterator it = m_objectList.begin() ; it != m_objectList.end() ; it++)
- delete *it;
-
- DT_DestroyRespTable(m_respTable);
- DT_DestroyRespTable(m_secondaryRespTable);
- DT_DestroyRespTable(m_fixRespTable);
- DT_DestroyScene(m_scene);
-}
diff --git a/source/gameengine/Physics/Sumo/Makefile b/source/gameengine/Physics/Sumo/Makefile
deleted file mode 100644
index 69efc4d84eb..00000000000
--- a/source/gameengine/Physics/Sumo/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# $Id$
-#
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-#
-#
-
-SOURCEDIR = source/gameengine/Physics/Sumo
-LIBNAME = sumo
-DIR = $(OCGDIR)/gameengine/blphys/$(LIBNAME)
-DIRS = Fuzzics
-
-include nan_compile.mk
-
-CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-
-CPPFLAGS += -I$(OPENGL_HEADERS)
-CPPFLAGS += -I$(NAN_STRING)/include
-CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
-CPPFLAGS += -I$(NAN_SOLID)/include
-CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
-CPPFLAGS += -I../../Physics/common
-CPPFLAGS += -I../../Physics/Dummy
-
-include nan_subdirs.mk
diff --git a/source/gameengine/Physics/Sumo/SConscript b/source/gameengine/Physics/Sumo/SConscript
deleted file mode 100644
index a228a986af2..00000000000
--- a/source/gameengine/Physics/Sumo/SConscript
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/python
-Import ('env')
-
-sources = ['SumoPHYCallbackBridge.cpp',
- 'SumoPhysicsController.cpp',
- 'SumoPhysicsEnvironment.cpp',
- 'Fuzzics/src/SM_FhObject.cpp',
- 'Fuzzics/src/SM_Object.cpp',
- 'Fuzzics/src/SM_Scene.cpp',
- 'Fuzzics/src/SM_MotionState.cpp'
- ]
-
-incs =['.',
- '../common',
- 'Fuzzics/include',
- '#/intern/moto/include'
- ]
-incs += [env['BF_SOLID_INC']]
-
-cflags = []
-if env['OURPLATFORM']=='win32-vc':
- cflags.append('/GR')
- cflags.append('/O1')
-
-env.BlenderLib ( 'bf_sumo', sources, incs, [], libtype=['core','player'], priority=[400, 55] , compileflags=cflags)
diff --git a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp b/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp
deleted file mode 100644
index 1992bbe3421..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "SumoPHYCallbackBridge.h"
-#include "PHY_IPhysicsController.h"
-#include "SM_Object.h"
-
-
-SumoPHYCallbackBridge::SumoPHYCallbackBridge(void* clientData,PHY_ResponseCallback phyCallback)
-:m_orgClientData(clientData),
-m_phyCallback(phyCallback)
-{
-
-}
-DT_Bool SumoPHYCallbackBridge::StaticSolidToPHYCallback(void *client_data,
- void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data)
-{
- SumoPHYCallbackBridge* bridge = static_cast<SumoPHYCallbackBridge*>(client_data);
- bridge->SolidToPHY(client_object1,client_object2,coll_data);
- return false;
-}
-
-DT_Bool SumoPHYCallbackBridge::SolidToPHY(void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data)
-{
-
- SM_Object* smObject1 = static_cast<SM_Object*>(client_object1);
- SM_Object* smObject2 = static_cast<SM_Object*>(client_object2);
-
- PHY_IPhysicsController* ctrl1 = static_cast<PHY_IPhysicsController*>(smObject1->getPhysicsClientObject());
- PHY_IPhysicsController* ctrl2 = static_cast<PHY_IPhysicsController*>(smObject2->getPhysicsClientObject());
-
- if (!ctrl1 || !ctrl2)
- {
- //todo: check which objects are not linked up properly
- return false;
- }
- if (coll_data)
- {
- PHY_CollData phyCollData;
-
- phyCollData.m_point1[0] = coll_data->point1[0];
- phyCollData.m_point1[1] = coll_data->point1[1];
- phyCollData.m_point1[2] = coll_data->point1[2];
- phyCollData.m_point1[3] = 0.f;
-
- phyCollData.m_point2[0] = coll_data->point2[0];
- phyCollData.m_point2[1] = coll_data->point2[1];
- phyCollData.m_point2[2] = coll_data->point2[2];
- phyCollData.m_point2[3] = 0.f;
-
- phyCollData.m_normal[0] = coll_data->normal[0];
- phyCollData.m_normal[1] = coll_data->normal[1];
- phyCollData.m_normal[2] = coll_data->normal[2];
- phyCollData.m_normal[3] = 0.f;
-
-
- return m_phyCallback(m_orgClientData,
- ctrl1,ctrl2,&phyCollData);
- }
-
- return m_phyCallback(m_orgClientData,
- ctrl1,ctrl2,0);
-
-}
-
diff --git a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h b/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h
deleted file mode 100644
index cc980f3961d..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPHYCallbackBridge.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SUMO_PHY_CALLBACK_BRIDGE_H
-#define SUMO_PHY_CALLBACK_BRIDGE_H
-
-#include <SOLID/SOLID.h>
-#include "PHY_DynamicTypes.h"
-
-class SumoPHYCallbackBridge
-{
- void* m_orgClientData;
- PHY_ResponseCallback m_phyCallback;
-
-public:
-
- SumoPHYCallbackBridge(void* clientData,PHY_ResponseCallback phyCallback);
-
- static DT_Bool StaticSolidToPHYCallback(void *client_data,
- void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data);
-
- DT_Bool SolidToPHY(void *client_object1,
- void *client_object2,
- const DT_CollData *coll_data);
-
-
-};
-
-#endif //SUMO_PHY_CALLBACK_BRIDGE_H
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
deleted file mode 100644
index 56caa9236bf..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp
+++ /dev/null
@@ -1,495 +0,0 @@
-/**
- * @file $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "SumoPhysicsController.h"
-#include "PHY_IMotionState.h"
-#include "SM_Object.h"
-#include "MT_Quaternion.h"
-
-
-SumoPhysicsController::SumoPhysicsController(
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- class PHY_IMotionState* motionstate,
-
- bool dyna)
- :
- m_sumoObj(sumoObj) ,
- m_sumoScene(sumoScene),
- m_bFirstTime(true),
- m_bDyna(dyna),
- m_MotionState(motionstate)
-{
- if (m_sumoObj)
- {
-
- PHY__Vector3 pos1;
- getPosition(pos1);
- MT_Point3 pos(pos1);
-
- //temp debugging check
- //assert(pos.length() < 100000.f);
-
- //need this to do the upcast after the solid/sumo collision callback
- m_sumoObj->setPhysicsClientObject(this);
- //if it is a dyna, register for a callback
- m_sumoObj->registerCallback(*this);
- }
-};
-
-
-
-SumoPhysicsController::~SumoPhysicsController()
-{
- if (m_sumoObj)
- {
- m_sumoScene->remove(*m_sumoObj);
-
- delete m_sumoObj;
- m_sumoObj = NULL;
- }
-}
-
-float SumoPhysicsController::getMass()
-{
- if (m_sumoObj)
- {
- const SM_ShapeProps *shapeprops = m_sumoObj->getShapeProps();
- if(shapeprops!=NULL) return shapeprops->m_mass;
- }
- return 0.f;
-}
-
-bool SumoPhysicsController::SynchronizeMotionStates(float)
-{
- if (m_bFirstTime)
- {
- setSumoTransform(!m_bFirstTime);
- m_bFirstTime = false;
- }
- return false;
-}
-
-
-
-
-void SumoPhysicsController::GetWorldOrientation(MT_Matrix3x3& mat)
-{
- float orn[4];
- m_MotionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
- MT_Quaternion quat(orn);
- mat.setRotation(quat);
-
-}
-
-void SumoPhysicsController::getPosition(PHY__Vector3& pos) const
-{
- assert(m_sumoObj);
-
- pos[0] = m_sumoObj->getPosition()[0];
- pos[1] = m_sumoObj->getPosition()[0];
- pos[2] = m_sumoObj->getPosition()[0];
-
- //m_MotionState->getWorldPosition(pos[0],pos[1],pos[2]);
-}
-
-void SumoPhysicsController::GetWorldPosition(MT_Point3& pos)
-{
-// assert(m_sumoObj);
-
-// pos[0] = m_sumoObj->getPosition()[0];
-// pos[1] = m_sumoObj->getPosition()[0];
-// pos[2] = m_sumoObj->getPosition()[0];
-
- float worldpos[3];
- m_MotionState->getWorldPosition(worldpos[0],worldpos[1],worldpos[2]);
- pos[0]=worldpos[0];
- pos[1]=worldpos[1];
- pos[2]=worldpos[2];
-}
-
-void SumoPhysicsController::GetWorldScaling(MT_Vector3& scale)
-{
- float worldscale[3];
- m_MotionState->getWorldScaling(worldscale[0],worldscale[1],worldscale[2]);
- scale[0]=worldscale[0];
- scale[1]=worldscale[1];
- scale[2]=worldscale[2];
-}
-
-
- // kinematic methods
-void SumoPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Matrix3x3 mat;
- GetWorldOrientation(mat);
- MT_Vector3 dloc(dlocX,dlocY,dlocZ);
-
- MT_Point3 newpos = m_sumoObj->getPosition();
-
- newpos += (local ? mat * dloc : dloc);
- m_sumoObj->setPosition(newpos);
- }
-
-}
-void SumoPhysicsController::RelativeRotate(const float drot[12],bool local)
-{
- if (m_sumoObj )
- {
- MT_Matrix3x3 drotmat(drot);
- MT_Matrix3x3 currentOrn;
- GetWorldOrientation(currentOrn);
-
- m_sumoObj->setOrientation(m_sumoObj->getOrientation()*(local ?
- drotmat : (currentOrn.inverse() * drotmat * currentOrn)).getRotation());
- }
-
-}
-void SumoPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
-{
- m_sumoObj->setOrientation(MT_Quaternion(quatImag0,quatImag1,quatImag2,quatReal));
-}
-
-void SumoPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
-{
- const MT_Quaternion& q = m_sumoObj->getOrientation();
- quatImag0 = q[0];
- quatImag1 = q[1];
- quatImag2 = q[2];
- quatReal = q[3];
-}
-
-void SumoPhysicsController::setPosition(float posX,float posY,float posZ)
-{
- m_sumoObj->setPosition(MT_Point3(posX,posY,posZ));
-}
-
-void SumoPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
-{
- if (!m_bDyna)
- m_sumoObj->setScaling(MT_Vector3(scaleX,scaleY,scaleZ));
-}
-
- // physics methods
-void SumoPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Vector3 torque(torqueX,torqueY,torqueZ);
-
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
- m_sumoObj->applyTorque(local ?
- orn * torque :
- torque);
- }
-}
-
-void SumoPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Vector3 force(forceX,forceY,forceZ);
-
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
-
- m_sumoObj->applyCenterForce(local ?
- orn * force :
- force);
- }
-}
-
-void SumoPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
-{
- if (m_sumoObj)
- {
- MT_Vector3 ang_vel(ang_velX,ang_velY,ang_velZ);
-
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
-
- m_sumoObj->setExternalAngularVelocity(local ?
- orn * ang_vel :
- ang_vel);
- }
-}
-
-void SumoPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)
-{
- if (m_sumoObj )
- {
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
-
- MT_Vector3 lin_vel(lin_velX,lin_velY,lin_velZ);
- m_sumoObj->setExternalLinearVelocity(local ?
- orn * lin_vel :
- lin_vel);
- }
-}
-
-void SumoPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
-{
- if (m_sumoObj)
- m_sumoObj->resolveCombinedVelocities(MT_Vector3(linvelX,linvelY,linvelZ),MT_Vector3(angVelX,angVelY,angVelZ));
-}
-
-
-
-
-void SumoPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
-{
- if (m_sumoObj)
- {
- MT_Point3 attach(attachX,attachY,attachZ);
- MT_Vector3 impulse(impulseX,impulseY,impulseZ);
- m_sumoObj->applyImpulse(attach,impulse);
- }
-
-}
-
-void SumoPhysicsController::SuspendDynamics()
-{
- m_suspendDynamics=true;
-
- if (m_sumoObj)
- {
- m_sumoObj->suspendDynamics();
- m_sumoObj->setLinearVelocity(MT_Vector3(0,0,0));
- m_sumoObj->setAngularVelocity(MT_Vector3(0,0,0));
- m_sumoObj->calcXform();
- }
-}
-
-void SumoPhysicsController::RestoreDynamics()
-{
- m_suspendDynamics=false;
-
- if (m_sumoObj)
- {
- m_sumoObj->restoreDynamics();
- }
-}
-
-
-/**
- reading out information from physics
-*/
-void SumoPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
-{
- if (m_sumoObj)
- {
- // get velocity from the physics object (m_sumoObj)
- const MT_Vector3& vel = m_sumoObj->getLinearVelocity();
- linvX = vel[0];
- linvY = vel[1];
- linvZ = vel[2];
- }
- else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
- }
-}
-
-/**
- GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
-*/
-void SumoPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
-{
- if (m_sumoObj)
- {
- MT_Point3 pos(posX,posY,posZ);
- // get velocity from the physics object (m_sumoObj)
- const MT_Vector3& vel = m_sumoObj->getVelocity(pos);
- linvX = vel[0];
- linvY = vel[1];
- linvZ = vel[2];
- }
- else
- {
- linvX = 0.f;
- linvY = 0.f;
- linvZ = 0.f;
-
- }
-}
-
-void SumoPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
-{
- const MT_Vector3& force = m_sumoObj->getReactionForce();
- forceX = force[0];
- forceY = force[1];
- forceZ = force[2];
-}
-
-void SumoPhysicsController::setRigidBody(bool rigid)
-{
- m_sumoObj->setRigidBody(rigid);
-}
-
-void SumoPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
-{
- m_MotionState = motionstate;
-
- SM_Object* dynaparent=0;
- SumoPhysicsController* sumoparentctrl = (SumoPhysicsController* )parentctrl;
-
- if (sumoparentctrl)
- {
- dynaparent = sumoparentctrl->GetSumoObject();
- }
-
- SM_Object* orgsumoobject = m_sumoObj;
-
-
- m_sumoObj = new SM_Object(
- orgsumoobject->getShapeHandle(),
- orgsumoobject->getMaterialProps(),
- orgsumoobject->getShapeProps(),
- dynaparent);
-
- m_sumoObj->setRigidBody(orgsumoobject->isRigidBody());
-
- m_sumoObj->setMargin(orgsumoobject->getMargin());
- m_sumoObj->setPosition(orgsumoobject->getPosition());
- m_sumoObj->setOrientation(orgsumoobject->getOrientation());
- //if it is a dyna, register for a callback
- m_sumoObj->registerCallback(*this);
-
- m_sumoScene->add(* (m_sumoObj));
-}
-
-PHY_IMotionState* SumoPhysicsController::GetMotionState()
-{
- return m_MotionState;
-}
-
-void SumoPhysicsController::SetSimulatedTime(float)
-{
-}
-
-
-void SumoPhysicsController::WriteMotionStateToDynamics(bool)
-{
-
-}
-// this is the actual callback from sumo, and the position/orientation
-//is written to the scenegraph, using the motionstate abstraction
-
-void SumoPhysicsController::do_me()
-{
- MT_assert(m_sumoObj);
- const MT_Point3& pos = m_sumoObj->getPosition();
- const MT_Quaternion& orn = m_sumoObj->getOrientation();
-
- MT_assert(m_MotionState);
- m_MotionState->setWorldPosition(pos[0],pos[1],pos[2]);
- m_MotionState->setWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
-}
-
-
-void SumoPhysicsController::setSumoTransform(bool nondynaonly)
-{
- if (!nondynaonly || !m_bDyna)
- {
- if (m_sumoObj)
- {
- MT_Point3 pos;
- GetWorldPosition(pos);
-
- m_sumoObj->setPosition(pos);
- if (m_bDyna)
- {
- m_sumoObj->setScaling(MT_Vector3(1,1,1));
- } else
- {
- MT_Vector3 scale;
- GetWorldScaling(scale);
- m_sumoObj->setScaling(scale);
- }
- MT_Matrix3x3 orn;
- GetWorldOrientation(orn);
- m_sumoObj->setOrientation(orn.getRotation());
- m_sumoObj->calcXform();
- }
- }
-}
-
-
- // clientinfo for raycasts for example
-void* SumoPhysicsController::getNewClientInfo()
-{
- if (m_sumoObj)
- return m_sumoObj->getClientObject();
- return 0;
-
-}
-void SumoPhysicsController::setNewClientInfo(void* clientinfo)
-{
- if (m_sumoObj)
- {
- SM_ClientObject* clOb = static_cast<SM_ClientObject*> (clientinfo);
- m_sumoObj->setClientObject(clOb);
- }
-
-}
-
-void SumoPhysicsController::calcXform()
-{
- if (m_sumoObj)
- m_sumoObj->calcXform();
-}
-
-void SumoPhysicsController::SetMargin(float margin)
-{
- if (m_sumoObj)
- m_sumoObj->setMargin(margin);
-}
-
-float SumoPhysicsController::GetMargin() const
-{
- if (m_sumoObj)
- m_sumoObj->getMargin();
- return 0.f;
-}
-
-float SumoPhysicsController::GetRadius() const
-{
- if (m_sumoObj && m_sumoObj->getShapeProps())
- {
- return m_sumoObj->getShapeProps()->m_radius;
- }
- return 0.f;
-
-}
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.h b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
deleted file mode 100644
index adf29649f18..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * @file $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __SUMO_PHYSICSCONTROLLER_H
-#define __SUMO_PHYSICSCONTROLLER_H
-
-#include "PHY_IPhysicsController.h"
-#include "SM_Scene.h"
-#include "SM_Callback.h"
-
-/**
- * Sumo Physics Controller, a special kind of a PhysicsController.
- * A Physics Controller is a special kind of Scene Graph Transformation Controller.
- * Each time the scene graph get's updated, the controller get's a chance
- * in the 'Update' method to reflect changes.
- *
- * Sumo uses the SOLID library for collision detection.
- */
-class SumoPhysicsController : public PHY_IPhysicsController , public SM_Callback
-
-
-{
-
-
-public:
- SumoPhysicsController(
- class SM_Scene* sumoScene,
- class SM_Object* sumoObj,
- class PHY_IMotionState* motionstate,
- bool dyna);
-
- virtual ~SumoPhysicsController();
-
- /**
- * @name Kinematic Methods.
- */
- /*@{*/
- virtual void RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
- /**
- * @param drot a 3x4 matrix. This will treated as a 3x3 rotation matrix.
- * @warning RelativeRotate expects a 3x4 matrix. The fourth column is padding.
- */
- virtual void RelativeRotate(const float drot[12],bool local);
- virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
- virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
- virtual void setPosition(float posX,float posY,float posZ);
- virtual void getPosition(PHY__Vector3& pos) const;
-
- virtual void setScaling(float scaleX,float scaleY,float scaleZ);
- /*@}*/
-
- /**
- * @name Physics Methods
- */
- /*@{*/
- virtual void ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local);
- virtual void ApplyForce(float forceX,float forceY,float forceZ,bool local);
- virtual void SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
- virtual void SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
- virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
- virtual void applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
- virtual void SetActive(bool active){};
- virtual void SuspendDynamics();
- virtual void RestoreDynamics();
- /*@}*/
-
-
- /**
- * reading out information from physics
- */
- virtual void GetLinearVelocity(float& linvX,float& linvY,float& linvZ);
- /**
- * GetVelocity parameters are in geometric coordinates (Origin is not center of mass!).
- */
- virtual void GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ);
- virtual float getMass();
- virtual void getReactionForce(float& forceX,float& forceY,float& forceZ);
- virtual void setRigidBody(bool rigid);
-
-
- virtual void PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl);
-
- // TODO: remove next line !
- virtual void SetSimulatedTime(float time);
-
- virtual void WriteDynamicsToMotionState() {};
- virtual void WriteMotionStateToDynamics(bool nondynaonly);
- virtual class PHY_IMotionState* GetMotionState();
-
- /**
- * call from Scene Graph Node to 'update'.
- */
- virtual bool SynchronizeMotionStates(float time);
-
- virtual void calcXform();
- virtual void SetMargin(float margin) ;
- virtual float GetMargin() const;
- virtual float GetRadius() const ;
- virtual void SetRadius(float margin) { SetMargin(margin); }
-
-
- // clientinfo for raycasts for example
- virtual void* getNewClientInfo();
- virtual void setNewClientInfo(void* clientinfo);
-
- float getFriction() { return m_friction;}
- float getRestitution() { return m_restitution;}
-
- /**
- * Sumo callback
- */
- virtual void do_me();
-
- class SM_Object* GetSumoObject ()
- {
- return m_sumoObj;
- };
-
- void GetWorldOrientation(class MT_Matrix3x3& mat);
- void GetWorldPosition(MT_Point3& pos);
- void GetWorldScaling(MT_Vector3& scale);
-
- float GetLinVelocityMin() const { return 0.f; }
- void SetLinVelocityMin(float val) { }
- float GetLinVelocityMax() const { return 0.f; }
- void SetLinVelocityMax(float val) { }
-
-
-// void SetSumoObject(class SM_Object* sumoObj) {
-// m_sumoObj = sumoObj;
-// }
-// void SetSumoScene(class SM_Scene* sumoScene) {
-// m_sumoScene = sumoScene;
-// }
-
- void setSumoTransform(bool nondynaonly);
-
-
-private:
- class SM_Object* m_sumoObj;
- class SM_Scene* m_sumoScene; // needed for replication
- bool m_bFirstTime;
- bool m_bDyna;
-
- float m_friction;
- float m_restitution;
-
-
- bool m_suspendDynamics;
-
- bool m_firstTime;
- bool m_bFullRigidBody;
- bool m_bPhantom; // special flag for objects that are not affected by physics 'resolver'
-
- // data to calculate fake velocities for kinematic objects (non-dynas)
- bool m_bKinematic;
- bool m_bPrevKinematic;
-
- float m_lastTime;
-
- class PHY_IMotionState* m_MotionState;
-
-
-};
-
-#endif //__SUMO_PHYSICSCONTROLLER_H
-
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
deleted file mode 100644
index b4daf0a3f80..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#include <string.h> // memset
-#include "SumoPhysicsEnvironment.h"
-#include "PHY_IMotionState.h"
-#include "SumoPhysicsController.h"
-#include "SM_Scene.h"
-#include "SumoPHYCallbackBridge.h"
-#include <SOLID/SOLID.h>
-
-SumoPhysicsEnvironment::SumoPhysicsEnvironment()
-{
- m_fixedTimeStep = 1.f/60.f;
- m_useFixedTimeStep = true;
- m_currentTime = 0.f;
-
- m_sumoScene = new SM_Scene();
-}
-
-
-
-SumoPhysicsEnvironment::~SumoPhysicsEnvironment()
-{
- delete m_sumoScene;
-}
-
-
-
-void SumoPhysicsEnvironment::beginFrame()
-{
- m_sumoScene->beginFrame();
-}
-
-void SumoPhysicsEnvironment::endFrame()
-{
- m_sumoScene->endFrame();
-}
-
-void SumoPhysicsEnvironment::setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep)
-{
- m_useFixedTimeStep = useFixedTimeStep;
- if (m_useFixedTimeStep)
- {
- m_fixedTimeStep = fixedTimeStep;
- } else
- {
- m_fixedTimeStep = 0.f;
- }
- //reset current time ?
- m_currentTime = 0.f;
-}
-float SumoPhysicsEnvironment::getFixedTimeStep()
-{
- return m_fixedTimeStep;
-}
-
-
-bool SumoPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep,float interval)
-{
-
- bool result = false;
- if (m_useFixedTimeStep)
- {
- m_currentTime += timeStep;
- float ticrate = 1.f/m_fixedTimeStep;
-
- result = m_sumoScene->proceed(curTime, ticrate);
- } else
- {
- m_currentTime += timeStep;
- result = m_sumoScene->proceed(m_currentTime, timeStep);
- }
- return result;
-}
-
-void SumoPhysicsEnvironment::setGravity(float x,float y,float z)
-{
- m_sumoScene->setForceField(MT_Vector3(x,y,z));
-}
-
-int SumoPhysicsEnvironment::createConstraint(
- class PHY_IPhysicsController* ctrl,
- class PHY_IPhysicsController* ctrl2,
- PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,
- float axisX,float axisY,float axisZ,
- float axis1X,float axis1Y,float axis1Z,
- float axis2X,float axis2Y,float axis2Z,
- int flag
- )
-{
- int constraintid = 0;
- return constraintid;
-}
-
-void SumoPhysicsEnvironment::removeConstraint(int constraintid)
-{
- if (constraintid)
- {
- }
-}
-
-PHY_IPhysicsController* SumoPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,
- float fromX,float fromY,float fromZ,
- float toX,float toY,float toZ)
-{
- SumoPhysicsController* ignoreCtr = static_cast<SumoPhysicsController*> (filterCallback.m_ignoreController);
-
- //collision detection / raytesting
- MT_Point3 hit, normal;
- PHY_RayCastResult result;
-
- SM_Object* sm_ignore = 0;
- if (ignoreCtr)
- sm_ignore = ignoreCtr->GetSumoObject();
-
- memset(&result, 0, sizeof(result));
-
- SM_Object* smOb = m_sumoScene->rayTest(sm_ignore,MT_Point3(fromX, fromY, fromZ),MT_Point3(toX, toY, toZ), hit, normal);
- if (smOb)
- {
- result.m_controller = (PHY_IPhysicsController *) smOb->getPhysicsClientObject();
- result.m_hitPoint[0] = hit[0];
- result.m_hitPoint[1] = hit[1];
- result.m_hitPoint[2] = hit[2];
- result.m_hitNormal[0] = normal[0];
- result.m_hitNormal[1] = normal[1];
- result.m_hitNormal[2] = normal[2];
- filterCallback.reportHit(&result);
- }
- return result.m_controller;
-}
-//gamelogic callbacks
-void SumoPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
-{
- SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
- SM_Object* smObject = smctrl->GetSumoObject();
- assert(smObject);
- if (smObject)
- {
- m_sumoScene->addSensor(*smObject);
- }
-}
-void SumoPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl)
-{
- SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
- SM_Object* smObject = smctrl->GetSumoObject();
- assert(smObject);
- if (smObject)
- {
- m_sumoScene->remove(*smObject);
- }
-}
-
-
-void SumoPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
-{
-
- int sumoRespClass = 0;
-
- //map PHY_ convention into SM_ convention
- switch (response_class)
- {
- case PHY_FH_RESPONSE:
- sumoRespClass = FH_RESPONSE;
- break;
- case PHY_SENSOR_RESPONSE:
- sumoRespClass = SENSOR_RESPONSE;
- break;
- case PHY_CAMERA_RESPONSE:
- sumoRespClass =CAMERA_RESPONSE;
- break;
- case PHY_OBJECT_RESPONSE:
- sumoRespClass = OBJECT_RESPONSE;
- break;
- case PHY_STATIC_RESPONSE:
- sumoRespClass = PHY_STATIC_RESPONSE;
- break;
- case PHY_BROADPH_RESPONSE:
- return;
- default:
- assert(0);
- return;
- }
-
- SumoPHYCallbackBridge* bridge = new SumoPHYCallbackBridge(user,callback);
-
- m_sumoScene->addTouchCallback(sumoRespClass,SumoPHYCallbackBridge::StaticSolidToPHYCallback,bridge);
-}
-bool SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctrl)
-{
- SumoPhysicsController* smctrl = dynamic_cast<SumoPhysicsController*>(ctrl);
- MT_assert(smctrl);
- SM_Object* smObject = smctrl->GetSumoObject();
- MT_assert(smObject);
- if (smObject)
- {
- //assert(smObject->getPhysicsClientObject() == ctrl);
- smObject->setPhysicsClientObject(ctrl);
-
- m_sumoScene->requestCollisionCallback(*smObject);
- return true;
- }
- return false;
-}
-
-bool SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
-{
- // intentionally empty
- return false;
-}
-
-PHY_IPhysicsController* SumoPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position)
-{
- DT_ShapeHandle shape = DT_NewSphere(0.0);
- SM_Object* ob = new SM_Object(shape,0,0,0);
- ob->setPosition(MT_Point3(position));
- //testing
- MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
- ob->setOrientation(rotquatje);
-
- PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,0,false);
- ctrl->SetMargin(radius);
- return ctrl;
-}
-PHY_IPhysicsController* SumoPhysicsEnvironment::CreateConeController(float coneradius,float coneheight)
-{
- DT_ShapeHandle shape = DT_NewCone(coneradius,coneheight);
- SM_Object* ob = new SM_Object(shape,0,0,0);
- ob->setPosition(MT_Point3(0.f,0.f,0.f));
- MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
- ob->setOrientation(rotquatje);
-
- PHY_IPhysicsController* ctrl = new SumoPhysicsController(m_sumoScene,ob,0,false);
-
- return ctrl;
-}
-
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
deleted file mode 100644
index 5ae33eb4b0e..00000000000
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef _SUMOPhysicsEnvironment
-#define _SUMOPhysicsEnvironment
-
-#include "MT_Scalar.h"
-
-#include "PHY_IPhysicsEnvironment.h"
-class SumoPHYCallbackBridge;
-#include <vector>
-/**
-* Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.)
-* A derived class may be able to 'construct' entities by loading and/or converting
-*/
-class SumoPhysicsEnvironment : public PHY_IPhysicsEnvironment
-{
-
- class SM_Scene* m_sumoScene;
- float m_currentTime;
- float m_fixedTimeStep;
- bool m_useFixedTimeStep;
-
- std::vector<SumoPHYCallbackBridge*> m_callbacks;
-
-public:
- SumoPhysicsEnvironment();
- virtual ~SumoPhysicsEnvironment();
- virtual void beginFrame();
- virtual void endFrame();
-// Perform an integration step of duration 'timeStep'.
- virtual bool proceedDeltaTime(double curTime,float timeStep,float interval);
- virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep);
- virtual float getFixedTimeStep();
-
- virtual void setGravity(float x,float y,float z);
- virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
- float pivotX,float pivotY,float pivotZ,
- float axisX,float axisY,float axisZ,
- float axis1X=0,float axis1Y=0,float axis1Z=0,
- float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
-
- );
-
- virtual void removeConstraint(int constraintid);
-
- //complex constraint for vehicles
- virtual PHY_IVehicle* getVehicleConstraint(int constraintId)
- {
- return 0;
- }
-
- virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
- virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4 *planes, int nplanes, int occlusionRes) { return false; }
-
-
- //gamelogic callbacks
- virtual void addSensor(PHY_IPhysicsController* ctrl);
- virtual void removeSensor(PHY_IPhysicsController* ctrl);
- virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
- virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl);
- virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
- virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
-
- virtual float getConstraintParam(int constraintId,int param)
- {
- return 0.f;
- }
- virtual void setConstraintParam(int constraintId,int param,float value,float value1)
- {
- }
- SM_Scene* GetSumoScene()
- {
- return m_sumoScene;
- }
-
-protected:
- // 60Hz (Default)
- static MT_Scalar PhysicsTicRate;
-
-};
-
-#endif //_SUMOPhysicsEnvironment
-
diff --git a/source/gameengine/Physics/Sumo/convert.txt b/source/gameengine/Physics/Sumo/convert.txt
deleted file mode 100644
index 81f8f602cde..00000000000
--- a/source/gameengine/Physics/Sumo/convert.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj)
-{
- DT_ShapeHandle shape = DT_NewComplexShape();
- int numpolys = meshobj->NumPolygons();
- int numvalidpolys = 0;
-
- for (int p=0; p<numpolys; p++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p);
-
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- DT_Begin();
- for (int v=0; v<poly->VertexCount(); v++) {
- MT_Point3 pt = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[v],
- poly->GetMaterial()->GetPolyMaterial())->xyz();
- DT_Vertex(pt[0],pt[1],pt[2]);
- }
- DT_End();
-
- numvalidpolys++;
- }
- }
-
- DT_EndComplexShape();
-
- if (numvalidpolys==0) {
- delete shape;
- return NULL;
- } else {
- return shape;
- }
-}
diff --git a/source/gameengine/Physics/Sumo/include/interpolator.h b/source/gameengine/Physics/Sumo/include/interpolator.h
deleted file mode 100644
index 055c242edc7..00000000000
--- a/source/gameengine/Physics/Sumo/include/interpolator.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef INTERPOLATOR_H
-#define INTERPOLATOR_H
-
-#include "solid_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-DT_DECLARE_HANDLE(IP_IpoHandle);
-
-typedef struct IP_ControlPoint {
- DT_Scalar m_key;
- DT_Scalar m_keyValue;
-} IP_ControlPoint;
-
-IP_IpoHandle IP_CreateLinear(const IP_ControlPoint *cpoints, int num_cpoints);
-
-void IP_DeleteInterpolator(IP_IpoHandle ipo);
-
-DT_Scalar IP_GetValue(IP_IpoHandle ipo, DT_Scalar key);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/gameengine/Physics/common/Makefile b/source/gameengine/Physics/common/Makefile
index e3edd426c36..f2dd0134b71 100644
--- a/source/gameengine/Physics/common/Makefile
+++ b/source/gameengine/Physics/common/Makefile
@@ -40,7 +40,7 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO)/include -I$(NAN_MOTO)/include
+CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_MOTO)/include
CPPFLAGS += -I../../blender
# these two needed because of blenkernel
CPPFLAGS += -I../../blender/makesdna
diff --git a/source/gameengine/SConscript b/source/gameengine/SConscript
index 864e4c3ebee..592b138583f 100644
--- a/source/gameengine/SConscript
+++ b/source/gameengine/SConscript
@@ -18,13 +18,5 @@ SConscript(['BlenderRoutines/SConscript',
'VideoTexture/SConscript'
])
-if env['WITH_BF_SOLID']:
- SConscript(['Physics/Sumo/SConscript'])
-
if env['WITH_BF_PLAYER']:
SConscript(['GamePlayer/SConscript'])
-
-#if user_options_dict['USE_PHYSICS'] == 'solid':
-# SConscript(['Physics/Sumo/SConscript'])
-#elif user_options_dict['USE_PHYSICS'] == 'ode':
-# SConscript(['Physics/BlOde/SConscript'])
diff --git a/source/nan_compile.mk b/source/nan_compile.mk
index bd6dd6e1baa..bc264fe5c1d 100644
--- a/source/nan_compile.mk
+++ b/source/nan_compile.mk
@@ -71,21 +71,6 @@ DBG_CCFLAGS += -g
# OS dependent parts ---------------------------------------------------
-ifeq ($(OS),beos)
- CC = gcc
- CCC = g++
- CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
- CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
- REL_CFLAGS += -O2
- REL_CCFLAGS += -O2
- NAN_DEPEND = true
- OPENGL_HEADERS = .
- CPPFLAGS += -D__BeOS
- AR = ar
- ARFLAGS = ruv
- ARFLAGSQUIET = ru
-endif
-
ifeq ($(OS),darwin)
CC = gcc
CCC = g++
diff --git a/source/nan_definitions.mk b/source/nan_definitions.mk
index b9e623ed4e4..91f90525c1e 100644
--- a/source/nan_definitions.mk
+++ b/source/nan_definitions.mk
@@ -91,7 +91,6 @@ endif
export BF_PROFILE ?= false
export NAN_USE_BULLET ?= true
export NAN_BULLET2 ?= $(LCGDIR)/bullet2
- export NAN_SUMO ?= $(SRCHOME)/gameengine/Physics/Sumo
export NAN_FUZZICS ?= $(SRCHOME)/gameengine/Physics/Sumo/Fuzzics
export NAN_BLENKEY ?= $(LCGDIR)/blenkey
export NAN_DECIMATION ?= $(LCGDIR)/decimation
@@ -131,45 +130,6 @@ endif
endif
# Platform Dependent settings go below:
- ifeq ($(OS),beos)
-
- export ID = $(USER)
- export HOST = $(HOSTNAME)
- export NAN_PYTHON ?= $(LCGDIR)/python
- export NAN_PYTHON_VERSION ?= 2.3
- export NAN_PYTHON_BINARY ?= $(NAN_PYTHON)/bin/python$(NAN_PYTHON_VERSION)
- export NAN_PYTHON_LIB ?= $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a
- export NAN_OPENAL ?= $(LCGDIR)/openal
- export NAN_JPEG ?= $(LCGDIR)/jpeg
- export NAN_PNG ?= $(LCGDIR)/png
- export NAN_TIFF ?= $(LCGDIR)/tiff
- export NAN_ODE ?= $(LCGDIR)/ode
- export NAN_TERRAPLAY ?= $(LCGDIR)/terraplay
- export NAN_MESA ?= /usr/src/Mesa-3.1
- export NAN_ZLIB ?= $(LCGDIR)/zlib
- export NAN_NSPR ?= $(LCGDIR)/nspr
- export NAN_FREETYPE ?= $(LCGDIR)/freetype
- export NAN_GETTEXT ?= $(LCGDIR)/gettext
- export NAN_SDL ?= $(shell sdl-config --prefix)
- export NAN_SDLLIBS ?= $(shell sdl-config --libs)
- export NAN_SDLCFLAGS ?= $(shell sdl-config --cflags)
-
- # Uncomment the following line to use Mozilla inplace of netscape
- # CPPFLAGS +=-DMOZ_NOT_NET
- # Location of MOZILLA/Netscape header files...
- export NAN_MOZILLA_INC ?= $(LCGDIR)/mozilla/include
- export NAN_MOZILLA_LIB ?= $(LCGDIR)/mozilla/lib/
- # Will fall back to look in NAN_MOZILLA_INC/nspr and NAN_MOZILLA_LIB
- # if this is not set.
-
- export NAN_BUILDINFO ?= true
- # Be paranoid regarding library creation (do not update archives)
- export NAN_PARANOID ?= true
-
- # l10n
- #export INTERNATIONAL ?= true
-
- else
ifeq ($(OS),darwin)
export ID = $(shell whoami)
@@ -589,7 +549,6 @@ endif
endif # irix
endif # freebsd
endif # darwin
- endif # beos
endif # CONFIG_GUESS
diff --git a/source/nan_link.mk b/source/nan_link.mk
index 42b17b425b3..63c9a578498 100644
--- a/source/nan_link.mk
+++ b/source/nan_link.mk
@@ -49,10 +49,6 @@ endif
# default (overriden by windows)
SOEXT = .so
-ifeq ($(OS),beos)
- LLIBS = -L/boot/develop/lib/x86/ -lGL -lbe -L/boot/home/config/lib/
-endif
-
ifeq ($(OS),darwin)
LLIBS += -lGLU -lGL
LLIBS += -lz -lstdc++