Merged changes in the trunk up to revision 26719.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Mon, 8 Feb 2010 21:13:33 +0000 (21:13 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Mon, 8 Feb 2010 21:13:33 +0000 (21:13 +0000)
154 files changed:
intern/audaspace/FX/AUD_FaderReader.cpp
intern/audaspace/FX/AUD_LoopReader.cpp
intern/audaspace/FX/AUD_LoopReader.h
intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
intern/audaspace/SRC/AUD_SRCResampleReader.cpp
intern/audaspace/SRC/AUD_SRCResampleReader.h
intern/audaspace/intern/AUD_C-API.cpp
intern/audaspace/intern/AUD_C-API.h
intern/audaspace/intern/AUD_Mixer.cpp
intern/audaspace/intern/AUD_Mixer.h
intern/audaspace/intern/AUD_SequencerFactory.cpp [new file with mode: 0644]
intern/audaspace/intern/AUD_SequencerFactory.h [new file with mode: 0644]
intern/audaspace/intern/AUD_SequencerReader.cpp [new file with mode: 0644]
intern/audaspace/intern/AUD_SequencerReader.h [new file with mode: 0644]
intern/audaspace/intern/AUD_SoftwareDevice.cpp
intern/audaspace/intern/AUD_Space.h
intern/audaspace/make/msvc_9_0/audaspace.vcproj
intern/guardedalloc/MEM_guardedalloc.h
intern/guardedalloc/intern/mallocn.c
intern/opennl/superlu/get_perm_c.c
intern/smoke/intern/FLUID_3D.cpp
intern/smoke/intern/FLUID_3D_STATIC.cpp
intern/smoke/intern/WAVELET_NOISE.h
projectfiles_vc9/gameengine/ketsji/KX_ketsji.vcproj
release/scripts/op/presets.py
release/scripts/op/sequencer.py [new file with mode: 0644]
release/scripts/presets/sunsky/classic.py [new file with mode: 0644]
release/scripts/presets/sunsky/desert.py [new file with mode: 0644]
release/scripts/presets/sunsky/mountain.py [new file with mode: 0644]
release/scripts/ui/properties_data_lamp.py
release/scripts/ui/properties_material.py
release/scripts/ui/properties_render.py
release/scripts/ui/properties_texture.py
release/scripts/ui/space_dopesheet.py
release/scripts/ui/space_graph.py
release/scripts/ui/space_sequencer.py
source/blender/blenkernel/BKE_fcurve.h
source/blender/blenkernel/BKE_screen.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/BKE_sound.h
source/blender/blenkernel/BKE_writeffmpeg.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/CCGSubSurf.c
source/blender/blenkernel/intern/Makefile
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/exotic.c
source/blender/blenkernel/intern/multires.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/screen.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenkernel/intern/sound.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/intern/BLI_args.c
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/noise.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/storage.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/animation/anim_ops.c
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/armature/poseobject.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_transform.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_graph/graph_select.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_text/text_intern.h
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/uvedit/uvedit_parametrizer.c
source/blender/imbuf/intern/iff.c
source/blender/imbuf/intern/thumbs.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_sequence_types.h
source/blender/makesdna/DNA_sound_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_text_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_actuator.c
source/blender/makesrna/intern/rna_color.c
source/blender/makesrna/intern/rna_lamp.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_sequencer.c
source/blender/makesrna/intern/rna_ui.c
source/blender/nodes/intern/TEX_nodes/TEX_output.c
source/blender/nodes/intern/TEX_util.c
source/blender/python/intern/bpy_interface.c
source/blender/render/intern/include/shading.h
source/blender/render/intern/raytrace/rayobject.cpp
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/shadeoutput.c
source/blender/render/intern/source/voxeldata.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_keymap.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/creator/creator.c
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Ketsji/CMakeLists.txt
source/gameengine/Ketsji/KX_SoundActuator.cpp
source/gameengine/Ketsji/SConscript
source/gameengine/PyDoc/VideoTexture.py
source/gameengine/VideoTexture/ImageBase.cpp
source/gameengine/VideoTexture/ImageBase.h
source/gameengine/VideoTexture/ImageMix.cpp
source/gameengine/VideoTexture/ImageMix.h
source/gameengine/VideoTexture/ImageRender.cpp
source/gameengine/VideoTexture/ImageRender.h
source/gameengine/VideoTexture/ImageViewport.cpp
source/gameengine/VideoTexture/ImageViewport.h
source/gameengine/VideoTexture/SConscript
source/gameengine/VideoTexture/Texture.cpp
source/gameengine/VideoTexture/VideoFFmpeg.cpp
source/gameengine/VideoTexture/VideoFFmpeg.h

index 6c7ea6e0a01204db216ec5d6eb8650505f413c1f..4e919fff323f86e60c10937933012292969d5671 100644 (file)
@@ -78,7 +78,7 @@ void AUD_FaderReader::read(int & length, sample_t* & buffer)
        else
        {
                sample_t* buf = m_buffer->getBuffer();
-               float volume;
+               float volume = 1.0f;
 
                for(int i = 0; i < length * specs.channels; i++)
                {
index 7d70fc2022170d1590678c4a706e1d6f5bec72a0..3bcd8c2f9d32e4484bc117b1569dd315dbeb0848 100644 (file)
@@ -31,6 +31,7 @@
 AUD_LoopReader::AUD_LoopReader(AUD_IReader* reader, int loop) :
                AUD_EffectReader(reader), m_loop(loop)
 {
+       m_samples = -1;
        m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
 }
 
@@ -51,6 +52,7 @@ bool AUD_LoopReader::notify(AUD_Message &message)
        if(message.type == AUD_MSG_LOOP)
        {
                m_loop = message.loopcount;
+               m_samples = message.time * m_reader->getSpecs().rate;
 
                m_reader->notify(message);
 
@@ -64,6 +66,13 @@ void AUD_LoopReader::read(int & length, sample_t* & buffer)
        AUD_Specs specs = m_reader->getSpecs();
        int samplesize = AUD_SAMPLE_SIZE(specs);
 
+       if(m_samples >= 0)
+       {
+               if(length > m_samples)
+                       length = m_samples;
+               m_samples -= length;
+       }
+
        int len = length;
 
        m_reader->read(len, buffer);
index 621ee3493abe6fbf467975dd21072d85e7b59725..e61a49cb0db39c4c13c1a7c4c7dc259f9ae4e6b0 100644 (file)
@@ -46,6 +46,11 @@ private:
         */
        int m_loop;
 
+       /**
+        * The left samples.
+        */
+       int m_samples;
+
 public:
        /**
         * Creates a new loop reader.
index 0b3e86eda56fb7c4ad91bd0b9eec383626cd3b3c..7ee8652f226839c880c46815a75faa97d2ee4bac 100644 (file)
@@ -180,7 +180,7 @@ void AUD_OpenALDevice::updateStreams()
                                                                                         AUD_DEVICE_SAMPLE_SIZE(specs),
                                                                                         specs.rate);
 
-                                                               if(alGetError() != AL_NO_ERROR)
+                                                               if((err = alGetError()) != AL_NO_ERROR)
                                                                {
                                                                        sound->data_end = true;
                                                                        break;
@@ -839,13 +839,14 @@ bool AUD_OpenALDevice::seek(AUD_Handle* handle, float position)
 
                        if(info != AL_PLAYING)
                        {
-                               if(info != AL_STOPPED)
+                               if(info == AL_PAUSED)
                                        alSourceStop(alhandle->source);
 
-                               alSourceUnqueueBuffers(alhandle->source,
-                                                                          AUD_OPENAL_CYCLE_BUFFERS,
-                                                                          alhandle->buffers);
-                               if(alGetError() == AL_NO_ERROR)
+                               alSourcei(alhandle->source, AL_BUFFER, 0);
+                               alhandle->current = 0;
+
+                               ALenum err;
+                               if((err = alGetError()) == AL_NO_ERROR)
                                {
                                        sample_t* buf;
                                        int length;
@@ -889,11 +890,14 @@ float AUD_OpenALDevice::getPosition(AUD_Handle* handle)
        if(isValid(handle))
        {
                AUD_OpenALHandle* h = (AUD_OpenALHandle*)handle;
-               if(h->isBuffered)
-                       alGetSourcef(h->source, AL_SEC_OFFSET, &position);
-               else
-                       position = h->reader->getPosition() /
-                                          (float)h->reader->getSpecs().rate;
+               alGetSourcef(h->source, AL_SEC_OFFSET, &position);
+               if(!h->isBuffered)
+               {
+                       AUD_Specs specs = h->reader->getSpecs();
+                       position += (h->reader->getPosition() - m_buffersize *
+                                                                       AUD_OPENAL_CYCLE_BUFFERS / specs.channels) /
+                                          (float)specs.rate;
+               }
        }
 
        unlock();
index 940f4245316c80dfabc2308522d477afc6bc6afe..e89857635dec99c573cb090a499c1c8b651a487e 100644 (file)
@@ -44,6 +44,7 @@ AUD_SRCResampleReader::AUD_SRCResampleReader(AUD_IReader* reader,
        m_tspecs = specs;
        m_tspecs.channels = m_sspecs.channels;
        m_factor = (double)m_tspecs.rate / (double)m_sspecs.rate;
+       m_position = 0;
 
        int error;
        m_src = src_callback_new(src_callback,
@@ -71,7 +72,7 @@ AUD_SRCResampleReader::~AUD_SRCResampleReader()
 
 long AUD_SRCResampleReader::doCallback(float** data)
 {
-       int length = m_buffer->getSize() / 4 / m_tspecs.channels;
+       int length = m_buffer->getSize() / AUD_SAMPLE_SIZE(m_tspecs);
        sample_t* buffer;
 
        m_reader->read(length, buffer);
@@ -84,6 +85,7 @@ void AUD_SRCResampleReader::seek(int position)
 {
        m_reader->seek(position / m_factor);
        src_reset(m_src);
+       m_position = position;
 }
 
 int AUD_SRCResampleReader::getLength()
@@ -93,7 +95,7 @@ int AUD_SRCResampleReader::getLength()
 
 int AUD_SRCResampleReader::getPosition()
 {
-       return m_reader->getPosition() * m_factor;
+       return m_position;
 }
 
 AUD_Specs AUD_SRCResampleReader::getSpecs()
@@ -111,4 +113,6 @@ void AUD_SRCResampleReader::read(int & length, sample_t* & buffer)
        buffer = m_buffer->getBuffer();
 
        length = src_callback_read(m_src, m_factor, length, buffer);
+
+       m_position += length;
 }
index 4fe30b48c6e7aa41eb7d81893ffda01af3797379..e09d1b66f13c72cc6315b4be1a142e744e7397eb 100644 (file)
@@ -62,6 +62,11 @@ private:
         */
        SRC_STATE* m_src;
 
+       /**
+        * The current playback position;
+        */
+       int m_position;
+
 public:
        /**
         * Creates a resampling reader.
index b7d0183cb5e4a1e384d78064fcb5375fe4d313f1..b2d5209e9d62272031c24de2fcdb6b595f55aa70 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <cstdlib>
 #include <cstring>
+#include <cmath>
 
 #include "AUD_NULLDevice.h"
 #include "AUD_I3DDevice.h"
@@ -47,6 +48,7 @@
 #include "AUD_ReadDevice.h"
 #include "AUD_SourceCaps.h"
 #include "AUD_IReader.h"
+#include "AUD_SequencerFactory.h"
 
 #ifdef WITH_SDL
 #include "AUD_SDLDevice.h"
@@ -231,7 +233,7 @@ AUD_Sound* AUD_delaySound(AUD_Sound* sound, float delay)
        }
 }
 
-extern AUD_Sound* AUD_limitSound(AUD_Sound* sound, float start, float end)
+AUD_Sound* AUD_limitSound(AUD_Sound* sound, float start, float end)
 {
        assert(sound);
 
@@ -273,13 +275,14 @@ AUD_Sound* AUD_loopSound(AUD_Sound* sound)
        }
 }
 
-int AUD_stopLoop(AUD_Handle* handle)
+int AUD_setLoop(AUD_Handle* handle, int loops, float time)
 {
        if(handle)
        {
                AUD_Message message;
                message.type = AUD_MSG_LOOP;
-               message.loopcount = 0;
+               message.loopcount = loops;
+               message.time = time;
 
                try
                {
@@ -537,14 +540,16 @@ AUD_Device* AUD_openReadDevice(AUD_DeviceSpecs specs)
        }
 }
 
-AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound)
+AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound, float seek)
 {
        assert(device);
        assert(sound);
 
        try
        {
-               return device->play(sound);
+               AUD_Handle* handle = device->play(sound);
+               device->seek(handle, seek);
+               return handle;
        }
        catch(AUD_Exception)
        {
@@ -663,3 +668,108 @@ float* AUD_readSoundBuffer(const char* filename, float low, float high,
        *length = position;
        return result;
 }
+
+AUD_Sound* AUD_createSequencer(void* data, AUD_volumeFunction volume)
+{
+/* AUD_XXX should be this: but AUD_createSequencer is called before the device
+ * is initialized.
+
+       return new AUD_SequencerFactory(AUD_device->getSpecs().specs, data, volume);
+*/
+       AUD_Specs specs;
+       specs.channels = AUD_CHANNELS_STEREO;
+       specs.rate = AUD_RATE_44100;
+       return new AUD_SequencerFactory(specs, data, volume);
+}
+
+void AUD_destroySequencer(AUD_Sound* sequencer)
+{
+       delete ((AUD_SequencerFactory*)sequencer);
+}
+
+AUD_SequencerEntry* AUD_addSequencer(AUD_Sound** sequencer, AUD_Sound* sound,
+                                                                float begin, float end, float skip, void* data)
+{
+       return ((AUD_SequencerFactory*)sequencer)->add((AUD_IFactory**) sound, begin, end, skip, data);
+}
+
+void AUD_removeSequencer(AUD_Sound* sequencer, AUD_SequencerEntry* entry)
+{
+       ((AUD_SequencerFactory*)sequencer)->remove(entry);
+}
+
+void AUD_moveSequencer(AUD_Sound* sequencer, AUD_SequencerEntry* entry,
+                                  float begin, float end, float skip)
+{
+       ((AUD_SequencerFactory*)sequencer)->move(entry, begin, end, skip);
+}
+
+void AUD_muteSequencer(AUD_Sound* sequencer, AUD_SequencerEntry* entry, char mute)
+{
+       ((AUD_SequencerFactory*)sequencer)->mute(entry, mute);
+}
+
+int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length)
+{
+       AUD_IReader* reader = sound->createReader();
+       AUD_DeviceSpecs specs;
+       sample_t* buf;
+
+       specs.specs = reader->getSpecs();
+       specs.channels = AUD_CHANNELS_MONO;
+       specs.format = AUD_FORMAT_FLOAT32;
+
+       AUD_ChannelMapperFactory mapper(reader, specs);
+
+       if(!reader || reader->getType() != AUD_TYPE_BUFFER)
+               return -1;
+
+       reader = mapper.createReader();
+
+       if(!reader)
+               return -1;
+
+       int len = reader->getLength();
+       float samplejump = (float)len / (float)length;
+       float min, max;
+
+       for(int i = 0; i < length; i++)
+       {
+               len = floor(samplejump * (i+1)) - floor(samplejump * i);
+               reader->read(len, buf);
+
+               if(len < 1)
+               {
+                       length = i;
+                       break;
+               }
+
+               max = min = *buf;
+               for(int j = 1; j < len; j++)
+               {
+                       if(buf[j] < min)
+                               min = buf[j];
+                       if(buf[j] > max)
+                               max = buf[j];
+                       buffer[i * 2] = min;
+                       buffer[i * 2 + 1] = max;
+               }
+       }
+
+       delete reader; AUD_DELETE("reader")
+
+       return length;
+}
+
+#ifdef AUD_DEBUG_MEMORY
+int AUD_References(int count, const char* text)
+{
+       static int m_count = 0;
+       m_count += count;
+       if(count > 0)
+               printf("+%s\n", text);
+       if(count < 0)
+               printf("-%s\n", text);
+       return m_count;
+}
+#endif
index c3439f89ade990a0b0eab5b6e7a7151be10e9828..ce1791886de5be548343d41aef55c3dd3c5cf90e 100644 (file)
@@ -50,6 +50,8 @@ typedef struct
        typedef void AUD_Sound;
        typedef void AUD_Handle;
        typedef void AUD_Device;
+       typedef void AUD_SequencerEntry;
+       typedef float (*AUD_volumeFunction)(void*, void*, float);
 #endif
 
 /**
@@ -143,11 +145,13 @@ extern AUD_Sound* AUD_pingpongSound(AUD_Sound* sound);
 extern AUD_Sound* AUD_loopSound(AUD_Sound* sound);
 
 /**
- * Stops a looping sound when the current playback finishes.
+ * Sets a remaining loop count of a looping sound that currently plays.
  * \param handle The playback handle.
+ * \param loops The count of remaining loops, -1 for infinity.
+ * \param time The time after which playback should stop, -1 for infinity.
  * \return Whether the handle is valid.
  */
-extern int AUD_stopLoop(AUD_Handle* handle);
+extern int AUD_setLoop(AUD_Handle* handle, int loops, float time);
 
 /**
  * Rectifies a sound.
@@ -211,6 +215,7 @@ extern int AUD_seek(AUD_Handle* handle, float seekTo);
 
 /**
  * Retrieves the playback position of a handle.
+ * \param handle The handle to the sound.
  * \return The current playback position in seconds or 0.0 if the handle is
  *         invalid.
  */
@@ -318,9 +323,10 @@ extern int AUD_setDeviceVolume(AUD_Device* device, float volume);
  * Plays back a sound file through a read device.
  * \param device The read device.
  * \param sound The handle of the sound file.
+ * \param seek The position where the sound should be seeked to.
  * \return A handle to the played back sound.
  */
-extern AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound);
+extern AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound, float seek);
 
 /**
  * Sets the volume of a played back sound of a read device.
@@ -360,6 +366,23 @@ extern float* AUD_readSoundBuffer(const char* filename, float low, float high,
                                                                  float sthreshold, int samplerate,
                                                                  int* length);
 
+extern AUD_Sound* AUD_createSequencer(void* data, AUD_volumeFunction volume);
+
+extern void AUD_destroySequencer(AUD_Sound* sequencer);
+
+extern AUD_SequencerEntry* AUD_addSequencer(AUD_Sound** sequencer, AUD_Sound* sound,
+                                                                               float begin, float end, float skip, void* data);
+
+extern void AUD_removeSequencer(AUD_Sound* sequencer, AUD_SequencerEntry* entry);
+
+extern void AUD_moveSequencer(AUD_Sound* sequencer, AUD_SequencerEntry* entry,
+                                                 float begin, float end, float skip);
+
+extern void AUD_muteSequencer(AUD_Sound* sequencer, AUD_SequencerEntry* entry,
+                                                 char mute);
+
+extern int AUD_readSound(AUD_Sound* sound, sample_t* buffer, int length);
+
 #ifdef __cplusplus
 }
 #endif
index bddc719b17959ada7452b32f5af246546e50ded9..e77d40fdbcab5cac64eed807ad1e4cd011480072 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "AUD_Mixer.h"
 #include "AUD_SRCResampleFactory.h"
+#include "AUD_LinearResampleFactory.h"
 #include "AUD_ChannelMapperFactory.h"
 #include "AUD_IReader.h"
 #include "AUD_Buffer.h"
@@ -59,7 +60,7 @@ AUD_IReader* AUD_Mixer::prepare(AUD_IReader* reader)
        m_resampler->setReader(reader);
        reader = m_resampler->createReader();
 
-       if(reader->getSpecs().channels != m_specs.channels)
+       if(reader != NULL && reader->getSpecs().channels != m_specs.channels)
        {
                m_mapper->setReader(reader);
                reader = m_mapper->createReader();
@@ -68,6 +69,11 @@ AUD_IReader* AUD_Mixer::prepare(AUD_IReader* reader)
        return reader;
 }
 
+AUD_DeviceSpecs AUD_Mixer::getSpecs()
+{
+       return m_specs;
+}
+
 void AUD_Mixer::setSpecs(AUD_DeviceSpecs specs)
 {
        m_specs = specs;
@@ -81,7 +87,7 @@ void AUD_Mixer::setSpecs(AUD_DeviceSpecs specs)
                delete m_mapper; AUD_DELETE("factory")
        }
 
-       m_resampler = new AUD_SRCResampleFactory(specs); AUD_NEW("factory")
+       m_resampler = new AUD_MIXER_RESAMPLER(specs); AUD_NEW("factory")
        m_mapper = new AUD_ChannelMapperFactory(specs); AUD_NEW("factory")
 
        int bigendian = 1;
@@ -115,10 +121,11 @@ void AUD_Mixer::setSpecs(AUD_DeviceSpecs specs)
        }
 }
 
-void AUD_Mixer::add(sample_t* buffer, int length, float volume)
+void AUD_Mixer::add(sample_t* buffer, int start, int length, float volume)
 {
        AUD_MixerBuffer buf;
        buf.buffer = buffer;
+       buf.start = start;
        buf.length = length;
        buf.volume = volume;
        m_buffers.push_back(buf);
@@ -145,11 +152,11 @@ void AUD_Mixer::superpose(data_t* buffer, int length, float volume)
                buf = m_buffers.front();
                m_buffers.pop_front();
 
-               end = buf.length*channels;
+               end = buf.length * channels;
                in = buf.buffer;
 
                for(int i = 0; i < end; i++)
-                       out[i] += in[i]*buf.volume * volume;
+                       out[i + buf.start * channels] += in[i] * buf.volume * volume;
        }
 
        m_convert(buffer, (data_t*) out, length * channels);
index 5097b9ec2a6e3a7b57a97627339d2b9fbb66d219..2e7ba7435413224c497d8c5263348d1bafbdb958 100644 (file)
 #ifndef AUD_MIXER
 #define AUD_MIXER
 
+#define AUD_MIXER_RESAMPLER AUD_SRCResampleFactory
+
 #include "AUD_ConverterFunctions.h"
 class AUD_ConverterFactory;
-class AUD_SRCResampleFactory;
+class AUD_MIXER_RESAMPLER;
 class AUD_ChannelMapperFactory;
 class AUD_Buffer;
 class AUD_IReader;
@@ -37,6 +39,7 @@ class AUD_IReader;
 struct AUD_MixerBuffer
 {
        sample_t* buffer;
+       int start;
        int length;
        float volume;
 };
@@ -53,7 +56,7 @@ private:
        /**
         * The resampling factory that resamples all readers for superposition.
         */
-       AUD_SRCResampleFactory* m_resampler;
+       AUD_MIXER_RESAMPLER* m_resampler;
 
        /**
         * The channel mapper factory that maps all readers for superposition.
@@ -98,6 +101,12 @@ public:
         */
        AUD_IReader* prepare(AUD_IReader* reader);
 
+       /**
+        * Returns the target specification for superposing.
+        * \return The target specification.
+        */
+       AUD_DeviceSpecs getSpecs();
+
        /**
         * Sets the target specification for superposing.
         * \param specs The target specification.
@@ -111,7 +120,7 @@ public:
         * \param length The length of the buffer in samples.
         * \param volume The mixing volume. Must be a value between 0.0 and 1.0.
         */
-       void add(sample_t* buffer, int length, float volume);
+       void add(sample_t* buffer, int start, int length, float volume);
 
        /**
         * Superposes all added buffers into an output buffer.
diff --git a/intern/audaspace/intern/AUD_SequencerFactory.cpp b/intern/audaspace/intern/AUD_SequencerFactory.cpp
new file mode 100644 (file)
index 0000000..bb5cf27
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN LGPL LICENSE BLOCK *****
+ *
+ * Copyright 2009 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * AudaSpace is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * AudaSpace 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LGPL LICENSE BLOCK *****
+ */
+
+#include "AUD_SequencerFactory.h"
+#include "AUD_SequencerReader.h"
+
+typedef std::list<AUD_SequencerReader*>::iterator AUD_ReaderIterator;
+
+AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, void* data, AUD_volumeFunction volume)
+{
+       m_specs = specs;
+       m_data = data;
+       m_volume = volume;
+}
+
+AUD_SequencerFactory::~AUD_SequencerFactory()
+{
+       AUD_SequencerReader* reader;
+       AUD_SequencerEntry* entry;
+
+       while(!m_readers.empty())
+       {
+               reader = m_readers.front();
+               m_readers.pop_front();
+               reader->destroy();
+       }
+
+       while(!m_entries.empty())
+       {
+               entry = m_entries.front();
+               m_entries.pop_front();
+               delete entry; AUD_DELETE("seqentry")
+       }
+}
+
+AUD_SequencerEntry* AUD_SequencerFactory::add(AUD_IFactory** sound, float begin, float end, float skip, void* data)
+{
+       AUD_SequencerEntry* entry = new AUD_SequencerEntry; AUD_NEW("seqentry")
+       entry->sound = sound;
+       entry->begin = begin;
+       entry->skip = skip;
+       entry->end = end;
+       entry->muted = false;
+       entry->data = data;
+
+       m_entries.push_front(entry);
+
+       for(AUD_ReaderIterator i = m_readers.begin(); i != m_readers.end(); i++)
+               (*i)->add(entry);
+
+       return entry;
+}
+
+void AUD_SequencerFactory::remove(AUD_SequencerEntry* entry)
+{
+       for(AUD_ReaderIterator i = m_readers.begin(); i != m_readers.end(); i++)
+               (*i)->remove(entry);
+
+       m_entries.remove(entry);
+
+       delete entry; AUD_DELETE("seqentry")
+}
+
+void AUD_SequencerFactory::move(AUD_SequencerEntry* entry, float begin, float end, float skip)
+{
+       entry->begin = begin;
+       entry->skip = skip;
+       entry->end = end;
+}
+
+void AUD_SequencerFactory::mute(AUD_SequencerEntry* entry, bool mute)
+{
+       entry->muted = mute;
+}
+
+AUD_IReader* AUD_SequencerFactory::createReader()
+{
+       AUD_SequencerReader* reader = new AUD_SequencerReader(this, m_entries, m_specs, m_data, m_volume); AUD_NEW("reader")
+       m_readers.push_front(reader);
+
+       return reader;
+}
+
+void AUD_SequencerFactory::removeReader(AUD_SequencerReader* reader)
+{
+       m_readers.remove(reader);
+}
diff --git a/intern/audaspace/intern/AUD_SequencerFactory.h b/intern/audaspace/intern/AUD_SequencerFactory.h
new file mode 100644 (file)
index 0000000..b564c88
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN LGPL LICENSE BLOCK *****
+ *
+ * Copyright 2009 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * AudaSpace is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * AudaSpace 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LGPL LICENSE BLOCK *****
+ */
+
+#ifndef AUD_SEQUENCERFACTORY
+#define AUD_SEQUENCERFACTORY
+
+#include "AUD_IFactory.h"
+
+#include <list>
+
+typedef float (*AUD_volumeFunction)(void*, void*, float);
+
+struct AUD_SequencerEntry
+{
+       AUD_IFactory** sound;
+       float begin;
+       float end;
+       float skip;
+       bool muted;
+       void* data;
+};
+
+class AUD_SequencerReader;
+
+/**
+ * This factory creates a resampling reader that does simple linear resampling.
+ */
+class AUD_SequencerFactory : public AUD_IFactory
+{
+private:
+       /**
+        * The target specification.
+        */
+       AUD_Specs m_specs;
+
+       std::list<AUD_SequencerEntry*> m_entries;
+       std::list<AUD_SequencerReader*> m_readers;
+       void* m_data;
+       AUD_volumeFunction m_volume;
+
+public:
+       AUD_SequencerFactory(AUD_Specs specs, void* data, AUD_volumeFunction volume);
+       ~AUD_SequencerFactory();
+
+       AUD_SequencerEntry* add(AUD_IFactory** sound, float begin, float end, float skip, void* data);
+       void remove(AUD_SequencerEntry* entry);
+       void move(AUD_SequencerEntry* entry, float begin, float end, float skip);
+       void mute(AUD_SequencerEntry* entry, bool mute);
+
+       virtual AUD_IReader* createReader();
+
+       void removeReader(AUD_SequencerReader* reader);
+};
+
+#endif //AUD_SEQUENCERFACTORY
diff --git a/intern/audaspace/intern/AUD_SequencerReader.cpp b/intern/audaspace/intern/AUD_SequencerReader.cpp
new file mode 100644 (file)
index 0000000..8869d8d
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN LGPL LICENSE BLOCK *****
+ *
+ * Copyright 2009 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * AudaSpace is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * AudaSpace 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LGPL LICENSE BLOCK *****
+ */
+
+#include "AUD_SequencerReader.h"
+#include "AUD_Buffer.h"
+
+#include <math.h>
+
+typedef std::list<AUD_SequencerStrip*>::iterator AUD_StripIterator;
+typedef std::list<AUD_SequencerEntry*>::iterator AUD_EntryIterator;
+
+AUD_SequencerReader::AUD_SequencerReader(AUD_SequencerFactory* factory, std::list<AUD_SequencerEntry*> &entries, AUD_Specs specs, void* data, AUD_volumeFunction volume)
+{
+       AUD_DeviceSpecs dspecs;
+       dspecs.specs = specs;
+       dspecs.format = AUD_FORMAT_FLOAT32;
+
+       m_mixer.setSpecs(dspecs);
+       m_factory = factory;
+       m_data = data;
+       m_volume = volume;
+
+       AUD_SequencerStrip* strip;
+
+       for(AUD_EntryIterator i = entries.begin(); i != entries.end(); i++)
+       {
+               strip = new AUD_SequencerStrip;  AUD_NEW("seqstrip")
+               strip->entry = *i;
+               strip->old_sound = NULL;
+
+               if(strip->old_sound)
+                       strip->reader = m_mixer.prepare(strip->old_sound->createReader());
+               else
+                       strip->reader = NULL;
+
+               m_strips.push_front(strip);
+       }
+
+       m_position = 0;
+       m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
+}
+
+AUD_SequencerReader::~AUD_SequencerReader()
+{
+       if(m_factory != NULL)
+               m_factory->removeReader(this);
+
+       AUD_SequencerStrip* strip;
+
+       while(!m_strips.empty())
+       {
+               strip = m_strips.front();
+               m_strips.pop_front();
+               if(strip->reader)
+               {
+                       delete strip->reader; AUD_DELETE("reader")
+               }
+               delete strip; AUD_DELETE("seqstrip")
+       }
+
+       delete m_buffer; AUD_DELETE("buffer")
+}
+
+void AUD_SequencerReader::destroy()
+{
+       m_factory = NULL;
+       AUD_SequencerStrip* strip;
+
+       while(!m_strips.empty())
+       {
+               strip = m_strips.front();
+               m_strips.pop_front();
+               delete strip; AUD_DELETE("seqstrip")
+       }
+}
+
+void AUD_SequencerReader::add(AUD_SequencerEntry* entry)
+{
+       AUD_SequencerStrip* strip = new AUD_SequencerStrip; AUD_NEW("seqstrip")
+       strip->entry = entry;
+
+       if(*strip->entry->sound)
+       {
+               strip->old_sound = *strip->entry->sound;
+               strip->reader = m_mixer.prepare(strip->old_sound->createReader());
+       }
+       else
+       {
+               strip->reader = NULL;
+               strip->old_sound = NULL;
+       }
+       m_strips.push_front(strip);
+}
+
+void AUD_SequencerReader::remove(AUD_SequencerEntry* entry)
+{
+       AUD_SequencerStrip* strip;
+       for(AUD_StripIterator i = m_strips.begin(); i != m_strips.end(); i++)
+       {
+               strip = *i;
+               if(strip->entry == entry)
+               {
+                       i++;
+                       if(strip->reader)
+                       {
+                               delete strip->reader; AUD_DELETE("reader")
+                       }
+                       m_strips.remove(strip);
+                       delete strip; AUD_DELETE("seqstrip")
+                       return;
+               }
+       }
+}
+
+bool AUD_SequencerReader::isSeekable()
+{
+       return true;
+}
+
+void AUD_SequencerReader::seek(int position)
+{
+       m_position = position;
+}
+
+int AUD_SequencerReader::getLength()
+{
+       return -1;
+}
+
+int AUD_SequencerReader::getPosition()
+{
+       return m_position;
+}
+
+AUD_Specs AUD_SequencerReader::getSpecs()
+{
+       return m_mixer.getSpecs().specs;
+}
+
+AUD_ReaderType AUD_SequencerReader::getType()
+{
+       return AUD_TYPE_STREAM;
+}
+
+bool AUD_SequencerReader::notify(AUD_Message &message)
+{
+       bool result = false;
+       AUD_SequencerStrip* strip;
+
+       for(AUD_StripIterator i = m_strips.begin(); i != m_strips.end(); i++)
+       {
+               strip = *i;
+               if(strip->reader)
+                       result |= (*i)->reader->notify(message);
+       }
+
+       return result;
+}
+
+void AUD_SequencerReader::read(int & length, sample_t* & buffer)
+{
+       AUD_DeviceSpecs specs = m_mixer.getSpecs();
+       int samplesize = AUD_SAMPLE_SIZE(specs);
+       int rate = specs.rate;
+
+       int size = length * samplesize;
+
+       int start, end, current, skip, len;
+       AUD_SequencerStrip* strip;
+       sample_t* buf;
+
+       if(m_buffer->getSize() < size)
+               m_buffer->resize(size);
+       buffer = m_buffer->getBuffer();
+
+       for(AUD_StripIterator i = m_strips.begin(); i != m_strips.end(); i++)
+       {
+               strip = *i;
+               if(!strip->entry->muted)
+               {
+                       if(strip->old_sound != *strip->entry->sound)
+                       {
+                               strip->old_sound = *strip->entry->sound;
+                               if(strip->reader)
+                               {
+                                       delete strip->reader; AUD_DELETE("reader")
+                               }
+
+                               if(strip->old_sound)
+                                       strip->reader = m_mixer.prepare(strip->old_sound->createReader());
+                               else
+                                       strip->reader = NULL;
+                       }
+
+                       if(strip->reader)
+                       {
+                               end = floor(strip->entry->end * rate);
+                               if(m_position < end)
+                               {
+                                       start = floor(strip->entry->begin * rate);
+                                       if(m_position + length > start)
+                                       {
+                                               current = m_position - start;
+                                               if(current < 0)
+                                               {
+                                                       skip = -current;
+                                                       current = 0;
+                                               }
+                                               else
+                                                       skip = 0;
+                                               current += strip->entry->skip * rate;
+                                               len = length > end - m_position ? end - m_position : length;
+                                               len -= skip;
+                                               if(strip->reader->getPosition() != current)
+                                                       strip->reader->seek(current);
+                                               strip->reader->read(len, buf);
+                                               m_mixer.add(buf, skip, len, m_volume(m_data, strip->entry->data, (float)m_position / (float)rate));
+                                       }
+                               }
+                       }
+               }
+       }
+
+       m_mixer.superpose((data_t*)buffer, length, 1.0f);
+
+       m_position += length;
+}
diff --git a/intern/audaspace/intern/AUD_SequencerReader.h b/intern/audaspace/intern/AUD_SequencerReader.h
new file mode 100644 (file)
index 0000000..a50e164
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN LGPL LICENSE BLOCK *****
+ *
+ * Copyright 2009 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * AudaSpace is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * AudaSpace 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with AudaSpace.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LGPL LICENSE BLOCK *****
+ */
+
+#ifndef AUD_SEQUENCERREADER
+#define AUD_SEQUENCERREADER
+
+#include "AUD_IReader.h"
+#include "AUD_SequencerFactory.h"
+#include "AUD_Mixer.h"
+
+class AUD_Buffer;
+
+struct AUD_SequencerStrip
+{
+       AUD_IFactory* old_sound;
+       AUD_IReader* reader;
+       AUD_SequencerEntry* entry;
+};
+
+/**
+ * This resampling reader uses libsamplerate for resampling.
+ */
+class AUD_SequencerReader : public AUD_IReader
+{
+private:
+       /**
+        * The current position.
+        */
+       int m_position;
+
+       /**
+        * The sound output buffer.
+        */
+       AUD_Buffer *m_buffer;
+
+       /**
+        * The target specification.
+        */
+       AUD_Mixer m_mixer;
+
+       /**
+        * Saves the SequencerFactory the reader belongs to.
+        */
+       AUD_SequencerFactory* m_factory;
+
+       std::list<AUD_SequencerStrip*> m_strips;
+
+       void* m_data;
+       AUD_volumeFunction m_volume;
+
+public:
+       /**
+        * Creates a resampling reader.
+        * \param reader The reader to mix.
+        * \param specs The target specification.
+        * \exception AUD_Exception Thrown if the reader is NULL.
+        */
+       AUD_SequencerReader(AUD_SequencerFactory* factory, std::list<AUD_SequencerEntry*> &entries, AUD_Specs specs, void* data, AUD_volumeFunction volume);
+
+       /**
+        * Destroys the reader.
+        */
+       ~AUD_SequencerReader();
+
+       void destroy();
+
+       void add(AUD_SequencerEntry* entry);
+       void remove(AUD_SequencerEntry* entry);
+
+       virtual bool isSeekable();
+       virtual void seek(int position);
+       virtual int getLength();
+       virtual int getPosition();
+       virtual AUD_Specs getSpecs();
+       virtual AUD_ReaderType getType();
+       virtual bool notify(AUD_Message &message);
+       virtual void read(int & length, sample_t* & buffer);
+};
+
+#endif //AUD_SEQUENCERREADER
index a615bcd0245d5deceb5ff62ecc1add8167565e5e..5a3f25fba077382a7841ffc57eddabf2f8c90984 100644 (file)
@@ -100,7 +100,6 @@ void AUD_SoftwareDevice::mix(data_t* buffer, int length)
                AUD_SoftwareHandle* sound;
                int len;
                sample_t* buf;
-               int sample_size = AUD_DEVICE_SAMPLE_SIZE(m_specs);
                std::list<AUD_SoftwareHandle*> stopSounds;
 
                // for all sounds
@@ -116,7 +115,7 @@ void AUD_SoftwareDevice::mix(data_t* buffer, int length)
                        len = length;
                        sound->reader->read(len, buf);
 
-                       m_mixer->add(buf, len, sound->volume);
+                       m_mixer->add(buf, 0, len, sound->volume);
 
                        // in case the end of the sound is reached
                        if(len < length)
@@ -128,12 +127,6 @@ void AUD_SoftwareDevice::mix(data_t* buffer, int length)
                        }
                }
 
-               // fill with silence
-               if(m_specs.format == AUD_FORMAT_U8)
-                       memset(buffer, 0x80, length * sample_size);
-               else
-                       memset(buffer, 0, length * sample_size);
-
                // superpose
                m_mixer->superpose(buffer, length, m_volume);
 
index 1d60be3979b0043012dc315a3fbab54d39e77401..9e857ce73b045c41e0cb8b3bd9c65678b421aef9 100644 (file)
@@ -97,7 +97,7 @@
 //#define AUD_DEBUG_MEMORY
 
 #ifdef AUD_DEBUG_MEMORY
-int AUD_References(int count = 0, const char* text = "");
+extern int AUD_References(int count, const char* text);
 #define AUD_NEW(text) AUD_References(1, text);
 #define AUD_DELETE(text) AUD_References(-1, text);
 #else
@@ -294,7 +294,11 @@ typedef struct
        union
        {
                // loop reader
-               int loopcount;
+               struct
+               {
+                       int loopcount;
+                       float time;
+               };
 
                // volume reader
                float volume;
index bdf14255391fae2954166052a544ef0bf713d29f..379f435e3b83e918f1f5f8ed21b795938249b693 100644 (file)
                                RelativePath="..\..\intern\AUD_ResampleFactory.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\intern\AUD_SequencerFactory.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\intern\AUD_SequencerFactory.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\intern\AUD_SequencerReader.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\intern\AUD_SequencerReader.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\intern\AUD_SinusFactory.cpp"\r
                                >\r
index e404f1749356d26a3c0bcb9549b4b4eb7cdf560f..2c3aab8eb2b2d37a81e2d2e3fd257598284b3093 100644 (file)
@@ -84,6 +84,13 @@ extern "C" {
         * newly allocated block.  */
        void *MEM_dupallocN(void *vmemh);
 
+       /**
+         * Reallocates a block of memory, and returns pointer to the newly
+         * allocated block, the old one is freed. this is not as optimized
+         * as a system realloc but just makes a new allocation and copies
+         * over from existing memory. */
+       void *MEM_reallocN(void *vmemh, unsigned int len);
+
        /**
         * Allocate a block of memory of size len, with tag name str. The
         * memory is cleared. The name must be static, because only a
index 446daea1c0389639bb5923c66aefd04a7eb896e4..6c6836db8294212c392421873c975e155c21abb9 100644 (file)
@@ -225,6 +225,28 @@ void *MEM_dupallocN(void *vmemh)
        return newp;
 }
 
+void *MEM_reallocN(void *vmemh, unsigned int len)
+{
+       void *newp= NULL;
+       
+       if (vmemh) {
+               MemHead *memh= vmemh;
+               memh--;
+
+               newp= MEM_mallocN(len, memh->name);
+               if(newp) {
+                       if(len < memh->len)
+                               memcpy(newp, vmemh, len);
+                       else
+                               memcpy(newp, vmemh, memh->len);
+               }
+
+               MEM_freeN(vmemh);
+       }
+
+       return newp;
+}
+
 static void make_memhead_header(MemHead *memh, unsigned int len, const char *str)
 {
        MemTail *memt;
index 4c0ee95c4c64390bbde2106b2a7d6628b6a1e957..64061725f1039612d3c7f1b5a738b4d816387ecc 100644 (file)
@@ -409,6 +409,7 @@ get_perm_c(int ispec, SuperMatrix *A, int *perm_c)
              return; 
         default:
              ABORT("Invalid ISPEC");
+                 return;
     }
 
     if ( bnz != 0 ) {
index 25673630fc469d497243c26d5e1297f49e70d227..4ac960b5ef07ead3f23ce2cb3d7f48eb777692b9 100644 (file)
@@ -204,16 +204,13 @@ void FLUID_3D::initBlenderRNA(float *alpha, float *beta)
 //////////////////////////////////////////////////////////////////////
 void FLUID_3D::step()
 {
-
-       int threadval = 1;
 #if PARALLEL==1
+       int threadval = 1;
        threadval = omp_get_max_threads();
-#endif
 
        int stepParts = 1;
        float partSize = _zRes;
 
-#if PARALLEL==1
        stepParts = threadval*2;        // Dividing parallelized sections into numOfThreads * 2 sections
        partSize = (float)_zRes/stepParts;      // Size of one part;
 
@@ -935,7 +932,6 @@ void FLUID_3D::addVorticity(int zBegin, int zEnd)
 
        float *_xVorticity, *_yVorticity, *_zVorticity, *_vorticity;
 
-       int _vIndex = _slabSize + _xRes + 1;
        int bb=0;
        int bt=0;
        int bb1=-1;
index 89ac2c74e15185992cc6c22c43a4d23e64f5c80b..6a27541f432439172b5556cd8843e338d85405ab 100644 (file)
@@ -57,7 +57,6 @@ void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res)
 
        float xTotal = dx * res[0];
        float yTotal = dx * res[1];
-       float zTotal = dx * res[2];
 
        float heighMin = 0.05;
        float heighMax = 0.10;
@@ -408,11 +407,11 @@ void FLUID_3D::advectFieldSemiLagrange(const float dt, const float* velx, const
 void FLUID_3D::advectFieldMacCormack1(const float dt, const float* xVelocity, const float* yVelocity, const float* zVelocity, 
                                float* oldField, float* tempResult, Vec3Int res, int zBegin, int zEnd)
 {
-       const int sx= res[0];
+       /*const int sx= res[0];
        const int sy= res[1];
        const int sz= res[2];
 
-       /*for (int x = 0; x < sx * sy * sz; x++)
+       for (int x = 0; x < sx * sy * sz; x++)
                phiHatN[x] = phiHatN1[x] = oldField[x];*/       // not needed as all the values are written first
 
        float*& phiN    = oldField;
@@ -433,7 +432,6 @@ void FLUID_3D::advectFieldMacCormack2(const float dt, const float* xVelocity, co
        float* t1  = temp1;
        const int sx= res[0];
        const int sy= res[1];
-       const int sz= res[2];
 
        float*& phiN    = oldField;
        float*& phiN1   = newField;
index 4c2e7514af762b66e24f7b6041c7d439e4055283..7056b1db5bec7e3813b7c8fe8caabecd5a6dc566 100644 (file)
 
 #include <MERSENNETWISTER.h>
 
+// Tile file header, update revision upon any change done to the noise generator
+static const char tilefile_headerstring[] = "Noise Tile File rev. ";
+static const char tilefile_revision[] =  "001";
+
 #define NOISE_TILE_SIZE 128
 static const int noiseTileSize = NOISE_TILE_SIZE;
 
@@ -94,7 +98,7 @@ static void downsampleNeumann(const float *from, float *to, int n, int stride)
 {
   // if these values are not local incorrect results are generated
   float downCoeffs[32] = { DOWNCOEFFS };
-  static const float *const aCoCenter= &downCoeffs[16];
+  const float *const aCoCenter= &downCoeffs[16];
        for (int i = 0; i < n / 2; i++) {
                to[i * stride] = 0;
                for (int k = 2 * i - 16; k < 2 * i + 16; k++) { 
@@ -212,6 +216,12 @@ static void upsampleZNeumann(float* to, const float* from, int sx, int sy, int s
 static bool loadTile(float* const noiseTileData, std::string filename)
 {
        FILE* file;
+       char headerbuffer[64];
+       size_t headerlen;
+       size_t bread;
+       int endiantest = 1;
+       char endianness;
+       
        file = fopen(filename.c_str(), "rb");
 
        if (file == NULL) {
@@ -219,11 +229,28 @@ static bool loadTile(float* const noiseTileData, std::string filename)
                return false;
        }
 
+       //Check header
+       headerlen = strlen(tilefile_headerstring) + strlen(tilefile_revision) + 2;
+       bread = fread((void*)headerbuffer, 1, headerlen, file);
+       if (*((unsigned char*)&endiantest) == 1)
+               endianness = 'L';
+       else
+               endianness = 'B';
+       if ((bread != headerlen)
+               || (strncmp(headerbuffer, tilefile_headerstring, strlen(tilefile_headerstring)))
+               || (strncmp(headerbuffer+ strlen(tilefile_headerstring), tilefile_revision, strlen(tilefile_revision)))
+               || (headerbuffer[headerlen-2] != endianness)
+               || (headerbuffer[headerlen-1] != (char)((char)sizeof(long)+'0')))
+       {
+               printf("loadTile : Noise tile '%s' was generated on an incompatible platform.\n",filename.c_str());
+               return false;
+       }
+       
        // dimensions
        size_t gridSize = noiseTileSize * noiseTileSize * noiseTileSize;
 
        // noiseTileData memory is managed by caller
-       size_t bread = fread((void*)noiseTileData, sizeof(float), gridSize, file);
+       bread = fread((void*)noiseTileData, sizeof(float), gridSize, file);
        fclose(file);
        printf("Noise tile file '%s' loaded.\n", filename.c_str());
 
@@ -241,12 +268,27 @@ static void saveTile(float* const noiseTileData, std::string filename)
 {
        FILE* file;
        file = fopen(filename.c_str(), "wb");
+       int endiantest=1;
+       char longsize;
 
        if (file == NULL) {
                printf("saveTile: Noise tile '%s' could not be saved.\n", filename.c_str());
                return;
        } 
 
+       //Write file header
+       fwrite(tilefile_headerstring, strlen(tilefile_headerstring), 1, file);
+       fwrite(tilefile_revision, strlen(tilefile_revision), 1, file);
+       //Endianness
+       if (*((unsigned char*)&endiantest) == 1)
+               fwrite("L", 1, 1, file); //Little endian
+       else
+               fwrite("B",1,1,file); //Big endian
+       //32/64bit
+       longsize = (char)sizeof(long)+'0';
+       fwrite(&longsize, 1, 1, file);
+       
+       
        fwrite((void*)noiseTileData, sizeof(float), noiseTileSize * noiseTileSize * noiseTileSize, file);
        fclose(file);
 
index 814db0bcb1412c8f51f28099023c8416fa7419f5..77a2800335c6d2e5b37a94e791bf981db1dfc774 100644 (file)
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python3.1;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\python\generic;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x;..\..\..\source\blender\gpu;..\..\..\intern\audaspace\intern"\r
-                               PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC"\r
+                               PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC;WITH_FFMPEG"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="1"\r
                                DefaultCharIsUnsigned="true"\r
                                Optimization="2"\r
                                InlineFunctionExpansion="1"\r
                                AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python3.1;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\python\generic;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x;..\..\..\source\blender\gpu;..\..\..\intern\audaspace\intern"\r
-                               PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC;WITH_FFMPEG"\r
                                StringPooling="true"\r
                                RuntimeLibrary="0"\r
                                EnableFunctionLevelLinking="true"\r
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python3.1;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\python\generic;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x;..\..\..\source\blender\gpu;..\..\..\intern\audaspace\intern"\r
-                               PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC"\r
+                               PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC;WITH_FFMPEG"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="1"\r
                                DefaultCharIsUnsigned="true"\r
                                Name="VCCLCompilerTool"\r
                                InlineFunctionExpansion="1"\r
                                AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python3.1;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\python\generic;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x;..\..\..\source\blender\gpu;..\..\..\intern\audaspace\intern"\r
-                               PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT;GLEW_STATIC;WITH_FFMPEG"\r
                                StringPooling="true"\r
                                RuntimeLibrary="0"\r
                                EnableFunctionLevelLinking="true"\r
index 76d84bc8b3dce82da659facd2690c5842482218f..f562f56575594c985b7c7eb37868318fb871aca4 100644 (file)
@@ -49,7 +49,11 @@ class AddPresetBase(bpy.types.Operator):
         file_preset = open(os.path.join(target_path, filename), 'w')
 
         for rna_path in self.preset_values:
-            file_preset.write("%s = %s\n" % (rna_path, eval(rna_path)))
+            value = eval(rna_path)
+            if type(value) == str:
+                value = "'%s'" % value
+
+            file_preset.write("%s = %s\n" % (rna_path, value))
 
         file_preset.close()
 
@@ -125,6 +129,33 @@ class AddPresetCloth(AddPresetBase):
 
     preset_subdir = "cloth"
 
+
+class AddPresetSunSky(AddPresetBase):
+    '''Add a Sky & Atmosphere Preset.'''
+    bl_idname = "lamp.sunsky_preset_add"
+    bl_label = "Add Sunsky Preset"
+    name = AddPresetBase.name
+
+    preset_values = [
+        "bpy.context.object.data.sky.atmosphere_turbidity",
+        "bpy.context.object.data.sky.sky_blend_type",
+        "bpy.context.object.data.sky.sky_blend",
+        "bpy.context.object.data.sky.horizon_brightness",
+        "bpy.context.object.data.sky.spread",
+        "bpy.context.object.data.sky.sky_color_space",
+        "bpy.context.object.data.sky.sky_exposure",
+        "bpy.context.object.data.sky.sun_brightness",
+        "bpy.context.object.data.sky.sun_size",
+        "bpy.context.object.data.sky.backscattered_light",
+        "bpy.context.object.data.sky.sun_intensity",
+        "bpy.context.object.data.sky.atmosphere_inscattering",
+        "bpy.context.object.data.sky.atmosphere_extinction",
+    ]
+
+    preset_subdir = "sunsky"
+
+
 bpy.types.register(AddPresetRender)
 bpy.types.register(AddPresetSSS)
 bpy.types.register(AddPresetCloth)
+bpy.types.register(AddPresetSunSky)
diff --git a/release/scripts/op/sequencer.py b/release/scripts/op/sequencer.py
new file mode 100644 (file)
index 0000000..e78084b
--- /dev/null
@@ -0,0 +1,76 @@
+# ##### 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.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+import bpy
+
+class SequencerCrossfadeSounds(bpy.types.Operator):
+    '''Do crossfading volume animation of two selected sound strips.'''
+
+    bl_idname = "sequencer.crossfade_sounds"
+    bl_label = "Crossfade sounds"
+    bl_register = True
+    bl_undo = True
+
+    def poll(self, context):
+        if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip:
+            return context.scene.sequence_editor.active_strip.type == 'SOUND'
+        else:
+            return False
+
+    def execute(self, context):
+        seq1 = None
+        seq2 = None
+        for s in context.scene.sequence_editor.sequences:
+            if s.selected and s.type == 'SOUND':
+                if seq1 == None:
+                    seq1 = s
+                elif seq2 == None:
+                    seq2 = s
+                else:
+                    seq2 = None
+                    break
+        if seq2 == None:
+            self.report({'ERROR'}, "Select 2 sound strips.")
+            return {'CANCELLED'}
+        if seq1.start_frame_final > seq2.start_frame_final:
+            s = seq1
+            seq1 = seq2
+            seq2 = s
+        if seq1.end_frame_final > seq2.start_frame_final:
+            tempcfra = context.scene.current_frame
+            context.scene.current_frame = seq2.start_frame_final
+            seq1.keyframe_insert('volume')
+            context.scene.current_frame = seq1.end_frame_final
+            seq1.volume = 0
+            seq1.keyframe_insert('volume')
+            seq2.keyframe_insert('volume')
+            context.scene.current_frame = seq2.start_frame_final
+            seq2.volume = 0
+            seq2.keyframe_insert('volume')
+            context.scene.current_frame = tempcfra
+            return {'FINISHED'}
+        else:
+            self.report({'ERROR'}, "The selected strips don't overlap.")
+            return {'CANCELLED'}
+
+bpy.types.register(SequencerCrossfadeSounds)
+
+if __name__ == "__main__":
+    bpy.ops.sequencer.crossfade_sounds()
diff --git a/release/scripts/presets/sunsky/classic.py b/release/scripts/presets/sunsky/classic.py
new file mode 100644 (file)
index 0000000..9ee35d6
--- /dev/null
@@ -0,0 +1,13 @@
+bpy.context.object.data.sky.atmosphere_turbidity = 4.0
+bpy.context.object.data.sky.sky_blend_type = 'ADD'
+bpy.context.object.data.sky.sky_blend = 1.0
+bpy.context.object.data.sky.horizon_brightness = 10.0
+bpy.context.object.data.sky.spread = 1.49011614159e-09
+bpy.context.object.data.sky.sky_color_space = 'SMPTE'
+bpy.context.object.data.sky.sky_exposure = 1.0
+bpy.context.object.data.sky.sun_brightness = 1.00000011921
+bpy.context.object.data.sky.sun_size = 1.00000166893
+bpy.context.object.data.sky.backscattered_light = 0.0
+bpy.context.object.data.sky.sun_intensity = 4.0
+bpy.context.object.data.sky.atmosphere_inscattering = 1.0
+bpy.context.object.data.sky.atmosphere_extinction = 1.0
diff --git a/release/scripts/presets/sunsky/desert.py b/release/scripts/presets/sunsky/desert.py
new file mode 100644 (file)
index 0000000..26ed452
--- /dev/null
@@ -0,0 +1,13 @@
+bpy.context.object.data.sky.atmosphere_turbidity = 6.0
+bpy.context.object.data.sky.sky_blend_type = 'ADD'
+bpy.context.object.data.sky.sky_blend = 1.0
+bpy.context.object.data.sky.horizon_brightness = 4.99999761581
+bpy.context.object.data.sky.spread = 1.49011614159e-09
+bpy.context.object.data.sky.sky_color_space = 'SMPTE'
+bpy.context.object.data.sky.sky_exposure = 1.0
+bpy.context.object.data.sky.sun_brightness = 1.00000011921
+bpy.context.object.data.sky.sun_size = 4.0
+bpy.context.object.data.sky.backscattered_light = 1.0
+bpy.context.object.data.sky.sun_intensity = 1.0
+bpy.context.object.data.sky.atmosphere_inscattering = 1.0
+bpy.context.object.data.sky.atmosphere_extinction = 1.0
diff --git a/release/scripts/presets/sunsky/mountain.py b/release/scripts/presets/sunsky/mountain.py
new file mode 100644 (file)
index 0000000..e35d394
--- /dev/null
@@ -0,0 +1,13 @@
+bpy.context.object.data.sky.atmosphere_turbidity = 2.00000023842
+bpy.context.object.data.sky.sky_blend_type = 'ADD'
+bpy.context.object.data.sky.sky_blend = 1.0
+bpy.context.object.data.sky.horizon_brightness = 0.100000016391
+bpy.context.object.data.sky.spread = 1.0
+bpy.context.object.data.sky.sky_color_space = 'SMPTE'
+bpy.context.object.data.sky.sky_exposure = 1.0
+bpy.context.object.data.sky.sun_brightness = 1.99999988079
+bpy.context.object.data.sky.sun_size = 4.0
+bpy.context.object.data.sky.backscattered_light = -1.0
+bpy.context.object.data.sky.sun_intensity = 10.0
+bpy.context.object.data.sky.atmosphere_inscattering = 1.0
+bpy.context.object.data.sky.atmosphere_extinction = 1.0
index d12138e64b93ea599b0bd98438099076512ee592..8d32eeaed9816de8b1ca4415affb0372f6126290 100644 (file)
@@ -23,6 +23,13 @@ from rna_prop_ui import PropertyPanel
 narrowui = 180
 
 
+class LAMP_MT_sunsky_presets(bpy.types.Menu):
+    bl_label = "Render Presets"
+    preset_subdir = "sunsky"
+    preset_operator = "script.python_file_run"
+    draw = bpy.types.Menu.draw_preset
+
+
 class DataButtonsPanel(bpy.types.Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -129,16 +136,19 @@ class DATA_PT_sunsky(DataButtonsPanel):
         lamp = context.lamp.sky
         wide_ui = context.region.width > narrowui
 
-        layout.prop(lamp, "sky")
+        row = layout.row(align=True)
+        row.prop(lamp, "use_sky")
+        row.menu("LAMP_MT_sunsky_presets", text="Presets")
+        row.operator("lamp.sunsky_preset_add", text="Add")
 
         row = layout.row()
-        row.active = lamp.sky or lamp.atmosphere
+        row.active = lamp.use_sky or lamp.use_atmosphere
         row.prop(lamp, "atmosphere_turbidity", text="Turbidity")
 
         split = layout.split()
 
         col = split.column()
-        col.active = lamp.sky
+        col.active = lamp.use_sky
         col.label(text="Blending:")
         sub = col.column()
         sub.prop(lamp, "sky_blend_type", text="")
@@ -151,7 +161,7 @@ class DATA_PT_sunsky(DataButtonsPanel):
 
         if wide_ui:
             col = split.column()
-        col.active = lamp.sky
+        col.active = lamp.use_sky
         col.label(text="Horizon:")
         sub = col.column()
         sub.prop(lamp, "horizon_brightness", text="Brightness")
@@ -165,19 +175,19 @@ class DATA_PT_sunsky(DataButtonsPanel):
 
         layout.separator()
 
-        layout.prop(lamp, "atmosphere")
+        layout.prop(lamp, "use_atmosphere")
 
         split = layout.split()
 
         col = split.column()
-        col.active = lamp.atmosphere
+        col.active = lamp.use_atmosphere
         col.label(text="Intensity:")
         col.prop(lamp, "sun_intensity", text="Sun")
         col.prop(lamp, "atmosphere_distance_factor", text="Distance")
 
         if wide_ui:
             col = split.column()
-        col.active = lamp.atmosphere
+        col.active = lamp.use_atmosphere
         col.label(text="Scattering:")
         sub = col.column(align=True)
         sub.prop(lamp, "atmosphere_inscattering", slider=True, text="Inscattering")
@@ -381,6 +391,8 @@ class DATA_PT_falloff_curve(DataButtonsPanel):
         self.layout.template_curve_mapping(lamp, "falloff_curve")
 
 
+bpy.types.register(LAMP_MT_sunsky_presets)
+
 bpy.types.register(DATA_PT_context_lamp)
 bpy.types.register(DATA_PT_preview)
 bpy.types.register(DATA_PT_lamp)
index dfd182283e84472074ea043e78e4dc9b8e6dbd07..ca7edf1e3ee685ab79395a30ef3f3514b76a2d9e 100644 (file)
@@ -98,7 +98,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
         if ob:
             row = layout.row()
 
-            row.template_list(ob, "materials", ob, "active_material_index", rows=2)
+            row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
 
             col = row.column(align=True)
             col.operator("object.material_slot_add", icon='ZOOMIN', text="")
@@ -274,7 +274,7 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
         col = split.column()
         col.prop(mat, "traceable")
         col.prop(mat, "full_oversampling")
-        col.prop(mat, "sky")
+        col.prop(mat, "use_sky")
         col.prop(mat, "exclude_mist")
         col.prop(mat, "invert_z")
         sub = col.row()
index e5f24490048f0acae9362b82c04451e67cf7ce84..ecd234b62ecae9d7883b058429720cc98a48ff0f 100644 (file)
@@ -250,8 +250,8 @@ class RENDER_PT_performance(RenderButtonsPanel):
             col = split.column()
         col.label(text="Memory:")
         sub = col.column()
+        sub.enabled = not (rd.use_border or rd.full_sample) 
         sub.prop(rd, "save_buffers")
-        sub.enabled = not rd.full_sample
         sub = col.column()
         sub.active = rd.use_compositing
         sub.prop(rd, "free_image_textures")
@@ -450,11 +450,11 @@ class RENDER_PT_encoding(RenderButtonsPanel):
         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
 
         # Audio:
-        layout.prop(rd, "ffmpeg_multiplex_audio", text="Audio")
-
         sub = layout.column()
-        sub.active = rd.ffmpeg_multiplex_audio
-        sub.prop(rd, "ffmpeg_audio_codec", text="Codec")
+
+        if rd.ffmpeg_format not in ('MP3'):
+          sub.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
+
         sub.separator()
 
         split = sub.split()
@@ -488,7 +488,9 @@ class RENDER_PT_antialiasing(RenderButtonsPanel):
 
         col = split.column()
         col.row().prop(rd, "antialiasing_samples", expand=True)
-        col.prop(rd, "full_sample")
+        sub = col.row() 
+        sub.enabled = not rd.use_border
+        sub.prop(rd, "full_sample")
 
         if wide_ui:
             col = split.column()
index 7de0df2dfe4cdd9297084fa9267244000ab47d91..f52cb9840c6415c725f65cffef733d7436a422a0 100644 (file)
@@ -98,7 +98,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel):
         if tex_collection:
             row = layout.row()
 
-            row.template_list(idblock, "textures", idblock, "active_texture_index", rows=2)
+            row.template_list(idblock, "texture_slots", idblock, "active_texture_index", rows=2)
 
             col = row.column(align=True)
             col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
index 2bd0300c465949678659fbdabc00f3c1ebf27271..f0ddc3b4651cfb3e64bb9cb6ca65d2766df63885 100644 (file)
@@ -130,6 +130,8 @@ class DOPESHEET_MT_channel(bpy.types.Menu):
     def draw(self, context):
         layout = self.layout
 
+        layout.operator_context = 'INVOKE_REGION_CHANNELS'
+
         layout.column()
         layout.operator("anim.channels_setting_toggle")
         layout.operator("anim.channels_setting_enable")
index 511ab06d0dad56191d9ece3a5223e07bb7a619aa..3ee85672f2895092f14f7681129cfd1be7d63498 100644 (file)
@@ -133,6 +133,8 @@ class GRAPH_MT_channel(bpy.types.Menu):
     def draw(self, context):
         layout = self.layout
 
+        layout.operator_context = 'INVOKE_REGION_CHANNELS'
+
         layout.column()
         layout.operator("anim.channels_setting_toggle")
         layout.operator("anim.channels_setting_enable")
index 9a63903300e9f296acd1262f47fe883753471077..d1b7affc1be964aaa98651314ed6d18a0df41b57 100644 (file)
@@ -123,7 +123,9 @@ class SEQUENCER_MT_view(bpy.types.Menu):
         if (st.view_type == 'SEQUENCER') or (st.view_type == 'SEQUENCER_PREVIEW'):
             layout.operator("sequencer.view_all", text='View all Sequences')
         if (st.view_type == 'PREVIEW') or (st.view_type == 'SEQUENCER_PREVIEW'):
+            layout.operator_context = 'INVOKE_REGION_PREVIEW'
             layout.operator("sequencer.view_all_preview", text='Fit preview in window')
+            layout.operator_context = 'INVOKE_DEFAULT'
         layout.operator("sequencer.view_selected")
 
         layout.prop(st, "draw_frames")
index 9839cde9a225657400da55b82d8b19b97724e809..bdcfec84bdf7191730d47913011d9f9e0af118fc 100644 (file)
@@ -34,6 +34,7 @@ struct ChannelDriver;
 struct DriverVar;
 struct DriverTarget;
 
+struct bAction;
 struct BezTriple;
 struct StructRNA;
 struct PointerRNA;
index 3a0cbd9d8721450e9ef8e8ab649848fd4ac4b30c..ebf4f09ffd4718aa642f19353402d4bc612c1be9 100644 (file)
@@ -234,6 +234,8 @@ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
 void   BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
 void   BKE_screen_area_free(struct ScrArea *sa);
 
+struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
+
 /* screen */
 void free_screen(struct bScreen *sc); 
 unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
index 0c84d729d474879cd8054791cb40d73410c96b0d..49afe201c92c4f118b23f2206fb59ebc4bdaba22 100644 (file)
@@ -150,8 +150,8 @@ struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra,
 struct ImBuf *give_ibuf_seq_threaded(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size);
 struct ImBuf *give_ibuf_seq_direct(struct Scene *scene, int rectx, int recty, int cfra, int render_size, struct Sequence *seq);
 void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size);
-void calc_sequence(struct Sequence *seq);
-void calc_sequence_disp(struct Sequence *seq);
+void calc_sequence(struct Scene *scene, struct Sequence *seq);
+void calc_sequence_disp(struct Scene *scene, struct Sequence *seq);
 void new_tstripdata(struct Sequence *seq);
 void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq);
 void sort_seq(struct Scene *scene);
@@ -191,8 +191,8 @@ int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene);
 int seqbase_isolated_sel_check(struct ListBase *seqbase);
 void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage);
 
-void seq_update_sound(struct Sequence *seq);
-void seq_update_muting(struct Editing *ed);
+void seq_update_sound(struct Scene* scene, struct Sequence *seq);
+void seq_update_muting(struct Scene* scene, struct Editing *ed);
 void seqbase_sound_reload(Scene *scene, ListBase *seqbase);
 void clear_scene_in_allseqs(struct Scene *sce);
 
index 82ef525ba918077dc696e2de4d597fc855ef6b90..1c9a7db03c3c322580ea75667497f7762c2edfee 100644 (file)
@@ -36,6 +36,7 @@ struct bSound;
 struct bContext;
 struct ListBase;
 struct Main;
+struct Sequence;
 
 void sound_init();
 
@@ -63,20 +64,28 @@ void sound_load(struct Main *main, struct bSound* sound);
 
 void sound_free(struct bSound* sound);
 
-void sound_unlink(struct bContext *C, struct bSound* sound);
+#ifdef AUD_CAPI
+AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume);
+#endif
 
-struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip);
+void sound_create_scene(struct Scene *scene);
 
-void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle);
+void sound_destroy_scene(struct Scene *scene);
 
-void sound_update_playing(struct bContext *C);
+void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip);
 
-void sound_scrub(struct bContext *C);
+void sound_remove_scene_sound(struct Scene *scene, void* handle);
 
-#ifdef AUD_CAPI
-AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, int end, float volume);
-#endif
+void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute);
+
+void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip);
+
+void sound_play_scene(struct Scene *scene);
+
+void sound_stop_scene(struct Scene *scene);
+
+void sound_seek_scene(struct bContext *C);
 
-void sound_stop_all(struct bContext *C);
+int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length);
 
 #endif
index 98c385ea2e1678364c688dbd8ac7eb3b165adfda..20c5b2fd46fc3f50bd75b17a801b0be5e4fb3600 100644 (file)
@@ -45,6 +45,8 @@ extern "C" {
 #define FFMPEG_FLV      8
 #define FFMPEG_MKV      9
 #define FFMPEG_OGG      10
+#define FFMPEG_WAV      11
+#define FFMPEG_MP3      12
 
 #define FFMPEG_PRESET_NONE             0
 #define FFMPEG_PRESET_DVD              1
index 69d43317013c77060dd6d27319ffad00a05cdc97..ea30d4404bea08f93c1382775093785044582675 100644 (file)
@@ -73,6 +73,10 @@ ELSE(WITH_PYTHON)
        ADD_DEFINITIONS(-DDISABLE_PYTHON)
 ENDIF(WITH_PYTHON)
 
+IF(WITH_OPENMP)
+               ADD_DEFINITIONS(-DPARALLEL=1)
+ENDIF(WITH_OPENMP)
+
 IF(NOT WITH_ELBEEM)
        ADD_DEFINITIONS(-DDISABLE_ELBEEM)
 ENDIF(NOT WITH_ELBEEM)
index d8201c277f701c6f671de22c30bf904f87f91c39..73f6a8393ed8e275395a7a24e7c286f81a0f3d52 100644 (file)
@@ -55,6 +55,10 @@ if env['WITH_BF_QUICKTIME']:
 if env['WITH_BF_BULLET']:
        defs.append('USE_BULLET')
 
+if env['OURPLATFORM'] == 'darwin':
+    if env['WITH_BF_OPENMP']:
+       defs.append('PARALLEL=1')
+
 if env['BF_NO_ELBEEM']:
        defs.append('DISABLE_ELBEEM')
 
index 60e1015f190bc75c30dae697d61cdd342df557fb..eb316c64af488f450b8ea8a8bc2c3cc9265498c2 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "CCGSubSurf.h"
 
+#include "MEM_guardedalloc.h"
 #include "BLO_sys_types.h" // for intptr_t support
 
 #ifdef _MSC_VER
@@ -689,8 +690,8 @@ void ccgSubSurf_free(CCGSubSurf *ss) {
                _ehash_free(ss->oldEMap, (EHEntryFreeFP) _edge_free, ss);
                _ehash_free(ss->oldVMap, (EHEntryFreeFP) _vert_free, ss);
 
-               CCGSUBSURF_free(ss, ss->tempVerts);
-               CCGSUBSURF_free(ss, ss->tempEdges);
+               MEM_freeN(ss->tempVerts);
+               MEM_freeN(ss->tempEdges);
        }
 
        CCGSUBSURF_free(ss, ss->r);
@@ -815,8 +816,8 @@ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss) {
        ss->numGrids = 0;
 
        ss->lenTempArrays = 12;
-       ss->tempVerts = CCGSUBSURF_alloc(ss, sizeof(*ss->tempVerts)*ss->lenTempArrays);
-       ss->tempEdges = CCGSUBSURF_alloc(ss, sizeof(*ss->tempEdges)*ss->lenTempArrays);
+       ss->tempVerts = MEM_mallocN(sizeof(*ss->tempVerts)*ss->lenTempArrays, "CCGSubsurf tempVerts");
+       ss->tempEdges = MEM_mallocN(sizeof(*ss->tempEdges)*ss->lenTempArrays, "CCGSubsurf tempEdges");
 
        ss->syncState = eSyncState_Vert;
 
@@ -1006,10 +1007,9 @@ CCGError ccgSubSurf_syncFace(CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGV
        int j, k, topologyChanged = 0;
 
        if (numVerts>ss->lenTempArrays) {
-               int oldLen = ss->lenTempArrays;
                ss->lenTempArrays = (numVerts<ss->lenTempArrays*2)?ss->lenTempArrays*2:numVerts;
-               ss->tempVerts = CCGSUBSURF_realloc(ss, ss->tempVerts, sizeof(*ss->tempVerts)*ss->lenTempArrays, sizeof(*ss->tempVerts)*oldLen);
-               ss->tempEdges = CCGSUBSURF_realloc(ss, ss->tempEdges, sizeof(*ss->tempEdges)*ss->lenTempArrays, sizeof(*ss->tempEdges)*oldLen);
+               ss->tempVerts = MEM_reallocN(ss->tempVerts, sizeof(*ss->tempVerts)*ss->lenTempArrays);
+               ss->tempEdges = MEM_reallocN(ss->tempEdges, sizeof(*ss->tempEdges)*ss->lenTempArrays);
        }
 
        if (ss->syncState==eSyncState_Partial) {
@@ -1124,8 +1124,8 @@ CCGError ccgSubSurf_processSync(CCGSubSurf *ss) {
                _ehash_free(ss->oldFMap, (EHEntryFreeFP) _face_unlinkMarkAndFree, ss);
                _ehash_free(ss->oldEMap, (EHEntryFreeFP) _edge_unlinkMarkAndFree, ss);
                _ehash_free(ss->oldVMap, (EHEntryFreeFP) _vert_free, ss);
-               CCGSUBSURF_free(ss, ss->tempEdges);
-               CCGSUBSURF_free(ss, ss->tempVerts);
+               MEM_freeN(ss->tempEdges);
+               MEM_freeN(ss->tempVerts);
 
                ss->lenTempArrays = 0;
 
@@ -1691,8 +1691,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
 
                #pragma omp critical
                {
-                       q = CCGSUBSURF_alloc(ss, ss->meshIFC.vertDataSize);
-                       r = CCGSUBSURF_alloc(ss, ss->meshIFC.vertDataSize);
+                       q = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf q");
+                       r = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf r");
                }
 
                #pragma omp for schedule(static)
@@ -1781,8 +1781,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
 
                #pragma omp critical
                {
-                       CCGSUBSURF_free(ss, q);
-                       CCGSUBSURF_free(ss, r);
+                       MEM_freeN(q);
+                       MEM_freeN(r);
                }
        }
 
@@ -1837,9 +1837,9 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
        int curLvl, nextLvl;
        void *q = ss->q, *r = ss->r;
 
-       effectedV = CCGSUBSURF_alloc(ss, sizeof(*effectedV)*ss->vMap->numEntries);
-       effectedE = CCGSUBSURF_alloc(ss, sizeof(*effectedE)*ss->eMap->numEntries);
-       effectedF = CCGSUBSURF_alloc(ss, sizeof(*effectedF)*ss->fMap->numEntries);
+       effectedV = MEM_mallocN(sizeof(*effectedV)*ss->vMap->numEntries, "CCGSubsurf effectedV");
+       effectedE = MEM_mallocN(sizeof(*effectedE)*ss->eMap->numEntries, "CCGSubsurf effectedE");
+       effectedF = MEM_mallocN(sizeof(*effectedF)*ss->fMap->numEntries, "CCGSubsurf effectedF");
        numEffectedV = numEffectedE = numEffectedF = 0;
        for (i=0; i<ss->vMap->curSize; i++) {
                CCGVert *v = (CCGVert*) ss->vMap->buckets[i];
@@ -2097,9 +2097,9 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
                e->flags = 0;
        }
 
-       CCGSUBSURF_free(ss, effectedF);
-       CCGSUBSURF_free(ss, effectedE);
-       CCGSUBSURF_free(ss, effectedV);
+       MEM_freeN(effectedF);
+       MEM_freeN(effectedE);
+       MEM_freeN(effectedV);
 }
 
 static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces, int *freeFaces)
@@ -2108,7 +2108,7 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces
        int i, num;
 
        if(!*faces) {
-               array = CCGSUBSURF_alloc(ss, sizeof(*array)*ss->fMap->numEntries);
+               array = MEM_mallocN(sizeof(*array)*ss->fMap->numEntries, "CCGSubsurf allFaces");
                num = 0;
                for (i=0; i<ss->fMap->curSize; i++) {
                        CCGFace *f = (CCGFace*) ss->fMap->buckets[i];
@@ -2131,8 +2131,8 @@ static void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, CCGFace **faces,
        CCGEdge **arrayE;
        int numV, numE, i, j;
 
-       arrayV = CCGSUBSURF_alloc(ss, sizeof(*arrayV)*ss->vMap->numEntries);
-       arrayE = CCGSUBSURF_alloc(ss, sizeof(*arrayE)*ss->eMap->numEntries);
+       arrayV = MEM_mallocN(sizeof(*arrayV)*ss->vMap->numEntries, "CCGSubsurf arrayV");
+       arrayE = MEM_mallocN(sizeof(*arrayE)*ss->eMap->numEntries, "CCGSubsurf arrayV");
        numV = numE = 0;
 
        for (i=0; i<numFaces; i++) {
@@ -2210,7 +2210,7 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
                }
        }
 
-       if(freeF) CCGSUBSURF_free(ss, effectedF);
+       if(freeF) MEM_freeN(effectedF);
 
        return eCCGError_None;
 }
@@ -2252,7 +2252,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
                }
        }
 
-       if(freeF) CCGSUBSURF_free(ss, effectedF);
+       if(freeF) MEM_freeN(effectedF);
 
        return eCCGError_None;
 }
@@ -2297,9 +2297,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
                VertDataZero(FACE_getCenterData(f));
 
                for (S=0; S<f->numVerts; S++)
-                       if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
-                               for (x=0; x<gridSize; x++)
-                                       VertDataZero(FACE_getIECo(f, lvl, S, x));
+                       for (x=0; x<gridSize; x++)
+                               VertDataZero(FACE_getIECo(f, lvl, S, x));
 
                for (S=0; S<f->numVerts; S++) {
                        int prevS = (S+f->numVerts-1)%f->numVerts;
@@ -2311,10 +2310,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
                                VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
 
                        for (x=1; x<gridSize-1; x++) {
-                               if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
-                                       VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
-                               if (FACE_getEdges(f)[prevS]->flags&Edge_eEffected)
-                                       VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x));
+                               VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
+                               VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x));
                        }
 
                        for (x=0; x<gridSize-1; x++) {
@@ -2351,9 +2348,8 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
                VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts);
 
                for (S=0; S<f->numVerts; S++)
-                       if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
-                               for (x=1; x<gridSize-1; x++)
-                                       VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f);
+                       for (x=1; x<gridSize-1; x++)
+                               VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f);
 
                for (S=0; S<f->numVerts; S++) {
                        int prevS = (S+f->numVerts-1)%f->numVerts;
@@ -2386,9 +2382,9 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
        for (i=0; i<numEffectedF; i++)
                effectedF[i]->flags = 0;
 
-       CCGSUBSURF_free(ss, effectedE);
-       CCGSUBSURF_free(ss, effectedV);
-       if(freeF) CCGSUBSURF_free(ss, effectedF);
+       MEM_freeN(effectedE);
+       MEM_freeN(effectedV);
+       if(freeF) MEM_freeN(effectedF);
 
        return eCCGError_None;
 }
@@ -2415,9 +2411,9 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf
        for (i=0; i<numEffectedF; i++)
                effectedF[i]->flags = 0;
 
-       CCGSUBSURF_free(ss, effectedE);
-       CCGSUBSURF_free(ss, effectedV);
-       if(freeF) CCGSUBSURF_free(ss, effectedF);
+       MEM_freeN(effectedE);
+       MEM_freeN(effectedV);
+       if(freeF) MEM_freeN(effectedF);
 
        return eCCGError_None;
 }
@@ -2449,9 +2445,9 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i
        for (i=0; i<numEffectedF; i++)
                effectedF[i]->flags = 0;
 
-       CCGSUBSURF_free(ss, effectedE);
-       CCGSUBSURF_free(ss, effectedV);
-       if(freeF) CCGSUBSURF_free(ss, effectedF);
+       MEM_freeN(effectedE);
+       MEM_freeN(effectedV);
+       if(freeF) MEM_freeN(effectedF);
 
        return eCCGError_None;
 }
index 95c82d318909252f4fd75b6d64cd3ecf36241ed9..70e1a785787c81770ff7397181b4d475d60bc585 100644 (file)
@@ -129,3 +129,8 @@ ifeq ($(WITH_QUICKTIME), true)
        CPPFLAGS += -DWITH_QUICKTIME
 endif
 
+ifeq ($(OS), darwin)
+    ifeq ($(WITH_BF_OPENMP), true)
+      CPPFLAGS += -DPARALLEL=1
+    endif
+endif
index 2ea54ac1f032cec9e94504e372291b419b9df134..3348f7e94c7cf72aff9af660de8e63fab879d730 100644 (file)
@@ -313,6 +313,7 @@ gsl_poly_solve_quadratic (double a, double b, double c,
 * See Bridson et al. "Robust Treatment of Collision, Contact and Friction for Cloth Animation"
 *     page 4, left column
 */
+#if 0
 static int cloth_get_collision_time ( double a[3], double b[3], double c[3], double d[3], double e[3], double f[3], double solution[3] )
 {
        int num_sols = 0;
@@ -424,6 +425,7 @@ static int cloth_get_collision_time ( double a[3], double b[3], double c[3], dou
 
        return num_sols;
 }
+#endif
 
 
 // w3 is not perfect
@@ -837,6 +839,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo
 }
 #endif
 
+#if 0
 static float projectPointOntoLine(float *p, float *a, float *b) 
 {
    float ba[3], pa[3];
@@ -1067,7 +1070,6 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
        return 0;
 }
 
-#if 0
 static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair )
 {
        EdgeCollPair edgecollpair;
index 18bf824f8d3944928cc247a70e97a88b016a17a4..4f4c1959f342ac934d3f406e692b95206b8bae33 100644 (file)
@@ -2011,14 +2011,6 @@ static void actcon_new_data (void *cdata)
        data->type = 20;
 }
 
-/* only for setting the ID as extern */
-static void actcon_copy_data (bConstraint *con, bConstraint *srccon)
-{
-       //bActionConstraint *src= srccon->data;
-       bActionConstraint *dst= con->data;
-       id_lib_extern((ID *)dst->act); /* would be better solved with something like modifiers_foreachIDLink */
-}
-
 static void actcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
 {
        bActionConstraint *data= con->data;
@@ -2170,7 +2162,7 @@ static bConstraintTypeInfo CTI_ACTION = {
        NULL, /* free data */
        actcon_relink, /* relink data */
        actcon_id_looper, /* id looper */
-       actcon_copy_data, /* copy data */
+       NULL, /* copy data */
        actcon_new_data, /* new data */
        actcon_get_tars, /* get constraint targets */
        actcon_flush_tars, /* flush constraint targets */
@@ -4049,6 +4041,12 @@ void id_loop_constraints (ListBase *conlist, ConstraintIDFunc func, void *userda
 
 /* ......... */
 
+static void con_extern_cb(bConstraint *con, ID **idpoin, void *userdata)
+{
+       if(idpoin && (*idpoin)->lib)
+               id_lib_extern(*idpoin);
+}
+
 /* duplicate all of the constraints in a constraint stack */
 void copy_constraints (ListBase *dst, const ListBase *src)
 {
@@ -4067,8 +4065,15 @@ void copy_constraints (ListBase *dst, const ListBase *src)
                id_us_plus((ID *)con->ipo);
                
                /* only do specific constraints if required */
-               if (cti && cti->copy_data)
-                       cti->copy_data(con, srccon);
+               if (cti) {
+                       if (cti->copy_data) {
+                               cti->copy_data(con, srccon);
+                       }
+
+                       if(cti->id_looper) {
+                               cti->id_looper(con, con_extern_cb, NULL);
+                       }
+               }
        }
 }
 
index 2a0759e6c36d59df15bc5e07b3cdd358638e75c6..050bf7c211fa49b43dc7b6163d03a08ac0ec4b1e 100644 (file)
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <string.h>
+#include <errno.h>
 
 #ifndef _WIN32 
 #include <unistd.h>
@@ -76,8 +77,8 @@
 #include "BKE_object.h"
 #include "BKE_material.h"
 #include "BKE_exotic.h"
+#include "BKE_report.h"
 
-/*  #include "BKE_error.h" */
 #include "BKE_screen.h"
 #include "BKE_displist.h"
 #include "BKE_DerivedMesh.h"
@@ -205,18 +206,31 @@ static void read_stl_mesh_binary(Scene *scene, char *str)
        unsigned int numfacets = 0, i, j, vertnum;
        unsigned int maxmeshsize, nummesh, lastmeshsize;
        unsigned int totvert, totface;
+       ReportList *reports= NULL; /* XXX */
 
        fpSTL= fopen(str, "rb");
        if(fpSTL==NULL) {
-               //XXX error("Can't read file");
+               BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno));
                return;
        }
 
-       fseek(fpSTL, 80, SEEK_SET);
-       fread(&numfacets, 4*sizeof(char), 1, fpSTL);
+       if(fseek(fpSTL, 80, SEEK_SET) != 0) {
+               BKE_reportf(reports, RPT_ERROR, "Failed reading file: %s.", strerror(errno));
+               fclose(fpSTL);
+               return;
+       }
+
+       if(fread(&numfacets, 4*sizeof(char), 1, fpSTL) != 1) {
+               if(feof(fpSTL))
+                       BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file.");
+               else
+                       BKE_reportf(reports, RPT_ERROR, "Failed reading file: %s.", strerror(errno));
+               fclose(fpSTL);
+               return;
+       }
        if (ENDIAN_ORDER==B_ENDIAN) {
-                SWITCH_INT(numfacets);
-        }
+               SWITCH_INT(numfacets);
+       }
 
        maxmeshsize = MESH_MAX_VERTS/3;
 
@@ -318,13 +332,14 @@ static void read_stl_mesh_ascii(Scene *scene, char *str)
        unsigned int numtenthousand, linenum;
        unsigned int i, vertnum;
        unsigned int totvert, totface;
+       ReportList *reports= NULL; /* XXX */
 
        /* ASCII stl sucks ... we don't really know how many faces there
           are until the file is done, so lets allocate faces 10000 at a time */
 
        fpSTL= fopen(str, "r");
        if(fpSTL==NULL) {
-               //XXX error("Can't read file");
+               BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno));
                return;
        }
        
@@ -634,6 +649,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
        int file, filelen, count, lll, face, nr = 0;
        int skipdata, ok, a, b, tot, first, colnr, coordtype, polytype, *idata;
        struct DispList *dl;
+       ReportList *reports= NULL; /* XXX */
        
        ivbase.first= ivbase.last= 0;
        iv_curcol= 0;
@@ -641,7 +657,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
        
        file= open(str, O_BINARY|O_RDONLY);
        if(file== -1) {
-               //XXX error("Can't read file\n");
+               BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno));
                return;
        }
 
@@ -652,7 +668,11 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
        }
        
        maindata= MEM_mallocN(filelen, "leesInventor");
-       read(file, maindata, filelen);
+       if(read(file, maindata, filelen) < filelen) {
+               BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file.");
+               close(file);
+               return;
+       }
        close(file);
 
        iv_data_stack= MEM_mallocN(sizeof(float)*IV_MAXSTACK, "ivstack");
@@ -1895,6 +1915,7 @@ void write_stl(Scene *scene, char *str)
        Base   *base;
        FILE   *fpSTL;
        int    numfacets = 0;
+       ReportList *reports= NULL; /* XXX */
        
        if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0;
        if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0;
@@ -1908,7 +1929,7 @@ void write_stl(Scene *scene, char *str)
        fpSTL= fopen(str, "wb");
        
        if(fpSTL==NULL) {
-               //XXX error("Can't write file");
+               BKE_reportf(reports, RPT_ERROR, "Can't open file: %s.", strerror(errno));
                return;
        }
        strcpy(temp_dir, str);
@@ -3388,7 +3409,7 @@ static void dxf_read_polyline(Scene *scene, int noob) {
        /* Blender vars */
        Object *ob;
        Mesh *me;
-       float vert[3];
+       float vert[3] = {0};
        
        MVert *mvert, *vtmp;
        MFace *mface, *ftmp;
@@ -3613,7 +3634,7 @@ static void dxf_read_lwpolyline(Scene *scene, int noob) {
        /* Blender vars */
        Object *ob;
        Mesh *me;
-       float vert[3];
+       float vert[3] = {0};
        
        MVert *mvert;
        MFace *mface;
index 20f8d4852ce97eeb3c869491de9087467af8b79a..e3b860ec0410c90e06b74e01008ebb2f9ea672f5 100644 (file)
@@ -96,16 +96,11 @@ static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lv
 {
        mmd->totlvl = lvl;
 
-       if(ob->mode != OB_MODE_SCULPT) {
-               mmd->lvl = MAX2(mmd->lvl, lvl);
-               CLAMP(mmd->lvl, 0, mmd->totlvl);
-       }
-
-       mmd->sculptlvl = MAX2(mmd->sculptlvl, lvl);
-       CLAMP(mmd->sculptlvl, 0, mmd->totlvl);
+       if(ob->mode != OB_MODE_SCULPT)
+               mmd->lvl = CLAMPIS(MAX2(mmd->lvl, lvl), 0, mmd->totlvl);
 
-       mmd->renderlvl = MAX2(mmd->renderlvl, lvl);
-       CLAMP(mmd->renderlvl, 0, mmd->totlvl);
+       mmd->sculptlvl = CLAMPIS(MAX2(mmd->sculptlvl, lvl), 0, mmd->totlvl);
+       mmd->renderlvl = CLAMPIS(MAX2(mmd->renderlvl, lvl), 0, mmd->totlvl);
 }
 
 static void multires_dm_mark_as_modified(DerivedMesh *dm)
index ec3cf453c4bc1cbcb679935cfe0e3a17a2bc9a78..285dc1014978854ad0a9b8f1ce22f48731069715 100644 (file)
@@ -2872,7 +2872,7 @@ void ntreeCompositTagRender(Scene *curscene)
 static int node_animation_properties(bNodeTree *ntree, bNode *node)
 {
        bNodeSocket *sock;
-       ListBase *lb;
+       const ListBase *lb;
        Link *link;
        PointerRNA ptr;
        PropertyRNA *prop;
index 9bdc700c313e395399cce58630f4b6074a16334b..71cea63b0bc2ccf6aba1afa85c07603e0ac46515 100644 (file)
 #include "DNA_smoke_types.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_threads.h"
 
+#include "PIL_time.h"
+
+#include "WM_api.h"
+
+#include "BKE_blender.h"
 #include "BKE_cloth.h"
 #include "BKE_depsgraph.h"
 #include "BKE_global.h"
@@ -58,8 +64,6 @@
 #include "BKE_utildefines.h"
 #include "BIK_api.h"
 
-#include "BLI_blenlib.h"
-
 /* both in intern */
 #include "smoke_API.h"
 
   #include "BLI_winstuff.h"
 #endif
 
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
+#include <pthread.h>
+extern pthread_key_t gomp_tls_key;
+static void *thread_tls_data;
+#endif
+
 #define PTCACHE_DATA_FROM(data, type, from)            if(data[type]) { memcpy(data[type], from, ptcache_data_size[type]); }
 #define PTCACHE_DATA_TO(data, type, index, to) if(data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); }
 
@@ -2247,6 +2258,32 @@ void BKE_ptcache_quick_cache_all(Scene *scene)
                BKE_ptcache_make_cache(&baker);
 }
 
+/* Simulation thread, no need for interlocks as data written in both threads
+ are only unitary integers (I/O assumed to be atomic for them) */
+typedef struct {
+       int break_operation;
+       int thread_ended;
+       int endframe;
+       int step;
+       int *cfra_ptr;
+       Scene *scene;
+} ptcache_make_cache_data;
+
+static void *ptcache_make_cache_thread(void *ptr) {
+       ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr;
+
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+       // Workaround for Apple gcc 4.2.1 omp vs background thread bug
+       pthread_setspecific (gomp_tls_key, thread_tls_data);
+#endif
+       
+       for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step)
+               scene_update_for_newframe(data->scene, data->scene->lay);
+
+       data->thread_ended = TRUE;
+       return NULL;
+}
+
 /* if bake is not given run simulations to current frame */
 void BKE_ptcache_make_cache(PTCacheBaker* baker)
 {
@@ -2258,10 +2295,16 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
        float frameleno = scene->r.framelen;
        int cfrao = CFRA;
        int startframe = MAXFRAME;
-       int endframe = baker->anim_init ? scene->r.sfra : CFRA;
        int bake = baker->bake;
        int render = baker->render;
-       int step = baker->quick_step;
+       ListBase threads;
+       ptcache_make_cache_data thread_data;
+       int progress, old_progress;
+       
+       thread_data.endframe = baker->anim_init ? scene->r.sfra : CFRA;
+       thread_data.step = baker->quick_step;
+       thread_data.cfra_ptr = &CFRA;
+       thread_data.scene = baker->scene;
 
        G.afbreek = 0;
 
@@ -2299,11 +2342,11 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
                        startframe = MAX2(cache->last_exact, cache->startframe);
 
                        if(bake) {
-                               endframe = cache->endframe;
+                               thread_data.endframe = cache->endframe;
                                cache->flag |= PTCACHE_BAKING;
                        }
                        else {
-                               endframe = MIN2(endframe, cache->endframe);
+                               thread_data.endframe = MIN2(thread_data.endframe, cache->endframe);
                        }
 
                        cache->flag &= ~PTCACHE_BAKED;
@@ -2335,7 +2378,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
                                        cache->flag |= PTCACHE_BAKING;
 
                                        if(bake)
-                                               endframe = MAX2(endframe, cache->endframe);
+                                               thread_data.endframe = MAX2(thread_data.endframe, cache->endframe);
                                }
 
                                cache->flag &= ~PTCACHE_BAKED;
@@ -2345,30 +2388,45 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
                BLI_freelistN(&pidlist);
        }
 
-       CFRA= startframe;
+       CFRA = startframe;
        scene->r.framelen = 1.0;
-
-       for(; CFRA <= endframe; CFRA+=step) {
-               int prog;
+       thread_data.break_operation = FALSE;
+       thread_data.thread_ended = FALSE;
+       old_progress = -1;
+       
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+       // Workaround for Apple gcc 4.2.1 omp vs background thread bug
+       thread_tls_data = pthread_getspecific(gomp_tls_key);
+#endif
+       BLI_init_threads(&threads, ptcache_make_cache_thread, 1);
+       BLI_insert_thread(&threads, (void*)&thread_data);
+       
+       while (thread_data.thread_ended == FALSE) {
 
                if(bake)
-                       prog = (int)(100.0f * (float)(CFRA - startframe)/(float)(endframe-startframe));
+                       progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe));
                else
-                       prog = CFRA;
+                       progress = CFRA;
 
                /* NOTE: baking should not redraw whole ui as this slows things down */
-               if(baker->progressbar)
-                       baker->progressbar(baker->progresscontext, prog);
+               if ((baker->progressbar) && (progress != old_progress)) {
+                       baker->progressbar(baker->progresscontext, progress);
+                       old_progress = progress;
+               }
                
-               scene_update_for_newframe(scene, scene->lay);
+               /* Delay to lessen CPU load from UI thread */
+               PIL_sleep_ms(200);
 
                /* NOTE: breaking baking should leave calculated frames in cache, not clear it */
-               if(baker->break_test && baker->break_test(baker->break_data))
-                       break;
+               if(blender_test_break() && !thread_data.break_operation) {
+                       thread_data.break_operation = TRUE;
+                       if (baker->progressend)
+                               baker->progressend(baker->progresscontext);
+                       WM_cursor_wait(1);
+               }
        }
 
-       if (baker->progressend)
-               baker->progressend(baker->progresscontext);
+       BLI_end_threads(&threads);
 
        /* clear baking flag */
        if(pid) {
@@ -2391,7 +2449,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
                
                        cache = pid->cache;
 
-                       if(step > 1)
+                       if(thread_data.step > 1)
                                cache->flag &= ~(PTCACHE_BAKING|PTCACHE_OUTDATED);
                        else
                                cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED);
@@ -2413,6 +2471,11 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
        if(bake) /* already on cfra unless baking */
                scene_update_for_newframe(scene, scene->lay);
 
+       if (thread_data.break_operation)
+               WM_cursor_wait(0);
+       else if (baker->progressend)
+               baker->progressend(baker->progresscontext);
+
        /* TODO: call redraw all windows somehow */
 }
 /* Helpers */
index 9a20943876e31e786fab8dea84209b2e6da56f9b..9603863b60fb2680c7bfaa0a885e6c70d781b2c9 100644 (file)
@@ -83,6 +83,7 @@
 #include "BKE_sequencer.h"
 #include "BKE_world.h"
 #include "BKE_utildefines.h"
+#include "BKE_sound.h"
 
 //XXX #include "BIF_previewrender.h"
 //XXX #include "BIF_editseq.h"
@@ -235,6 +236,8 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type)
         }
        }
 
+       sound_create_scene(scen);
+
        return scen;
 }
 
@@ -322,6 +325,8 @@ void free_scene(Scene *sce)
 
        if(sce->stats)
                MEM_freeN(sce->stats);
+
+       sound_destroy_scene(sce);
 }
 
 Scene *add_scene(char *name)
@@ -487,6 +492,8 @@ Scene *add_scene(char *name)
        sce->gm.flag = GAME_DISPLAY_LISTS;
        sce->gm.matmode = GAME_MAT_MULTITEX;
 
+       sound_create_scene(sce);
+
        return sce;
 }
 
@@ -726,7 +733,7 @@ Object *scene_find_camera_switch(Scene *scene)
        Object *camera= NULL;
 
        for (m= scene->markers.first; m; m= m->next) {
-               if(m->camera && (m->frame <= cfra) && (m->frame > frame)) {
+               if(m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER)==0 && (m->frame <= cfra) && (m->frame > frame)) {
                        camera= m->camera;
                        frame= m->frame;
 
index 0dc6bf359f6a7d14bac6e671b4325a4591e81c4d..b8ac8d99128970b58b02708228cf73d1b4bec219 100644 (file)
@@ -336,3 +336,19 @@ unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene)
        return layer;
 }
 
+/* ***************** Utilities ********************** */
+
+/* Find a region of the specified type from the given area */
+ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
+{
+       if (sa) {
+               ARegion *ar;
+               
+               for (ar=sa->regionbase.first; ar; ar= ar->next) {
+                       if (ar->regiontype == type)
+                               return ar;
+               }
+       }
+       return NULL;
+}
+
index 9fde073001111b59ce1a849cf7a2b097da1ac080..8c119eb753ba7eaaa37bf5fff42400c158edf562 100644 (file)
@@ -233,8 +233,8 @@ void seq_free_sequence(Scene *scene, Sequence *seq)
                if (ed->act_seq==seq)
                        ed->act_seq= NULL;
 
-               if(seq->sound_handle)
-                       sound_delete_handle(scene, seq->sound_handle);
+               if(seq->scene_sound)
+                       sound_remove_scene_sound(scene, seq->scene_sound);
        }
 
        MEM_freeN(seq);
@@ -484,7 +484,7 @@ void build_seqar_cb(ListBase *seqbase, Sequence  ***seqar, int *totseq,
 }
 
 
-void calc_sequence_disp(Sequence *seq)
+void calc_sequence_disp(Scene *scene, Sequence *seq)
 {
        if(seq->startofs && seq->startstill) seq->startstill= 0;
        if(seq->endofs && seq->endstill) seq->endstill= 0;
@@ -500,10 +500,10 @@ void calc_sequence_disp(Sequence *seq)
                seq->handsize= (float)((seq->enddisp-seq->startdisp)/25);
        }
 
-       seq_update_sound(seq);
+       seq_update_sound(scene, seq);
 }
 
-void calc_sequence(Sequence *seq)
+void calc_sequence(Scene *scene, Sequence *seq)
 {
        Sequence *seqm;
        int min, max;
@@ -511,7 +511,7 @@ void calc_sequence(Sequence *seq)
        /* check all metas recursively */
        seqm= seq->seqbase.first;
        while(seqm) {
-               if(seqm->seqbase.first) calc_sequence(seqm);
+               if(seqm->seqbase.first) calc_sequence(scene, seqm);
                seqm= seqm->next;
        }
 
@@ -534,7 +534,7 @@ void calc_sequence(Sequence *seq)
                        seq->enddisp= MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
                        seq->len= seq->enddisp - seq->startdisp;
                } else {
-                       calc_sequence_disp(seq);
+                       calc_sequence_disp(scene, seq);
                }
 
                if(seq->strip && seq->len!=seq->strip->len) {
@@ -563,7 +563,7 @@ void calc_sequence(Sequence *seq)
                                }
                        }
                }
-               calc_sequence_disp(seq);
+               calc_sequence_disp(scene, seq);
        }
 }
 
@@ -614,7 +614,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq)
                }
                seq->strip->len = seq->len;
        } else if (seq->type == SEQ_SOUND) {
-               seq->len = AUD_getInfo(seq->sound->handle).length * FPS;
+               seq->len = AUD_getInfo(seq->sound->playback_handle).length * FPS;
                seq->len -= seq->anim_startofs;
                seq->len -= seq->anim_endofs;
                if (seq->len < 0) {
@@ -653,7 +653,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq)
 
        free_proxy_seq(seq);
 
-       calc_sequence(seq);
+       calc_sequence(scene, seq);
 }
 
 void sort_seq(Scene *scene)
@@ -3189,7 +3189,7 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan
                }
                
                if(len_change)
-                       calc_sequence(seq);
+                       calc_sequence(scene, seq);
        }
        
        return free_imbuf;
@@ -3239,23 +3239,6 @@ static void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo)
 }
 #endif
 
-static int seq_sound_reload_cb(Sequence *seq, void *arg_pt)
-{
-       if (seq->type==SEQ_SOUND && seq->sound) {
-               Scene *scene= (Scene *)arg_pt;
-               if(seq->sound_handle)
-                       sound_delete_handle(scene, seq->sound_handle);
-
-               seq->sound_handle = sound_new_handle(scene, seq->sound, seq->start, seq->start + seq->strip->len, 0);
-               return 0;
-       }
-       return 1; /* recurse meta's */
-}
-void seqbase_sound_reload(Scene *scene, ListBase *seqbase)
-{
-       seqbase_recursive_apply(seqbase, seq_sound_reload_cb, (void *)scene);
-}
-
 /* seq funcs's for transforming internally
  notice the difference between start/end and left/right.
 
@@ -3463,7 +3446,7 @@ static void seq_translate(Scene *evil_scene, Sequence *seq, int delta)
                }
        }
 
-       calc_sequence_disp(seq);
+       calc_sequence_disp(evil_scene, seq);
 }
 
 /* return 0 if there werent enough space */
@@ -3471,13 +3454,13 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene)
 {
        int orig_machine= test->machine;
        test->machine++;
-       calc_sequence(test);
+       calc_sequence(evil_scene, test);
        while( seq_test_overlap(seqbasep, test) ) {
                if(test->machine >= MAXSEQ) {
                        break;
                }
                test->machine++;
-               calc_sequence(test); // XXX - I dont think this is needed since were only moving vertically, Campbell.
+               calc_sequence(evil_scene, test); // XXX - I dont think this is needed since were only moving vertically, Campbell.
        }
 
        
@@ -3497,7 +3480,7 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene)
                new_frame = new_frame + (test->start-test->startdisp); /* adjust by the startdisp */
                seq_translate(evil_scene, test, new_frame - test->start);
 
-               calc_sequence(test);
+               calc_sequence(evil_scene, test);
                return 0;
        } else {
                return 1;
@@ -3526,7 +3509,7 @@ static int shuffle_seq_time_offset_test(ListBase * seqbasep, char dir)
        return offset;
 }
 
-static int shuffle_seq_time_offset(ListBase * seqbasep, char dir)
+static int shuffle_seq_time_offset(Scene* scene, ListBase * seqbasep, char dir)
 {
        int ofs= 0;
        int tot_ofs= 0;
@@ -3545,7 +3528,7 @@ static int shuffle_seq_time_offset(ListBase * seqbasep, char dir)
 
        for(seq= seqbasep->first; seq; seq= seq->next) {
                if(seq->tmp)
-                       calc_sequence_disp(seq); /* corrects dummy startdisp/enddisp values */
+                       calc_sequence_disp(scene, seq); /* corrects dummy startdisp/enddisp values */
        }
 
        return tot_ofs;
@@ -3557,8 +3540,8 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene)
 
        Sequence *seq;
 
-       int offset_l = shuffle_seq_time_offset(seqbasep, 'L');
-       int offset_r = shuffle_seq_time_offset(seqbasep, 'R');
+       int offset_l = shuffle_seq_time_offset(evil_scene, seqbasep, 'L');
+       int offset_r = shuffle_seq_time_offset(evil_scene, seqbasep, 'R');
        int offset = (-offset_l < offset_r) ?  offset_l:offset_r;
 
        if(offset) {
@@ -3573,19 +3556,16 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene)
        return offset? 0:1;
 }
 
-void seq_update_sound(Sequence *seq)
+void seq_update_sound(Scene* scene, Sequence *seq)
 {
-       if(seq->type == SEQ_SOUND && seq->sound_handle)
+       if(seq->scene_sound)
        {
-               seq->sound_handle->startframe = seq->startdisp;
-               seq->sound_handle->endframe = seq->enddisp;
-               seq->sound_handle->frameskip = seq->startofs + seq->anim_startofs;
-               seq->sound_handle->changed = -1;
+               sound_move_scene_sound(scene, seq->scene_sound, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
                /* mute is set in seq_update_muting_recursive */
        }
 }
 
-static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute)
+static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequence *metaseq, int mute)
 {
        Sequence *seq;
        int seqmute;
@@ -3601,27 +3581,26 @@ static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, i
                        if(seq == metaseq)
                                seqmute= 0;
 
-                       seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute);
+                       seq_update_muting_recursive(scene, &seq->seqbase, metaseq, seqmute);
                }
                else if(seq->type == SEQ_SOUND) {
-                       if(seq->sound_handle && seqmute != seq->sound_handle->mute) {
-                               seq->sound_handle->mute = seqmute;
-                               seq->sound_handle->changed = -1;
+                       if(seq->scene_sound) {
+                               sound_mute_scene_sound(scene, seq->scene_sound, seqmute);
                        }
                }
        }
 }
 
-void seq_update_muting(Editing *ed)
+void seq_update_muting(Scene *scene, Editing *ed)
 {
        if(ed) {
                /* mute all sounds up to current metastack list */
                MetaStack *ms= ed->metastack.last;
 
                if(ms)
-                       seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1);
+                       seq_update_muting_recursive(scene, &ed->seqbase, ms->parseq, 1);
                else
-                       seq_update_muting_recursive(&ed->seqbase, NULL, 0);
+                       seq_update_muting_recursive(scene, &ed->seqbase, NULL, 0);
        }
 }
 
@@ -3744,6 +3723,7 @@ Sequence *alloc_sequence(ListBase *lb, int cfra, int machine)
        seq->machine= machine;
        seq->mul= 1.0;
        seq->blend_opacity = 100.0;
+       seq->volume = 1.0f;
 
        return seq;
 }
@@ -3793,13 +3773,13 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
 
        sound = sound_new_file(CTX_data_main(C), seq_load->path);
 
-       if (sound==NULL || sound->handle == NULL) {
+       if (sound==NULL || sound->playback_handle == NULL) {
                //if(op)
                //      BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
                return NULL;
        }
 
-       info = AUD_getInfo(sound->handle);
+       info = AUD_getInfo(sound->playback_handle);
 
        if (info.specs.channels == AUD_CHANNELS_INVALID) {
                sound_delete(C, sound);
@@ -3824,9 +3804,9 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
 
        BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
 
-       seq->sound_handle = sound_new_handle(scene, sound, seq_load->start_frame, seq_load->start_frame + strip->len, 0);
+       seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + strip->len, 0);
 
-       calc_sequence_disp(seq);
+       calc_sequence_disp(scene, seq);
 
        /* last active name */
        strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1);
@@ -3868,7 +3848,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
 
        BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
 
-       calc_sequence_disp(seq);
+       calc_sequence_disp(scene, seq);
 
 
        if(seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
index a1e3dd6f963e7162ca7f7872aa158d7325af1da8..abf76d0e9983e9b01548778f79c3fa44706ca0ca 100644 (file)
@@ -2864,7 +2864,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
        /* or heun ~ 2nd order runge-kutta steps, mode 1,2 */
        SoftBody *sb= ob->soft; /* is supposed to be there */
        BodyPoint *bp;
-       float dx[3],dv[3],aabbmin[3],aabbmax[3],cm[3]={0.0f,0.0f,0.0f};
+       float dx[3]={0},dv[3],aabbmin[3],aabbmax[3],cm[3]={0.0f,0.0f,0.0f};
        float timeovermass/*,freezeloc=0.00001f,freezeforce=0.00000000001f*/;
        float maxerrpos= 0.0f,maxerrvel = 0.0f;
        int a,fuzzy=0;
index 1be59529cc792b3baec90f6eb7cee522c471f0de..03fe1b8df7bf1e938622f14c6e97283b8bd47b63 100644 (file)
@@ -12,6 +12,7 @@
 #include "BLI_blenlib.h"
 
 #include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_packedFile_types.h"
 #include "DNA_screen_types.h"
@@ -26,6 +27,9 @@
 #include "BKE_context.h"
 #include "BKE_library.h"
 #include "BKE_packedFile.h"
+#include "BKE_fcurve.h"
+
+#include "RNA_access.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -107,7 +111,7 @@ struct bSound* sound_new_file(struct Main *main, char* filename)
 
        sound_load(main, sound);
 
-       if(!sound->handle)
+       if(!sound->playback_handle)
        {
                free_libblock(&main->sound, sound);
                sound = NULL;
@@ -133,7 +137,7 @@ struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source)
 
        sound_load(CTX_data_main(C), sound);
 
-       if(!sound->handle)
+       if(!sound->playback_handle)
        {
                free_libblock(&CTX_data_main(C)->sound, sound);
                sound = NULL;
@@ -159,7 +163,7 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa
 
        sound_load(CTX_data_main(C), sound);
 
-       if(!sound->handle)
+       if(!sound->playback_handle)
        {
                free_libblock(&CTX_data_main(C)->sound, sound);
                sound = NULL;
@@ -175,8 +179,6 @@ void sound_delete(struct bContext *C, struct bSound* sound)
        {
                sound_free(sound);
 
-               sound_unlink(C, sound);
-
                free_libblock(&CTX_data_main(C)->sound, sound);
        }
 }
@@ -187,7 +189,7 @@ void sound_cache(struct bSound* sound, int ignore)
                AUD_unload(sound->cache);
 
        sound->cache = AUD_bufferSound(sound->handle);
-       sound->changed++;
+       sound->playback_handle = sound->cache;
 }
 
 void sound_delete_cache(struct bSound* sound)
@@ -196,6 +198,7 @@ void sound_delete_cache(struct bSound* sound)
        {
                AUD_unload(sound->cache);
                sound->cache = NULL;
+               sound->playback_handle = sound->handle;
        }
 }
 
@@ -207,6 +210,7 @@ void sound_load(struct Main *main, struct bSound* sound)
                {
                        AUD_unload(sound->handle);
                        sound->handle = NULL;
+                       sound->playback_handle = NULL;
                }
 
 // XXX unused currently
@@ -253,7 +257,10 @@ void sound_load(struct Main *main, struct bSound* sound)
                        break;
                }
 #endif
-               sound->changed++;
+               if(sound->cache)
+                       sound->playback_handle = sound->cache;
+               else
+                       sound->playback_handle = sound->handle;
        }
 }
 
@@ -269,243 +276,115 @@ void sound_free(struct bSound* sound)
        {
                AUD_unload(sound->handle);
                sound->handle = NULL;
+               sound->playback_handle = NULL;
        }
 }
 
-void sound_unlink(struct bContext *C, struct bSound* sound)
+static float sound_get_volume(Scene* scene, Sequence* sequence, float time)
 {
-       Scene *scene;
-       SoundHandle *handle;
-
-// XXX unused currently
-#if 0
-       bSound *snd;
-       for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next)
-       {
-               if(snd->child_sound == sound)
-               {
-                       snd->child_sound = NULL;
-                       if(snd->handle)
-                       {
-                               AUD_unload(sound->handle);
-                               snd->handle = NULL;
-                       }
-
-                       sound_unlink(C, snd);
-               }
-       }
-#endif
-
-       for(scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next)
-       {
-               for(handle = scene->sound_handles.first; handle; handle = handle->next)
-               {
-                       if(handle->source == sound)
-                       {
-                               handle->source = NULL;
-                               if(handle->handle)
-                                       AUD_stop(handle->handle);
-                       }
-               }
-       }
+       struct FCurve* fcu = id_data_find_fcurve(&scene->id, sequence, &RNA_Sequence, "volume", 0);
+       if(fcu)
+               return evaluate_fcurve(fcu, time * FPS);
+       else
+               return sequence->volume;
 }
 
-struct SoundHandle* sound_new_handle(struct Scene *scene, struct bSound* sound, int startframe, int endframe, int frameskip)
+AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
 {
-       ListBase* handles = &scene->sound_handles;
+       AUD_Device* mixdown = AUD_openReadDevice(specs);
+
+       AUD_setDeviceVolume(mixdown, volume);
 
-       SoundHandle* handle = MEM_callocN(sizeof(SoundHandle), "sound_handle");
-       handle->source = sound;
-       handle->startframe = startframe;
-       handle->endframe = endframe;
-       handle->frameskip = frameskip;
-       handle->state = AUD_STATUS_INVALID;
-       handle->volume = 1.0f;
+       AUD_playDevice(mixdown, scene->sound_scene, start / FPS);
 
-       BLI_addtail(handles, handle);
+       return mixdown;
+}
 
-       return handle;
+void sound_create_scene(struct Scene *scene)
+{
+       scene->sound_scene = AUD_createSequencer(scene, (AUD_volumeFunction)&sound_get_volume);
 }
 
-void sound_delete_handle(struct Scene *scene, struct SoundHandle *handle)
+void sound_destroy_scene(struct Scene *scene)
 {
-       if(handle == NULL)
-               return;
+       if(scene->sound_scene_handle)
+               AUD_stop(scene->sound_scene_handle);
+       if(scene->sound_scene)
+               AUD_destroySequencer(scene->sound_scene);
+}
 
-       if(handle->handle)
-               AUD_stop(handle->handle);
+void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
+{
+       return AUD_addSequencer(scene->sound_scene, &(sequence->sound->playback_handle), startframe / FPS, endframe / FPS, frameskip / FPS, sequence);
+}
 
-       BLI_freelinkN(&scene->sound_handles, handle);
+void sound_remove_scene_sound(struct Scene *scene, void* handle)
+{
+       AUD_removeSequencer(scene->sound_scene, handle);
 }
 
-void sound_stop_all(struct bContext *C)
+void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute)
 {
-       SoundHandle *handle;
+       AUD_muteSequencer(scene->sound_scene, handle, mute);
+}
 
-       for(handle = CTX_data_scene(C)->sound_handles.first; handle; handle = handle->next)
-       {
-               if(handle->state == AUD_STATUS_PLAYING)
-               {
-                       AUD_pause(handle->handle);
-                       handle->state = AUD_STATUS_PAUSED;
-               }
-       }
+void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip)
+{
+       AUD_moveSequencer(scene->sound_scene, handle, startframe / FPS, endframe / FPS, frameskip / FPS);
 }
 
-void sound_update_playing(struct bContext *C)
+void sound_start_play_scene(struct Scene *scene)
 {
-       SoundHandle *handle;
-       Scene* scene = CTX_data_scene(C);
-       int cfra = CFRA;
-       float fps = FPS;
-       int action;
+       AUD_Sound* sound;
+       sound = AUD_loopSound(scene->sound_scene);
+       scene->sound_scene_handle = AUD_play(sound, 1);
+       AUD_unload(sound);
+}
 
+void sound_play_scene(struct Scene *scene)
+{
        AUD_lock();
 
-       for(handle = scene->sound_handles.first; handle; handle = handle->next)
-       {
-               if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute || (scene->audio.flag & AUDIO_MUTE))
-               {
-                       if(handle->state == AUD_STATUS_PLAYING)
-                       {
-                               AUD_pause(handle->handle);
-                               handle->state = AUD_STATUS_PAUSED;
-                       }
-               }
-               else
-               {
-                       action = 0;
-
-                       if(handle->changed != handle->source->changed)
-                       {
-                               handle->changed = handle->source->changed;
-                               action = 3;
-                               if(handle->state != AUD_STATUS_INVALID)
-                               {
-                                       AUD_stop(handle->handle);
-                                       handle->state = AUD_STATUS_INVALID;
-                               }
-                       }
-                       else
-                       {
-                               if(handle->state != AUD_STATUS_PLAYING)
-                                       action = 3;
-                               else
-                               {
-                                       handle->state = AUD_getStatus(handle->handle);
-                                       if(handle->state != AUD_STATUS_PLAYING)
-                                               action = 3;
-                                       else
-                                       {
-                                               float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe;
-                                               if(diff < 0.0)
-                                                       diff = -diff;
-                                               if(diff > FPS/2.0)
-                                               {
-                                                       action = 2;
-                                               }
-                                       }
-                               }
-                       }
-
-                       AUD_setSoundVolume(handle->handle, handle->volume);
-                       
-                       if(action & 1)
-                       {
-                               if(handle->state == AUD_STATUS_INVALID)
-                               {
-                                       if(handle->source && handle->source->handle)
-                                       {
-                                               AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps);
-                                               handle->handle = AUD_play(limiter, 1);
-                                               AUD_unload(limiter);
-                                               if(handle->handle)
-                                                       handle->state = AUD_STATUS_PLAYING;
-                                               if(cfra == handle->startframe)
-                                                       action &= ~2;
-                                       }
-                               }
-                               else
-                                       if(AUD_resume(handle->handle))
-                                               handle->state = AUD_STATUS_PLAYING;
-                                       else
-                                               handle->state = AUD_STATUS_INVALID;
-                       }
-
-                       if(action & 2)
-                               AUD_seek(handle->handle, (cfra - handle->startframe) / fps);
-               }
-       }
+       if(!scene->sound_scene_handle || AUD_getStatus(scene->sound_scene_handle) == AUD_STATUS_INVALID)
+               sound_start_play_scene(scene);
+
+       AUD_seek(scene->sound_scene_handle, CFRA / FPS);
+       AUD_setLoop(scene->sound_scene_handle, -1, -1);
+       AUD_resume(scene->sound_scene_handle);
 
        AUD_unlock();
 }
 
-void sound_scrub(struct bContext *C)
+void sound_stop_scene(struct Scene *scene)
 {
-       SoundHandle *handle;
-       Scene* scene = CTX_data_scene(C);
-       int cfra = CFRA;
-       float fps = FPS;
-
-       if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer)
-       {
-               AUD_lock();
-
-               for(handle = scene->sound_handles.first; handle; handle = handle->next)
-               {
-                       if(cfra >= handle->startframe && cfra < handle->endframe && !handle->mute)
-                       {
-                               if(handle->source && handle->source->handle)
-                               {
-                                       int frameskip = handle->frameskip + cfra - handle->startframe;
-                                       AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, frameskip / fps, (frameskip + 1)/fps);
-                                       AUD_play(limiter, 0);
-                                       AUD_unload(limiter);
-                               }
-                       }
-               }
-
-               AUD_unlock();
-       }
+       AUD_pause(scene->sound_scene_handle);
 }
 
-AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, int end, float volume)
+void sound_seek_scene(struct bContext *C)
 {
-       AUD_Device* mixdown = AUD_openReadDevice(specs);
-       SoundHandle *handle;
-       float fps = FPS;
-       AUD_Sound *limiter, *delayer;
-       int frameskip, s, e;
+       struct Scene *scene = CTX_data_scene(C);
 
-       end++;
+       AUD_lock();
 
-       AUD_setDeviceVolume(mixdown, volume);
+       if(!scene->sound_scene_handle || AUD_getStatus(scene->sound_scene_handle) == AUD_STATUS_INVALID)
+       {
+               sound_start_play_scene(scene);
+               AUD_pause(scene->sound_scene_handle);
+       }
 
-       for(handle = scene->sound_handles.first; handle; handle = handle->next)
+       if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer)
        {
-               if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->handle)
-               {
-                       frameskip = handle->frameskip;
-                       s = handle->startframe - start;
-                       e = handle->frameskip + AUD_MIN(handle->endframe, end) - handle->startframe;
-
-                       if(s < 0)
-                       {
-                               frameskip -= s;
-                               s = 0;
-                       }
-                       
-                       AUD_setSoundVolume(handle->handle, handle->volume);
-                       
-                       limiter = AUD_limitSound(handle->source->handle, frameskip / fps, e / fps);
-                       delayer = AUD_delaySound(limiter, s / fps);
-
-                       AUD_playDevice(mixdown, delayer);
-
-                       AUD_unload(delayer);
-                       AUD_unload(limiter);
-               }
+               AUD_setLoop(scene->sound_scene_handle, -1, 1 / FPS);
+               AUD_seek(scene->sound_scene_handle, CFRA / FPS);
+               AUD_resume(scene->sound_scene_handle);
        }
+       else
+               AUD_seek(scene->sound_scene_handle, CFRA / FPS);
 
-       return mixdown;
+       AUD_unlock();
+}
+
+int sound_read_sound_buffer(bSound* sound, float* buffer, int length)
+{
+       return AUD_readSound(sound->cache, buffer, length);
 }
index 2ad17b7d0b98a57c225958680764c1025923d6e5..69f02bc6a80dfa4c94d2698e0c4d0651d4af52f7 100644 (file)
@@ -1220,6 +1220,21 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
        glNormal3fv(no);
 }
 
+static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
+{
+       if(ccgdm->pbvh) {
+               CCGFace **faces;
+               int totface;
+
+               BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface);
+               if(totface) {
+                       ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface);
+                       ccgSubSurf_updateNormals(ccgdm->ss, faces, totface);
+                       MEM_freeN(faces);
+               }
+       }
+}
+
        /* Only used by non-editmesh types */
 static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, int (*setMaterial)(int, void *attribs)) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
@@ -1229,20 +1244,12 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
        char *faceFlags = ccgdm->faceFlags;
        int step = (fast)? gridSize-1: 1;
 
-       if(ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
-               CCGFace **faces;
-               int totface;
-
-               BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface);
-               if(totface) {
-                       ccgSubSurf_updateFromFaces(ss, 0, faces, totface);
-                       ccgSubSurf_updateNormals(ss, faces, totface);
-                       MEM_freeN(faces);
-               }
+       ccgdm_pbvh_update(ccgdm);
 
+       if(ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
                if(dm->numFaceData) {
                        /* should be per face */
-                       if(!setMaterial(faceFlags[1], NULL))
+                       if(!setMaterial(faceFlags[1]+1, NULL))
                                return;
 
                        glShadeModel((faceFlags[0] & ME_SMOOTH)? GL_SMOOTH: GL_FLAT);
@@ -1330,6 +1337,8 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v
        char *faceFlags = ccgdm->faceFlags;
        int a, b, i, doDraw, numVerts, matnr, new_matnr, totface;
 
+       ccgdm_pbvh_update(ccgdm);
+
        doDraw = 0;
        numVerts = 0;
        matnr = -1;
@@ -1484,6 +1493,8 @@ static void ccgDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned ch
        unsigned char *cp1, *cp2;
        int useTwoSide=1;
 
+       ccgdm_pbvh_update(ccgdm);
+
        cp1= col1;
        if(col2) {
                cp2= col2;
@@ -1554,6 +1565,8 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
        int i, totface, flag, gridSize = ccgSubSurf_getGridSize(ss);
        int gridFaces = gridSize - 1;
 
+       ccgdm_pbvh_update(ccgdm);
+
        if(!mcol)
                mcol = dm->getFaceDataArray(dm, CD_MCOL);
 
index 634d9e6ce0d923d372204c303e1585ac75a620ab..fce9ed75e937fd087fa082b61a2e79095ce71efa 100644 (file)
@@ -860,8 +860,6 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex)
 
 bNode *give_current_material_texture_node(Material *ma)
 {
-       bNode *node;
-       
        if(ma && ma->use_nodes && ma->nodetree)
                return nodeGetActiveID(ma->nodetree, ID_TE);
        
index 9c38f84aa2670ec200e6467e407d788b2fe68b43..d71836ab1817fd9eaf749614a11732806b061e98 100644 (file)
@@ -15,7 +15,6 @@
  *
  */
 
-
 #ifdef WITH_FFMPEG
 #include <string.h>
 #include <stdio.h>
@@ -78,11 +77,10 @@ extern void do_init_ffmpeg();
 
 static int ffmpeg_type = 0;
 static int ffmpeg_codec = CODEC_ID_MPEG4;
-static int ffmpeg_audio_codec = CODEC_ID_MP2;
+static int ffmpeg_audio_codec = CODEC_ID_NONE;
 static int ffmpeg_video_bitrate = 1150;
 static int ffmpeg_audio_bitrate = 128;
 static int ffmpeg_gop_size = 12;
-static int ffmpeg_multiplex_audio = 1;
 static int ffmpeg_autosplit = 0;
 static int ffmpeg_autosplit_count = 0;
 
@@ -99,6 +97,7 @@ static uint8_t* audio_input_buffer = 0;
 static int audio_input_frame_size = 0;
 static uint8_t* audio_output_buffer = 0;
 static int audio_outbuf_size = 0;
+static double audio_time = 0.0f;
 
 static AUD_Device* audio_mixdown_device = 0;
 
@@ -133,27 +132,39 @@ static int write_audio_frame(void)
 
        c = get_codec_from_stream(audio_stream);
 
-       if(audio_mixdown_device)
-               AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_frame_size);
-
        av_init_packet(&pkt);
+       pkt.size = 0;
+
+       AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_frame_size);
+       audio_time += (double) audio_input_frame_size / (double) c->sample_rate;
 
        pkt.size = avcodec_encode_audio(c, audio_output_buffer,
-                                       audio_outbuf_size, 
+                                       audio_outbuf_size,
                                        (short*) audio_input_buffer);
+
+       if(pkt.size <= 0)
+       {
+               // XXX error("Error writing audio packet");
+               return -1;
+       }
+
        pkt.data = audio_output_buffer;
+
+       if(c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
+       {
 #ifdef FFMPEG_CODEC_TIME_BASE
-       pkt.pts = av_rescale_q(c->coded_frame->pts, 
-                              c->time_base, audio_stream->time_base);
+               pkt.pts = av_rescale_q(c->coded_frame->pts,
+                                          c->time_base, audio_stream->time_base);
 #else
-       pkt.pts = c->coded_frame->pts;
+               pkt.pts = c->coded_frame->pts;
 #endif
-       fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
+               fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
+       }
 
        pkt.stream_index = audio_stream->index;
        pkt.flags |= PKT_FLAG_KEY;
        if (av_interleaved_write_frame(outfile, &pkt) != 0) {
-               //XXX error("Error writing audio packet");
+               // XXX error("Error writing audio packet");
                return -1;
        }
        return 0;
@@ -233,6 +244,14 @@ static const char** get_file_extensions(int format)
                static const char * rv[] = { ".ogg", ".ogv", NULL };
                return rv;
        }
+       case FFMPEG_MP3: {
+               static const char * rv[] = { ".mp3", NULL };
+               return rv;
+       }
+       case FFMPEG_WAV: {
+               static const char * rv[] = { ".wav", NULL };
+               return rv;
+       }
        default:
                return NULL;
        }
@@ -563,6 +582,7 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
 
        c->sample_rate = rd->ffcodecdata.audio_mixrate;
        c->bit_rate = ffmpeg_audio_bitrate*1000;
+       c->sample_fmt = SAMPLE_FMT_S16;
        c->channels = 2;
        codec = avcodec_find_encoder(c->codec_id);
        if (!codec) {
@@ -577,40 +597,22 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
                return NULL;
        }
 
-       /* FIXME: Should be user configurable */
-       if (ffmpeg_type == FFMPEG_DV) {
-               /* this is a hack around the poor ffmpeg dv multiplexer. */
-               /* only fixes PAL for now 
-                  (NTSC is a lot more complicated here...)! */
-               audio_outbuf_size = 7680;
-       } else {
-               audio_outbuf_size = 10000;
-       }
+       audio_outbuf_size = FF_MIN_BUFFER_SIZE;
+
        audio_output_buffer = (uint8_t*)MEM_mallocN(
                audio_outbuf_size, "FFMPEG audio encoder input buffer");
 
-       /* ugly hack for PCM codecs */
-
-       if (c->frame_size <= 1) {
-               audio_input_frame_size = audio_outbuf_size / c->channels;
-               switch(c->codec_id) {
-               case CODEC_ID_PCM_S16LE:
-               case CODEC_ID_PCM_S16BE:
-               case CODEC_ID_PCM_U16LE:
-               case CODEC_ID_PCM_U16BE:
-                       audio_input_frame_size >>= 1;
-                       break;
-               default:
-                       break;
-               }
-       } else {
+       if((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
+               audio_input_frame_size = audio_outbuf_size * 8 / c->bits_per_coded_sample / c->channels;
+       else
                audio_input_frame_size = c->frame_size;
-       }
 
        audio_input_buffer = (uint8_t*)MEM_mallocN(
-               audio_input_frame_size * sizeof(short) * c->channels, 
+               audio_input_frame_size * c->channels * sizeof(int16_t),
                "FFMPEG audio encoder output buffer");
 
+       audio_time = 0.0f;
+
        return st;
 }
 /* essential functions -- start, append, end */
@@ -629,8 +631,6 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        ffmpeg_video_bitrate = rd->ffcodecdata.video_bitrate;
        ffmpeg_audio_bitrate = rd->ffcodecdata.audio_bitrate;
        ffmpeg_gop_size = rd->ffcodecdata.gop_size;
-       ffmpeg_multiplex_audio = rd->ffcodecdata.flags
-               & FFMPEG_MULTIPLEX_AUDIO;
        ffmpeg_autosplit = rd->ffcodecdata.flags
                & FFMPEG_AUTOSPLIT_OUTPUT;
        
@@ -641,12 +641,11 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        fprintf(stderr, "Starting output to %s(ffmpeg)...\n"
                "  Using type=%d, codec=%d, audio_codec=%d,\n"
                "  video_bitrate=%d, audio_bitrate=%d,\n"
-               "  gop_size=%d, multiplex=%d, autosplit=%d\n"
+               "  gop_size=%d, autosplit=%d\n"
                "  render width=%d, render height=%d\n", 
                name, ffmpeg_type, ffmpeg_codec, ffmpeg_audio_codec,
                ffmpeg_video_bitrate, ffmpeg_audio_bitrate,
-               ffmpeg_gop_size, ffmpeg_multiplex_audio,
-               ffmpeg_autosplit, rectx, recty);
+               ffmpeg_gop_size, ffmpeg_autosplit, rectx, recty);
        
        exts = get_file_extensions(ffmpeg_type);
        if (!exts) {
@@ -667,7 +666,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        
        of->oformat = fmt;
        of->packet_size= rd->ffcodecdata.mux_packet_size;
-       if (ffmpeg_multiplex_audio) {
+       if (ffmpeg_audio_codec != CODEC_ID_NONE) {
                of->mux_rate = rd->ffcodecdata.mux_rate;
        } else {
                of->mux_rate = 0;
@@ -676,6 +675,8 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        of->preload = (int)(0.5*AV_TIME_BASE);
        of->max_delay = (int)(0.7*AV_TIME_BASE);
 
+       fmt->audio_codec = ffmpeg_audio_codec;
+
        snprintf(of->filename, sizeof(of->filename), "%s", name);
        /* set the codec to the user's selection */
        switch(ffmpeg_type) {
@@ -703,6 +704,11 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
        case FFMPEG_FLV:
                fmt->video_codec = CODEC_ID_FLV1;
                break;
+       case FFMPEG_MP3:
+               fmt->audio_codec = CODEC_ID_MP3;
+       case FFMPEG_WAV:
+               fmt->video_codec = CODEC_ID_NONE;
+               break;
        case FFMPEG_MPEG4:
        default:
                fmt->video_codec = CODEC_ID_MPEG4;
@@ -723,30 +729,29 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
                }
        }
        
-       fmt->audio_codec = ffmpeg_audio_codec;
-
        if (ffmpeg_type == FFMPEG_DV) {
                fmt->audio_codec = CODEC_ID_PCM_S16LE;
-               if (ffmpeg_multiplex_audio && rd->ffcodecdata.audio_mixrate != 48000) {
+               if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000) {
                        BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!");
                        return 0;
                }
        }
        
-       video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty);
-       printf("alloc video stream %p\n", video_stream);
-       if (!video_stream) {
-               BKE_report(reports, RPT_ERROR, "Error initializing video stream.");
-               return 0;
+       if (fmt->video_codec != CODEC_ID_NONE) {
+               video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty);
+               printf("alloc video stream %p\n", video_stream);
+               if (!video_stream) {
+                       BKE_report(reports, RPT_ERROR, "Error initializing video stream.");
+                       return 0;
+               }
        }
-       
-       if (ffmpeg_multiplex_audio) {
+
+       if (ffmpeg_audio_codec != CODEC_ID_NONE) {
                audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of);
                if (!audio_stream) {
                        BKE_report(reports, RPT_ERROR, "Error initializing audio stream.");
                        return 0;
                }
-               //XXX audiostream_play(SFRA, 0, 1);
        }
        if (av_set_parameters(of, NULL) < 0) {
                BKE_report(reports, RPT_ERROR, "Error setting output parameters.");
@@ -818,14 +823,14 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo
 
        success = start_ffmpeg_impl(rd, rectx, recty, reports);
 
-       if(ffmpeg_multiplex_audio && audio_stream)
+       if(audio_stream)
        {
                AVCodecContext* c = get_codec_from_stream(audio_stream);
                AUD_DeviceSpecs specs;
                specs.channels = c->channels;
                specs.format = AUD_FORMAT_S16;
                specs.rate = rd->ffcodecdata.audio_mixrate;
-               audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->efra, rd->ffcodecdata.audio_volume);
+               audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume);
        }
 
        return success;
@@ -833,21 +838,13 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo
 
 void end_ffmpeg(void);
 
-static void write_audio_frames()
+static void write_audio_frames(double to_pts)
 {
        int finished = 0;
 
-       while (ffmpeg_multiplex_audio && !finished) {
-               double a_pts = ((double)audio_stream->pts.val 
-                               * audio_stream->time_base.num 
-                               / audio_stream->time_base.den);
-               double v_pts = ((double)video_stream->pts.val 
-                               * video_stream->time_base.num 
-                               / video_stream->time_base.den);
-               
-               if (a_pts < v_pts) {
-                       write_audio_frame();
-               } else {
+       while (audio_stream && !finished) {
+               if((audio_time >= to_pts) ||
+                  (write_audio_frame())) {
                        finished = 1;
                }
        }
@@ -856,25 +853,31 @@ static void write_audio_frames()
 int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty, ReportList *reports) 
 {
        AVFrame* avframe;
-       int success;
+       int success = 1;
 
        fprintf(stderr, "Writing frame %i, "
                "render width=%d, render height=%d\n", frame,
                rectx, recty);
 
-       write_audio_frames();
+// why is this done before writing the video frame and again at end_ffmpeg?
+//     write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
 
-       avframe= generate_video_frame((unsigned char*) pixels, reports);
-       success= (avframe && write_video_frame(rd, avframe, reports));
-
-       if (ffmpeg_autosplit) {
-               if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) {
-                       end_ffmpeg();
-                       ffmpeg_autosplit_count++;
-                       success &= start_ffmpeg_impl(rd, rectx, recty, reports);
+       if(video_stream)
+       {
+               avframe= generate_video_frame((unsigned char*) pixels, reports);
+               success= (avframe && write_video_frame(rd, avframe, reports));
+
+               if (ffmpeg_autosplit) {
+                       if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) {
+                               end_ffmpeg();
+                               ffmpeg_autosplit_count++;
+                               success &= start_ffmpeg_impl(rd, rectx, recty, reports);
+                       }
                }
        }
 
+       write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
+
        return success;
 }
 
@@ -885,9 +888,9 @@ void end_ffmpeg(void)
        
        fprintf(stderr, "Closing ffmpeg...\n");
 
-       if (audio_stream && video_stream) {
+/*     if (audio_stream) { SEE UPPER
                write_audio_frames();
-       }
+       }*/
 
        if(audio_mixdown_device)
        {
@@ -1259,8 +1262,8 @@ void ffmpeg_verify_image_type(RenderData *rd)
                }
        }
 
-       if(audio && rd->ffcodecdata.audio_codec <= 0) {
-               rd->ffcodecdata.audio_codec = CODEC_ID_MP2;
+       if(audio && rd->ffcodecdata.audio_codec < 0) {
+               rd->ffcodecdata.audio_codec = CODEC_ID_NONE;
                rd->ffcodecdata.audio_bitrate = 128;
        }
 }
index b3ecb0122823f2aa05fff62332b05254839cb2d3..0a7c016df7f92f06e48e4b502b0f05ee7a79bb2d 100644 (file)
@@ -44,6 +44,7 @@ typedef struct bAKey {
 } bAKey;
 
 typedef struct bArgument {
+       bAKey *key;
        BA_ArgCallback func;
        void *data;
 } bArgument;
@@ -55,7 +56,7 @@ struct bArgs {
        int       *passes;
 };
 
-unsigned int case_strhash(void *ptr) {
+static unsigned int case_strhash(void *ptr) {
        char *s= ptr;
        unsigned int i= 0;
        unsigned char c;
@@ -86,6 +87,17 @@ static int keycmp(void *a, void *b)
        }
 }
 
+static bArgument *lookUp(struct bArgs *ba, char *arg, int pass, int case_str)
+{
+       bAKey key;
+
+       key.case_str = case_str;
+       key.pass = pass;
+       key.arg = arg;
+
+       return BLI_ghash_lookup(ba->items, &key);
+}
+
 bArgs *BLI_argsInit(int argc, char **argv)
 {
        bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs");
@@ -122,49 +134,52 @@ char **BLI_argsArgv(struct bArgs *ba)
        return ba->argv;
 }
 
-void BLI_argsAdd(struct bArgs *ba, char *arg, int pass, BA_ArgCallback cb, void *data)
+static void internalAdd(struct bArgs *ba, char *arg, int pass, int case_str, BA_ArgCallback cb, void *data)
 {
-       bArgument *a = MEM_callocN(sizeof(bArgument), "bArgument");
-       bAKey *key = MEM_callocN(sizeof(bAKey), "bAKey");
+       bArgument *a;
+       bAKey *key;
+
+       a = lookUp(ba, arg, pass, case_str);
+
+       if (a) {
+               printf("WARNING: conflicting argument\n");
+               printf("\ttrying to add '%s' on pass %i, %scase sensitive\n", arg, pass, case_str == 1? "not ": "");
+               printf("\tconflict with '%s' on pass %i, %scase sensitive\n\n", a->key->arg, (int)a->key->pass, a->key->case_str == 1? "not ": "");
+       }
+
+       a = MEM_callocN(sizeof(bArgument), "bArgument");
+       key = MEM_callocN(sizeof(bAKey), "bAKey");
 
        key->arg = arg;
        key->pass = pass;
-       key->case_str = 0;
+       key->case_str = case_str;
 
+       a->key = key;
        a->func = cb;
        a->data = data;
 
        BLI_ghash_insert(ba->items, key, a);
 }
 
-void BLI_argsAddCase(struct bArgs *ba, char *arg, int pass, BA_ArgCallback cb, void *data)
+void BLI_argsAdd(struct bArgs *ba, char *arg, int pass, BA_ArgCallback cb, void *data)
 {
-       bArgument *a = MEM_callocN(sizeof(bArgument), "bArgument");
-       bAKey *key = MEM_callocN(sizeof(bAKey), "bAKey");
-
-       key->arg = arg;
-       key->pass = pass;
-       key->case_str = 1;
-
-       a->func = cb;
-       a->data = data;
+       internalAdd(ba, arg, pass, 0, cb, data);
+}
 
-       BLI_ghash_insert(ba->items, key, a);
+void BLI_argsAddCase(struct bArgs *ba, char *arg, int pass, BA_ArgCallback cb, void *data)
+{
+       internalAdd(ba, arg, pass, 1, cb, data);
 }
 
 
 void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
 {
-       bAKey key;
        int i = 0;
 
-       key.case_str = -1; /* signal what side of the comparison it is */
-       key.pass = pass;
-
        for( i = 1; i < ba->argc; i++) { /* skip argv[0] */
-               key.arg = ba->argv[i];
                if (ba->passes[i] == 0) {
-                       bArgument *a = BLI_ghash_lookup(ba->items, &key);
+                        /* -1 signal what side of the comparison it is */
+                       bArgument *a = lookUp(ba, ba->argv[i], pass, -1);
                        BA_ArgCallback func = NULL;
                        void *data = NULL;
 
@@ -174,10 +189,6 @@ void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *
                        } else {
                                func = default_cb;
                                data = default_data;
-
-                               if (func) {
-                                       printf("calling default on %s\n", ba->argv[i]);
-                               }
                        }
 
                        if (func) {
index a91c24471bb70d1065885f241664ce82731161e5..39f6e7a8abab743350ddda045411dd193f9b3f1a 100644 (file)
@@ -196,14 +196,14 @@ int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, int *max_
 // http://ralphunden.net/content/tutorials/a-guide-to-introsort/
 // and he derived it from the SUN STL 
 //////////////////////////////////////////////////////////////////////////////////////////////////////
-static int size_threshold = 16;
+//static int size_threshold = 16;
 /*
 * Common methods for all algorithms
 */
-static int floor_lg(int a)
+/*static int floor_lg(int a)
 {
        return (int)(floor(log(a)/log(2)));
-}
+}*/
 
 /*
 * Insertion sort algorithm
@@ -243,6 +243,7 @@ static int bvh_partition(BVHNode **a, int lo, int hi, BVHNode * x, int axis)
 /*
 * Heapsort algorithm
 */
+#if 0
 static void bvh_downheap(BVHNode **a, int i, int n, int lo, int axis)
 {
        BVHNode * d = a[lo+i-1];
@@ -274,6 +275,7 @@ static void bvh_heapsort(BVHNode **a, int lo, int hi, int axis)
                bvh_downheap(a, 1,i-1,lo, axis);
        }
 }
+#endif
 
 static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) // returns Sortable
 {
index c3e7d1713dbf4ddccd695050047dd9225a04d73e..670c70b86f2e5a58d1f7a9eb868528fc8ae70368 100644 (file)
@@ -486,8 +486,8 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo
        BLI_bpathIterator_getPathExpanded(bpi, path_expanded);
 
        if(reports) {
-               if (name)       BKE_reportf(reports, RPT_INFO, "%s \"%s\", \"%s\": %s", prefix, name, path_expanded, message);
-               else            BKE_reportf(reports, RPT_INFO, "%s \"%s\": %s", prefix, path_expanded, message);
+               if (name)       BKE_reportf(reports, RPT_WARNING, "%s \"%s\", \"%s\": %s", prefix, name, path_expanded, message);
+               else            BKE_reportf(reports, RPT_WARNING, "%s \"%s\": %s", prefix, path_expanded, message);
        }
 
 }
index 66e9a65dba5e47fcd0b2acfe12f03627abb63eab..5338995073432c4cd955612f6a84af83ff031a2b 100644 (file)
@@ -43,8 +43,8 @@
 
 /* local */
 static float noise3_perlin(float vec[3]);
-static float turbulence_perlin(float *point, float lofreq, float hifreq);
-static float turbulencep(float noisesize, float x, float y, float z, int nr);
+//static float turbulence_perlin(float *point, float lofreq, float hifreq);
+//static float turbulencep(float noisesize, float x, float y, float z, int nr);
 
 #define HASHVEC(x,y,z) hashvectf+3*hash[ (hash[ (hash[(z) & 255]+(y)) & 255]+(x)) & 255]
 
@@ -976,6 +976,7 @@ static float noise3_perlin(float vec[3])
        return 1.5 * lerp(sz, c, d); /* interpolate in z */
 }
 
+#if 0
 static float turbulence_perlin(float *point, float lofreq, float hifreq)
 {
        float freq, t, p[3];
@@ -993,6 +994,7 @@ static float turbulence_perlin(float *point, float lofreq, float hifreq)
        }
        return t - 0.3; /* readjust to make mean value = 0.0 */
 }
+#endif
 
 /* for use with BLI_gNoise/gTurbulence, returns signed noise */
 static float orgPerlinNoise(float x, float y, float z)
@@ -1029,7 +1031,7 @@ float BLI_hnoisep(float noisesize, float x, float y, float z)
        return noise3_perlin(vec);
 }
 
-static float turbulencep(float noisesize, float x, float y, float z, int nr)
+/*static float turbulencep(float noisesize, float x, float y, float z, int nr)
 {
        float vec[3];
 
@@ -1038,7 +1040,7 @@ static float turbulencep(float noisesize, float x, float y, float z, int nr)
        vec[2]= z/noisesize;
        nr++;
        return turbulence_perlin(vec, 1.0, (float)(1<<nr));
-}
+}*/
 
 /******************/
 /* VORONOI/WORLEY */
index c3ce73df6c641c484541380cbbb235a4b295fda8..6baa7084b47502647ae34dcfde7e05cd4cdadfe3 100644 (file)
@@ -990,11 +990,11 @@ void BLI_setenv(const char *env, const char*val)
 {
        /* SGI or free windows */
 #if (defined(__sgi) || ((defined(WIN32) || defined(WIN64)) && defined(FREE_WINDOWS)))
-       char *envstr= malloc(sizeof(char) * (strlen(env) + strlen(val) + 2)); /* one for = another for \0 */
+       char *envstr= MEM_mallocN(sizeof(char) * (strlen(env) + strlen(val) + 2), "envstr"); /* one for = another for \0 */
 
        sprintf(envstr, "%s=%s", env, val);
        putenv(envstr);
-       free(envstr);
+       MEM_freeN(envstr);
 
        /* non-free windows */
 #elif (defined(WIN32) || defined(WIN64)) /* not free windows */
index ee7734fb14b01ea2190d7daaf7c745b50304a0f6..f7f032a72bb26f855207fedc655550a16e476894 100644 (file)
@@ -487,7 +487,7 @@ LinkNode *BLI_read_file_as_lines(char *name)
        size= ftell(fp);
        fseek(fp, 0, SEEK_SET);
 
-       buf= malloc(size);
+       buf= MEM_mallocN(size, "file_as_lines");
        if (buf) {
                int i, last= 0;
                
@@ -506,7 +506,7 @@ LinkNode *BLI_read_file_as_lines(char *name)
                        }
                }
                
-               free(buf);
+               MEM_freeN(buf);
        }
        
        fclose(fp);
index 65fdd99c62e5547a77fea55eba4d4fc3da46ab88..38a58f3a3988d3f9255948600c82e10dc9bf01bc 100644 (file)
@@ -4138,14 +4138,14 @@ static void lib_link_scene(FileData *fd, Main *main)
                                if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo);
                                if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene);
                                if(seq->sound) {
-                                       seq->sound_handle= NULL;
+                                       seq->scene_sound = NULL;
                                        if(seq->type == SEQ_HD_SOUND)
                                                seq->type = SEQ_SOUND;
                                        else
                                                seq->sound= newlibadr(fd, sce->id.lib, seq->sound);
                                        if (seq->sound) {
                                                seq->sound->id.us++;
-                                               seq->sound_handle= sound_new_handle(sce, seq->sound, seq->startdisp, seq->enddisp, seq->startofs);
+                                               seq->scene_sound = sound_add_scene_sound(sce, seq, seq->startdisp, seq->enddisp, seq->startofs);
                                        }
                                }
                                seq->anim= 0;
@@ -4161,7 +4161,7 @@ static void lib_link_scene(FileData *fd, Main *main)
 #endif
 
                        if(sce->ed)
-                               seq_update_muting(sce->ed);
+                               seq_update_muting(sce, sce->ed);
                        
                        if(sce->nodetree) {
                                lib_link_ntree(fd, &sce->id, sce->nodetree);
@@ -4218,7 +4218,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
        sce->obedit= NULL;
        sce->stats= 0;
 
-       memset(&sce->sound_handles, 0, sizeof(sce->sound_handles));
+       sound_create_scene(sce);
 
        /* set users to one by default, not in lib-link, this will increase it for compo nodes */
        sce->id.us= 1;
@@ -5205,6 +5205,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
 static void direct_link_sound(FileData *fd, bSound *sound)
 {
        sound->handle = NULL;
+       sound->playback_handle = NULL;
 
        sound->packedfile = direct_link_packedfile(fd, sound->packedfile);
        sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile);
@@ -5926,6 +5927,29 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb)
        ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y);
 }
 
+static void sequencer_init_preview_region(ARegion* ar)
+{
+       // XXX a bit ugly still, copied from space_sequencer
+       /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */
+       ar->regiontype= RGN_TYPE_PREVIEW;
+       ar->alignment= RGN_ALIGN_TOP;
+       ar->flag |= RGN_FLAG_HIDDEN;
+       ar->v2d.keepzoom= V2D_KEEPASPECT | V2D_KEEPZOOM;
+       ar->v2d.minzoom= 0.00001f;
+       ar->v2d.maxzoom= 100000.0f;
+       ar->v2d.tot.xmin= -960.0f; /* 1920 width centered */
+       ar->v2d.tot.ymin= -540.0f; /* 1080 height centered */
+       ar->v2d.tot.xmax= 960.0f;
+       ar->v2d.tot.ymax= 540.0f;
+       ar->v2d.min[0]= 0.0f;
+       ar->v2d.min[1]= 0.0f;
+       ar->v2d.max[0]= 12000.0f;
+       ar->v2d.max[1]= 12000.0f;
+       ar->v2d.cur= ar->v2d.tot;
+       ar->v2d.align= V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
+       ar->v2d.keeptot= V2D_KEEPTOT_FREE;
+}
+
 /* 2.50 patch */
 static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
 {
@@ -6006,9 +6030,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
                                }
                                ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
                                BLI_insertlinkbefore(lb, ar_main, ar);
-                               ar->regiontype= RGN_TYPE_PREVIEW;
-                               ar->alignment= RGN_ALIGN_TOP;
-                               ar->flag |= RGN_FLAG_HIDDEN;
+                               sequencer_init_preview_region(ar);
                                break;
                        case SPACE_VIEW3D:
                                /* toolbar */
@@ -10305,7 +10327,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                                break;
                                                }
 
-                                               if (ar) {
+                                               if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) {
                                                        SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ);
                                                        BKE_area_region_free(st, ar);
                                                        BLI_freelinkN(regionbase, ar);
@@ -10350,9 +10372,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                        }
                                                        ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer");
                                                        BLI_insertlinkbefore(regionbase, ar_main, ar);
-                                                       ar->regiontype= RGN_TYPE_PREVIEW;
-                                                       ar->alignment= RGN_ALIGN_TOP;
-                                                       ar->flag |= RGN_FLAG_HIDDEN;
+                                                       sequencer_init_preview_region(ar);
                                                }
                                        }
                                }
@@ -10459,7 +10479,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                ma->vol.ms_intensity = 1.f;     
                        }
                }
-               
        }
        
        if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) {
@@ -10552,6 +10571,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        /* put 2.50 compatibility code here until next subversion bump */
        {
                Scene *sce;
+               Sequence *seq;
 
                /* initialize to sane default so toggling on border shows something */
                for(sce = main->scene.first; sce; sce = sce->id.next) {
@@ -10562,7 +10582,48 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                sce->r.border.xmax= 1.0f;
                                sce->r.border.ymax= 1.0f;
                        }
+
+                       if((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0)
+                               sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE
+
+                       SEQ_BEGIN(sce->ed, seq) {
+                               seq->volume = 1.0f;
+                       }
+                       SEQ_END
                }
+
+               /* sequencer changes */
+               {
+                       bScreen *screen;
+                       ScrArea *sa;
+                       SpaceLink *sl;
+
+                       for(screen= main->screen.first; screen; screen= screen->id.next) {
+                               for(sa= screen->areabase.first; sa; sa= sa->next) {
+                                       for(sl= sa->spacedata.first; sl; sl= sl->next) {
+                                               if(sl->spacetype==SPACE_SEQ) {
+                                                       ARegion *ar_preview;
+                                                       ListBase *regionbase;
+
+                                                       if (sl == sa->spacedata.first) {
+                                                               regionbase = &sa->regionbase;
+                                                       } else {
+                                                               regionbase = &sl->regionbase;
+                                                       }
+
+                                                       ar_preview = (ARegion*)regionbase->first;
+                                                       for (; ar_preview; ar_preview = ar_preview->next) {
+                                                               if (ar_preview->regiontype == RGN_TYPE_PREVIEW)
+                                                                       break;
+                                                       }
+                                                       if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) {
+                                                               sequencer_init_preview_region(ar_preview);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } /* sequencer changes */
        }
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
@@ -10878,7 +10939,8 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
                                /* this is actually only needed on UI call? when ID was already read before, and another append
                                   happens which invokes same ID... in that case the lookup table needs this entry */
                                oldnewmap_insert(fd->libmap, bhead->old, id, 1);
-                               if(G.f & G_DEBUG) printf("expand: already read %s\n", id->name);
+                // commented because this can print way too much
+                               // if(G.f & G_DEBUG) printf("expand: already read %s\n", id->name);
                        }
                }
        }
index 8463fe5840edd4da835813192ae03b2f82853a0b..84be7049f7b4caffc3cf886a3fc55a3e89fe867c 100644 (file)
@@ -2074,7 +2074,7 @@ static void dummy_olddraw_gpencil ()
                case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */
                {
                        bGPdata *gpd = (bGPdata *)ale->data;
-                       ScrArea *sa = (ScrArea *)ale->owner;
+                       ScrArea *sa = (ScrArea *)ale->owner; // XXX depreceated...
                        
                        indent = 0;
                        group= 3;
index f756c5b3158640025e37b1ed4f0a92271c975af8..fba6d56fcc6ae94bfb660cbe98887c37ddb4fc6b 100644 (file)
@@ -71,6 +71,7 @@
 #include "BKE_material.h"
 #include "BKE_object.h"
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_utildefines.h"
 
 #include "UI_interface.h"
@@ -436,18 +437,29 @@ void ANIM_flush_setting_anim_channels (bAnimContext *ac, ListBase *anim_data, bA
                        
                        /* if the level is 'less than' (i.e. more important) the level we're matching
                         * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, 
-                        * when toggling visibility of F-Curves, gets flushed), flush the new status...
+                        * when toggling visibility of F-Curves, gets flushed, which should happen if we don't let prevLevel
+                        * get updated below once the first 1st group is found)...
                         */
-                       if (level < prevLevel)
+                       if (level < prevLevel) {
+                               /* flush the new status... */
                                ANIM_channel_setting_set(ac, ale, setting, on);
-                       /* however, if the level is 'greater than' (i.e. less important than the previous channel,
-                        * stop searching, since we've already reached the bottom of another hierarchy
-                        */
-                       else if (level > matchLevel)
-                               break;
-                       
-                       /* store this level as the 'old' level now */
-                       prevLevel= level;
+                               
+                               /* store this level as the 'old' level now */
+                               prevLevel= level;
+                       }       
+                       /* if the level is 'greater than' (i.e. less important) than the previous level... */
+                       else if (level > prevLevel) {
+                               /* if previous level was a base-level (i.e. 0 offset / root of one hierarchy),
+                                * stop here
+                                */
+                               if (prevLevel == 0)
+                                       break;
+                               /* otherwise, this level weaves into another sibling hierarchy to the previous one just
+                                * finished, so skip until we get to the parent of this level 
+                                */
+                               else
+                                       continue;
+                       }
                }
        }
        
@@ -1385,7 +1397,7 @@ void ANIM_OT_channels_expand (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* props */
-       RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)");
+       ot->prop= RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)");
 }
 
 /* ********************** Collapse Channels Operator *********************** */
@@ -1427,7 +1439,7 @@ void ANIM_OT_channels_collapse (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* props */
-       RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)");
+       ot->prop= RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)");
 }
 
 /* ********************** Select All Operator *********************** */
@@ -1467,7 +1479,7 @@ void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* props */
-       RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
+       ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
 }
 
 /* ******************** Borderselect Operator *********************** */
@@ -1594,7 +1606,8 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh
        ale= BLI_findlink(&anim_data, channel_index);
        if (ale == NULL) {
                /* channel not found */
-               printf("Error: animation channel (index = %d) not found in mouse_anim_channels() \n", channel_index);
+               if (G.f & G_DEBUG)
+                       printf("Error: animation channel (index = %d) not found in mouse_anim_channels() \n", channel_index);
                
                BLI_freelistN(&anim_data);
                return 0;
@@ -1793,7 +1806,7 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh
                case ANIMTYPE_GPLAYER:
                {
 #if 0 // XXX future of this is unclear
-                       bGPdata *gpd= (bGPdata *)ale->owner;
+                       bGPdata *gpd= (bGPdata *)ale->owner; // xxx depreceated
                        bGPDlayer *gpl= (bGPDlayer *)ale->data;
                        
                        if (x >= (ACHANNEL_NAMEWIDTH-16)) {
@@ -1818,7 +1831,8 @@ static int mouse_anim_channels (bAnimContext *ac, float x, int channel_index, sh
                }
                        break;
                default:
-                       printf("Error: Invalid channel type in mouse_anim_channels() \n");
+                       if (G.f & G_DEBUG)
+                               printf("Error: Invalid channel type in mouse_anim_channels() \n");
        }
        
        /* free channels */
index d64787ba35bb67c21e1c1629c803737f1152f9f9..38dcdd0c4054bc9b01f075d58be01c43f80efefa 100644 (file)
@@ -629,7 +629,7 @@ static void MARKER_OT_move(wmOperatorType *ot)
        ot->poll= ED_operator_areaactive;
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
        
        /* rna storage */
        RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX);
index 82a2b615681006e5ea41efb19858a0f1ed382d11..8ac2bd5753a5ddb068cb8174ed745d0f68e2a3c1 100644 (file)
@@ -83,7 +83,7 @@ static void change_frame_apply(bContext *C, wmOperator *op)
        CFRA= RNA_int_get(op->ptr, "frame");
        
        /* do updates */
-       sound_scrub(C);
+       sound_seek_scene(C);
        WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
 }
 
index c1b2e474d522d42ce04833c34f7ec4840bba24f5..718286b4ba411e94996196a8d79a84a6132a2988 100644 (file)
  */
 short ANIM_fcurve_keys_bezier_loop(BeztEditData *bed, FCurve *fcu, BeztEditFunc bezt_ok, BeztEditFunc bezt_cb, FcuEditFunc fcu_cb) 
 {
-    BezTriple *bezt;
+       BezTriple *bezt;
+       int i;
        
        /* sanity check */
        if (ELEM(NULL, fcu, fcu->bezt))
                return 0;
        
        /* set the F-Curve into the editdata so that it can be accessed */
-       bed->fcu= fcu;
-       bed->curIndex= 0;
+       if(bed) {
+               bed->fcu= fcu;
+               bed->curIndex= 0;
+       }
        
        /* if function to apply to bezier curves is set, then loop through executing it on beztriples */
-    if (bezt_cb) {
+       if (bezt_cb) {
                /* if there's a validation func, include that check in the loop 
                 * (this is should be more efficient than checking for it in every loop)
                 */
                if (bezt_ok) {
-                       for (bed->curIndex=0, bezt=fcu->bezt; bed->curIndex < fcu->totvert; bed->curIndex++, bezt++) {
+                       for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
                                /* Only operate on this BezTriple if it fullfills the criteria of the validation func */
+                               if(bed) bed->curIndex= i;
                                if (bezt_ok(bed, bezt)) {
                                        /* Exit with return-code '1' if function returns positive
                                         * This is useful if finding if some BezTriple satisfies a condition.
                                         */
-                               if (bezt_cb(bed, bezt)) return 1;
+                                       if (bezt_cb(bed, bezt)) return 1;
                                }
                        }
                }
                else {
-                       for (bed->curIndex=0, bezt=fcu->bezt; bed->curIndex < fcu->totvert; bed->curIndex++, bezt++) {
+                       for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) {
                                /* Exit with return-code '1' if function returns positive
                                 * This is useful if finding if some BezTriple satisfies a condition.
                                 */
-                       if (bezt_cb(bed, bezt)) return 1;
+                               if(bed) bed->curIndex= i;
+                               if (bezt_cb(bed, bezt)) return 1;
                        }
                }
-    }
+        }
        
        /* unset the F-Curve from the editdata now that it's done */
-       bed->fcu= NULL;
-       bed->curIndex= 0;
-
-    /* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
-    if (fcu_cb)
-        fcu_cb(fcu);
+       if(bed) {
+               bed->fcu= NULL;
+               bed->curIndex= 0;
+       }
+
+       /* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
+       if (fcu_cb)
+               fcu_cb(fcu);
        
        /* done */      
-    return 0;
+       return 0;
 }
 
 /* -------------------------------- Further Abstracted (Not Exposed Directly) ----------------------------- */
index 496e9a0d4d73d6ade4d73a4a3f73b711c33d12b0..9f82275390bffea91979d66f4c1e13045b201a1a 100644 (file)
@@ -4982,7 +4982,7 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
                        }
                        else {
                                /* perform clamping using euler form (3-components) */
-                               float eul[3], oldeul[3], quat1[4];
+                               float eul[3], oldeul[3], quat1[4] = {0};
                                
                                if (pchan->rotmode == ROT_MODE_QUAT) {
                                        QUATCOPY(quat1, pchan->quat);
@@ -5082,7 +5082,8 @@ static int pose_select_inverse_exec(bContext *C, wmOperator *op)
 {
        
        /*      Set the flags */
-       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) {
+       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
+       {
                if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
                        pchan->bone->flag ^= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
                }
@@ -5114,11 +5115,20 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
        int action = RNA_enum_get(op->ptr, "action");
 
        if (action == SEL_TOGGLE) {
-               action = SEL_SELECT;
-               /* Determine if there are any selected bones and therefore whether we are selecting or deselecting */
-               // NOTE: we have to check for > 1 not > 0, since there is almost always an active bone that can't be cleared...
-               if (CTX_DATA_COUNT(C, selected_pose_bones) > 1)
+               bPoseChannel *pchan= CTX_data_active_pose_bone(C);
+               int num_sel = CTX_DATA_COUNT(C, selected_pose_bones);
+               
+               /* cases for deselect:
+                *      1) there's only one bone selected, and that is the active one
+                *      2) there's more than one bone selected
+                */
+               if ( ((num_sel == 1) && (pchan) && (pchan->bone->flag & BONE_SELECTED)) ||
+                        (num_sel > 1) )
+               {
                        action = SEL_DESELECT;
+               }
+               else 
+                       action = SEL_SELECT;
        }
        
        /*      Set the flags */
index eee56070e9125411ad2271a32ca5be65d2e16265..75e7e9a3db803a0d473455e14a36726cd8d43084 100644 (file)
@@ -1074,7 +1074,7 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok
                DepthPeel *p1, *p2;
                float *last_p = NULL;
                float dist = FLT_MAX;
-               float p[3];
+               float p[3] = {0};
                float size = 0;
                float mvalf[2];
 
index e4fb378aff24514a16d1611d1ef07b9ba79d4170..708ebe5c3ed7bcf7bf9da7447b1349636aa94e86 100644 (file)
@@ -333,88 +333,43 @@ void POSE_OT_paths_clear (wmOperatorType *ot)
 
 /* ******************* Select Constraint Target Operator ************* */
 
-// XXX this function is to be removed when the other stuff is recoded
-void pose_select_constraint_target(Scene *scene)
-{
-       Object *obedit= scene->obedit; // XXX context
-       Object *ob= OBACT;
-       bArmature *arm= ob->data;
-       bPoseChannel *pchan;
-       bConstraint *con;
-       
-       /* paranoia checks */
-       if (!ob && !ob->pose) return;
-       if (ob==obedit || (ob->mode & OB_MODE_POSE)==0) return;
-       
-       for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-               if (arm->layer & pchan->bone->layer) {
-                       if (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone) {
-                               for (con= pchan->constraints.first; con; con= con->next) {
-                                       bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
-                                       ListBase targets = {NULL, NULL};
-                                       bConstraintTarget *ct;
-                                       
-                                       if (cti && cti->get_constraint_targets) {
-                                               cti->get_constraint_targets(con, &targets);
-                                               
-                                               for (ct= targets.first; ct; ct= ct->next) {
-                                                       if ((ct->tar == ob) && (ct->subtarget[0])) {
-                                                               bPoseChannel *pchanc= get_pose_channel(ob->pose, ct->subtarget);
-                                                               if((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE))
-                                                                       pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
-                                                       }
-                                               }
-                                               
-                                               if (cti->flush_constraint_targets)
-                                                       cti->flush_constraint_targets(con, &targets, 1);
-                                       }
-                               }
-                       }
-               }
-       }
-       
-       BIF_undo_push("Select constraint target");
-
-}
-
 static int pose_select_constraint_target_exec(bContext *C, wmOperator *op)
 {
        Object *ob= CTX_data_active_object(C);
        bArmature *arm= ob->data;
-       bPoseChannel *pchan;
        bConstraint *con;
        int found= 0;
        
-       for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-               if (arm->layer & pchan->bone->layer) {
-                       if (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone) {
-                               for (con= pchan->constraints.first; con; con= con->next) {
-                                       bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
-                                       ListBase targets = {NULL, NULL};
-                                       bConstraintTarget *ct;
+       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
+       {
+               if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
+                       for (con= pchan->constraints.first; con; con= con->next) {
+                               bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+                               ListBase targets = {NULL, NULL};
+                               bConstraintTarget *ct;
+                               
+                               if (cti && cti->get_constraint_targets) {
+                                       cti->get_constraint_targets(con, &targets);
                                        
-                                       if (cti && cti->get_constraint_targets) {
-                                               cti->get_constraint_targets(con, &targets);
-                                               
-                                               for (ct= targets.first; ct; ct= ct->next) {
-                                                       if ((ct->tar == ob) && (ct->subtarget[0])) {
-                                                               bPoseChannel *pchanc= get_pose_channel(ob->pose, ct->subtarget);
-                                                               if((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) {
-                                                                       pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
-                                                                       found= 1;
-                                                               }
+                                       for (ct= targets.first; ct; ct= ct->next) {
+                                               if ((ct->tar == ob) && (ct->subtarget[0])) {
+                                                       bPoseChannel *pchanc= get_pose_channel(ob->pose, ct->subtarget);
+                                                       if((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) {
+                                                               pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
+                                                               found= 1;
                                                        }
                                                }
-                                               
-                                               if (cti->flush_constraint_targets)
-                                                       cti->flush_constraint_targets(con, &targets, 1);
                                        }
+                                       
+                                       if (cti->flush_constraint_targets)
+                                               cti->flush_constraint_targets(con, &targets, 1);
                                }
                        }
                }
        }
+       CTX_DATA_END;
 
-       if(!found)
+       if (!found)
                return OPERATOR_CANCELLED;
 
        WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
@@ -442,24 +397,22 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
 {
        Object *ob= CTX_data_active_object(C);
        bArmature *arm= ob->data;
-       bPoseChannel *pchan;
        Bone *curbone, *pabone, *chbone;
        int direction = RNA_enum_get(op->ptr, "direction");
        int add_to_sel = RNA_boolean_get(op->ptr, "extend");
        int found= 0;
        
-       for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
+       {
                curbone= pchan->bone;
                
-               if ((arm->layer & curbone->layer) && (curbone->flag & BONE_UNSELECTABLE)==0) {
+               if ((curbone->flag & BONE_UNSELECTABLE)==0) {
                        if (curbone == arm->act_bone) {
                                if (direction == BONE_SELECT_PARENT) {
-                               
                                        if (pchan->parent == NULL) continue;
                                        else pabone= pchan->parent->bone;
                                        
                                        if ((arm->layer & pabone->layer) && !(pabone->flag & BONE_HIDDEN_P)) {
-                                               
                                                if (!add_to_sel) curbone->flag &= ~BONE_SELECTED;
                                                pabone->flag |= BONE_SELECTED;
                                                arm->act_bone= pabone;
@@ -467,13 +420,12 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
                                                found= 1;
                                                break;
                                        }
-                               } else { // BONE_SELECT_CHILD
-                               
+                               } 
+                               else { /* direction == BONE_SELECT_CHILD */
                                        if (pchan->child == NULL) continue;
                                        else chbone = pchan->child->bone;
                                        
                                        if ((arm->layer & chbone->layer) && !(chbone->flag & BONE_HIDDEN_P)) {
-                                       
                                                if (!add_to_sel) curbone->flag &= ~BONE_SELECTED;
                                                chbone->flag |= BONE_SELECTED;
                                                arm->act_bone= chbone;
@@ -485,6 +437,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
                        }
                }
        }
+       CTX_DATA_END;
 
        if (found == 0)
                return OPERATOR_CANCELLED;
@@ -521,11 +474,10 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot)
 
 /* ******************* select grouped operator ************* */
 
-static short pose_select_same_group (Object *ob, short extend)
+static short pose_select_same_group (bContext *C, Object *ob, short extend)
 {
-       bPose *pose= (ob)? ob->pose : NULL;
        bArmature *arm= (ob)? ob->data : NULL;
-       bPoseChannel *pchan;
+       bPose *pose= (ob)? ob->pose : NULL;
        char *group_flags;
        int numGroups = 0;
        short changed=0, tagged=0;
@@ -545,25 +497,26 @@ static short pose_select_same_group (Object *ob, short extend)
         */
        group_flags= MEM_callocN(numGroups+1, "pose_select_same_group");
        
-       for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
-               if (arm->layer & pchan->bone->layer) {
-                       /* keep track of group as group to use later? */
-                       if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
-                               group_flags[pchan->agrp_index] = 1;
-                               tagged= 1;
-                       }
-                       
-                       /* deselect all bones before selecting new ones? */
-                       if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
-                               pchan->bone->flag &= ~BONE_SELECTED;
+       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
+       {
+               /* keep track of group as group to use later? */
+               if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
+                       group_flags[pchan->agrp_index] = 1;
+                       tagged= 1;
                }
+               
+               /* deselect all bones before selecting new ones? */
+               if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
+                       pchan->bone->flag &= ~BONE_SELECTED;
        }
+       CTX_DATA_END;
        
        /* small optimisation: only loop through bones a second time if there are any groups tagged */
        if (tagged) {
                /* only if group matches (and is not selected or current bone) */
-               for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
-                       if ((arm->layer & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+               CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
+               {
+                       if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
                                /* check if the group used by this bone is counted */
                                if (group_flags[pchan->agrp_index]) {
                                        pchan->bone->flag |= BONE_SELECTED;
@@ -571,6 +524,7 @@ static short pose_select_same_group (Object *ob, short extend)
                                }
                        }
                }
+               CTX_DATA_END;
        }
        
        /* free temp info */
@@ -579,11 +533,10 @@ static short pose_select_same_group (Object *ob, short extend)
        return changed;
 }
 
-static short pose_select_same_layer (Object *ob, short extend)
+static short pose_select_same_layer (bContext *C, Object *ob, short extend)
 {
        bPose *pose= (ob)? ob->pose : NULL;
        bArmature *arm= (ob)? ob->data : NULL;
-       bPoseChannel *pchan;
        short changed= 0;
        int layers= 0;
        
@@ -591,30 +544,30 @@ static short pose_select_same_layer (Object *ob, short extend)
                return 0;
        
        /* figure out what bones are selected */
-       for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-               if (arm->layer & pchan->bone->layer) {
-                       /* keep track of layers to use later? */
-                       if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone))
-                               layers |= pchan->bone->layer;
-                               
-                       /* deselect all bones before selecting new ones? */
-                       if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
-                               pchan->bone->flag &= ~BONE_SELECTED;
-               }
+       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
+       {
+               /* keep track of layers to use later? */
+               if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone))
+                       layers |= pchan->bone->layer;
+                       
+               /* deselect all bones before selecting new ones? */
+               if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
+                       pchan->bone->flag &= ~BONE_SELECTED;
        }
+       CTX_DATA_END;
        if (layers == 0) 
                return 0;
                
        /* select bones that are on same layers as layers flag */
-       for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-               if (arm->layer & pchan->bone->layer) {
-                       /* if bone is on a suitable layer, and the bone can have its selection changed, select it */
-                       if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
-                               pchan->bone->flag |= BONE_SELECTED;
-                               changed= 1;
-                       }
+       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
+       {
+               /* if bone is on a suitable layer, and the bone can have its selection changed, select it */
+               if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+                       pchan->bone->flag |= BONE_SELECTED;
+                       changed= 1;
                }
        }
+       CTX_DATA_END;
        
        return changed;
 }
@@ -635,10 +588,10 @@ static int pose_select_grouped_exec (bContext *C, wmOperator *op)
         */
        switch (RNA_enum_get(op->ptr, "type")) {
                case 1: /* group */
-                       changed= pose_select_same_group(ob, extend);
+                       changed= pose_select_same_group(C, ob, extend);
                        break;
                default: /* layer */
-                       changed= pose_select_same_layer(ob, extend);
+                       changed= pose_select_same_layer(C, ob, extend);
                        break;
        }
        
index cd9ebe6996f9463b17527688567f041c1202a1db..c54b062c8153959045174cdeea12e7fce4f49923 100644 (file)
@@ -1499,7 +1499,7 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen)
                }
 
                if(!buf) {
-                       BLI_strncpy(str, "", maxlen);
+                       str[0] = '\0';
                }
                else if(buf && buf != str) {
                        /* string was too long, we have to truncate */
@@ -1511,12 +1511,12 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen)
                /* ID pointer */
                if(but->idpoin_idpp) { /* Can be NULL for ID properties by python */
                        ID *id= *(but->idpoin_idpp);
-                       if(id)
+                       if(id) {
                                BLI_strncpy(str, id->name+2, maxlen);
+                               return;
+                       }
                }
-               else {
-                       str[0] = '\0';
-               }
+               str[0] = '\0';
                return;
        }
        else if(but->type == TEX) {
@@ -2067,7 +2067,7 @@ void ui_check_but(uiBut *but)
                
        case HOTKEYEVT:
                if (but->flag & UI_SELECT) {
-                       strncpy(but->drawstr, "", UI_MAX_DRAW_STR);
+                       but->drawstr[0]= '\0';
                        
                        if(but->modifier_key) {
                                char *str= but->drawstr;
index d3912e183c13063aec0ee6afc6e0fa309193fdd6..76a98479d55ed97d111e9f13fe78e2e49067042f 100644 (file)
@@ -2084,7 +2084,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
                /* pass on release as press for other keymaps XXX hack alert! */
                if(event->type==LEFTMOUSE && event->val==KM_RELEASE) {
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
-                       event->val= KM_PRESS;
+                       event->val= KM_CLICK;
                        return WM_UI_HANDLER_CONTINUE;
                }
                
index 6c4f5564fd74dbfa0a63d4f97a47b8d742174cff..7608014b150c09909baf5d1d1deb9ddbca509639 100644 (file)
@@ -573,8 +573,8 @@ static void init_iconfile_list(struct ListBase *list)
        if(!BLI_getwdN(olddir)) 
                restoredir = 0;
        totfile = BLI_getdir(icondirstr, &dir);
-       if (restoredir)
-               chdir(olddir);
+       if (restoredir && !chdir(olddir))
+               ; /* fix warning about checking return value */
 
        for(i=0; i<totfile; i++) {
                if( (dir[i].type & S_IFREG) ) {
index 269fc2785819df9324c8904ad205ebcccec6c522..62af987c9661ccff619f1c832522d3ec7cd5e672 100644 (file)
@@ -732,7 +732,7 @@ void sort_faces(Scene *scene, View3D *v3d)
                                if (event == 1) { /* sort on view axis */
                                        mul_m4_v3(mat, vec);
                                        face_sort_floats[i] = vec[2] * reverse;
-                               } else { /* distance from cursor*/
+                               } else if(event == 2) { /* distance from cursor*/
                                        face_sort_floats[i] = len_v3v3(cur, vec) * reverse; /* back to front */
                                }
                        }
index 15ed20c783e67a5f29c7947ce10ae184f07af654..82e72136dafaa07605ad370e5341ed95e0e3de3e 100644 (file)
@@ -181,7 +181,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op)
                                }
                                else {
                                        /* perform clamping using euler form (3-components) */
-                                       float eul[3], oldeul[3], quat1[4];
+                                       float eul[3], oldeul[3], quat1[4] = {0};
                                        
                                        if (ob->rotmode == ROT_MODE_QUAT) {
                                                QUATCOPY(quat1, ob->quat);
index eec971e777e1c70ac96b239332f7ba52839c90fb..b1a3a3be28d00c54f7fd3e66fad91aa6f70a24a9 100644 (file)
@@ -109,9 +109,9 @@ static void *thread_tls_data;
 /* XXX */
 /* from header info.c */
 static int start_progress_bar(void) {return 0;};
-static void end_progress_bar(void) {};
+static void end_progress_bar(wmWindow *win) {WM_cursor_restore(win);};
 static void waitcursor(int val) {};
-static int progress_bar(float done, char *busy_info) {return 0;}
+static int progress_bar(wmWindow *win, float done, char *busy_info) { WM_timecursor(win,done*100); return 0;}
 static int pupmenu() {return 0;}
 /* XXX */
 
@@ -1060,7 +1060,7 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
                {
                        int done = 0;
                        float noFramesf = (float)noFrames;
-                       float percentdone = 0.0;
+                       float percentdone = 0.0, oldpercentdone = -1.0;
                        int lastRedraw = -1;
                        
                        g_break= 0;
@@ -1075,11 +1075,15 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
                                
                                // lukep we add progress bar as an interim mesure
                                percentdone = globalBakeFrame / noFramesf;
-                               sprintf(busy_mess, "baking fluids %d / %d       |||", globalBakeFrame, (int) noFramesf);
-                               progress_bar(percentdone, busy_mess );
+                               if (percentdone != oldpercentdone) {
+                                       sprintf(busy_mess, "baking fluids %d / %d       |||", globalBakeFrame, (int) noFramesf);
+                                       percentdone = percentdone < 0.0 ? 0.0:percentdone;
+                                       progress_bar(CTX_wm_window(C), percentdone, busy_mess );
+                                       oldpercentdone = percentdone;
+                               }
                                
-                               // longer delay to prevent frequent redrawing
-                               PIL_sleep_ms(2000);
+                               //XXX no more need for longer delay to prevent frequent redrawing
+                               PIL_sleep_ms(200);
                                
                                BLI_lock_thread(LOCK_CUSTOM1);
                                if(globalBakeState != 0) done = 1; // 1=ok, <0=error/abort
@@ -1121,7 +1125,7 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
 #endif
                                } // redraw
                        }
-                       end_progress_bar();
+                       end_progress_bar(CTX_wm_window(C));
                }
                BLI_end_threads(&threads);
        } // El'Beem API init, thread creation 
index f83af1d5167c8c4ee8c42fade72149cde1925b45..9e7034b6475344b1cdaae1a236af684c46a824a8 100644 (file)
@@ -1390,6 +1390,8 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
        // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file)
                // scrollbars for button regions
        ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); 
+       ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
+       ar->v2d.scroll &= ~V2D_SCROLL_VERTICAL_HIDE;
        ar->v2d.keepzoom |= V2D_KEEPZOOM;
 
                // correctly initialised User-Prefs?
index 259cb6d7c905cf01f8469460bc505c387e9f99b0..d747fc26aed176f36f869e0016207ea6bf8cf333 100644 (file)
@@ -1513,9 +1513,11 @@ static int frame_offset_exec(bContext *C, wmOperator *op)
        int delta;
        
        delta = RNA_int_get(op->ptr, "delta");
-       
+
        CTX_data_scene(C)->r.cfra += delta;
        
+       sound_seek_scene(C);
+
        WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C));
        
        return OPERATOR_FINISHED;
@@ -2473,12 +2475,13 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
                        }
                }
                
+               if(sad->flag & ANIMPLAY_FLAG_JUMPED)
+                       sound_seek_scene(C);
+
                /* since we follow drawflags, we can't send notifier but tag regions ourselves */
 
                ED_update_for_newframe(C, 1);
                
-               sound_update_playing(C);
-
                for(sa= screen->areabase.first; sa; sa= sa->next) {
                        ARegion *ar;
                        for(ar= sa->regionbase.first; ar; ar= ar->next) {
@@ -2521,16 +2524,19 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot)
 static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
 {
        bScreen *screen= CTX_wm_screen(C);
+       struct Scene* scene = CTX_data_scene(C);
        
        if(screen->animtimer) {
                /* stop playback now */
                ED_screen_animation_timer(C, 0, 0, 0);
-               sound_stop_all(C);
+               sound_stop_scene(scene);
        }
        else {
                ScrArea *sa= CTX_wm_area(C);
                int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
                int sync= -1;
+               if(mode == 1) // XXX only play audio forwards!?
+                       sound_play_scene(scene);
                
                if(RNA_property_is_set(op->ptr, "sync"))
                        sync= (RNA_boolean_get(op->ptr, "sync"));
index c5dc6f74f58a78cf81cfccccb60bd74184fa4b7a..81e2b1caea2b12d04dd2914daf765e57084096a9 100644 (file)
@@ -3578,7 +3578,7 @@ static void *do_projectpaint_thread(void *ph_v)
        rctf bucket_bounds;
        
        /* for smear only */
-       float pos_ofs[2];
+       float pos_ofs[2] = {0};
        float co[2];
        float mask = 1.0f; /* airbrush wont use mask */
        unsigned short mask_short;
index 1914c40f817286891eb6697da35c43ee2d1d92a8..129d10050a51b7f89c8cee224245fa0f612880d7 100644 (file)
@@ -1276,7 +1276,7 @@ static void do_flatten_clay_brush(Sculpt *sd, SculptSession *ss, PBVHNode **node
        Brush *brush = paint_brush(&sd->paint);
        float bstrength= ss->cache->bstrength;
        float area_normal[3];
-       float cntr[3], cntr2[3], bstr = 0;
+       float cntr[3], cntr2[3] = {0}, bstr = 0;
        int n, flip = 0;
 
        calc_area_normal(sd, ss, area_normal, nodes, totnode);
index 064baafbd9561b40e8897587750a28d9bf355b6a..7398017a267b8648857e04655821973717699a06 100644 (file)
@@ -74,12 +74,12 @@ static int open_exec(bContext *C, wmOperator *op)
 
        sound = sound_new_file(CTX_data_main(C), path);
 
-       if (sound==NULL || sound->handle == NULL) {
+       if (sound==NULL || sound->playback_handle == NULL) {
                BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
                return OPERATOR_CANCELLED;
        }
 
-       info = AUD_getInfo(sound->handle);
+       info = AUD_getInfo(sound->playback_handle);
 
        if (info.specs.channels == AUD_CHANNELS_INVALID) {
                sound_delete(C, sound);
index 22f5989f3aa2ef2e26a5ff7ec9eb944d9371df5f..d91f2788ecdaf0fa7f18395d696e66ae1ca98f6f 100644 (file)
@@ -733,7 +733,7 @@ void ACTION_OT_clean (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* properties */
-       RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
+       ot->prop= RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
 }
 
 /* ******************** Sample Keyframes Operator *********************** */
index 1939057b654f501471e5fc04e84b8fa3f6cc0ce0..c22533f9d45042d0bab631939a85a200c7c6dc7b 100644 (file)
@@ -196,7 +196,7 @@ void ACTION_OT_select_all_toggle (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* props */
-       RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
+       ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
 }
 
 /* ******************** Border Select Operator **************************** */
@@ -362,7 +362,7 @@ void ACTION_OT_select_border(wmOperatorType *ot)
        /* rna */
        WM_operator_properties_gesture_border(ot, FALSE);
        
-       RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
+       ot->prop= RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
 }
 
 /* ******************** Column Select Operator **************************** */
@@ -571,7 +571,7 @@ void ACTION_OT_select_column (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* props */
-       RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
+       ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
 }
 
 /* ******************** Select More/Less Operators *********************** */
index dbe9417fd2aed6941c268f4b1f92c50ee4bf385a..556ab13654b7afc9b11daac06d87628448fa1d06 100644 (file)
@@ -801,7 +801,7 @@ static void filelist_read_dir(struct FileList* filelist)
        BLI_hide_dot_files(filelist->hide_dot);
        filelist->numfiles = BLI_getdir(filelist->dir, &(filelist->filelist));
 
-       chdir(wdir);
+       if(!chdir(wdir)) /* fix warning about not checking return value */;
        filelist_setfiletypes(filelist, G.have_quicktime);
        filelist_filter(filelist);
 
index dca2b2f3b982ae12a6cae55c76a7bc3e778404b1..40e035759d15dd652702ba6ab2436b3c6f29e0a5 100644 (file)
@@ -924,7 +924,7 @@ void GRAPH_OT_clean (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* properties */
-       RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
+       ot->prop= RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
 }
 
 /* ******************** Bake F-Curve Operator *********************** */
@@ -2013,7 +2013,7 @@ void GRAPH_OT_fmodifier_add (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* id-props */
-       RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", "");
+       ot->prop= RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", "");
        RNA_def_boolean(ot->srna, "only_active", 1, "Only Active", "Only add F-Modifier to active F-Curve.");
 }
 
index 648a162890d57ebc66a5c068626c3d4f21744bc6..f8a12c566df8bfeaee195997a13568f612670e41 100644 (file)
@@ -77,7 +77,7 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op)
         * NOTE: sync this part of the code with ANIM_OT_change_frame
         */
        CFRA= RNA_int_get(op->ptr, "frame");
-       sound_scrub(C);
+       sound_seek_scene(C);
        
        /* set the cursor value */
        sipo->cursorVal= RNA_float_get(op->ptr, "value");
index 872b688bea14e863ed66575c41774c7412b16727..b2a38c295fa9467f1b3230e85512032e0e6f6c24 100644 (file)
@@ -199,7 +199,7 @@ void GRAPH_OT_select_all_toggle (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
        
        /* props */
-       RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
+       ot->prop= RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
 }
 
 /* ******************** Border Select Operator **************************** */
@@ -361,7 +361,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
        /* rna */
        WM_operator_properties_gesture_border(ot, FALSE);
        
-       RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
+       ot->prop= RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", "");
 }
 
 /* ******************** Column Select Operator **************************** */
@@ -546,7 +546,7 @@ void GRAPH_OT_select_column (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
        
        /* props */
-       RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
+       ot->prop= RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
 }
 
 /* ******************** Select More/Less Operators *********************** */
@@ -687,7 +687,16 @@ enum {
        NEAREST_HANDLE_KEY,
        NEAREST_HANDLE_RIGHT
 } eHandleIndex; 
+
+/* check if its ok to select a handle */
+// XXX also need to check for int-values only?
+static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
+{
+       if (sipo->flag & SIPO_NOHANDLES) return 0;
+       if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt)==0) return 0;
+       return 1;
+}
+
 /* Find the vertex (either handle (0/2) or the keyframe (1)) that is nearest to the mouse cursor (in area coordinates)  
  * Selected verts get a disadvantage, to make it easier to select handles behind.
  * Returns eHandleIndex
@@ -751,8 +760,7 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc
                                }
                                
                                /* handles - only do them if they're visible */
-                               // XXX also need to check for int-values only?
-                               if ((sipo->flag & SIPO_NOHANDLES)==0) {
+                               if (fcurve_handle_sel_check(sipo, bezt1)) {
                                        /* first handle only visible if previous segment had handles */
                                        if ( (!prevbezt && (bezt1->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) )
                                        {
index 1666a169f12060d948df03bc54ca617f09319b5f..885521fe8c0315e1de95079c5b69be6f895310ab 100644 (file)
@@ -59,6 +59,7 @@
 #include "BKE_animsys.h"
 #include "BKE_nla.h"
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
@@ -109,7 +110,8 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
        ale= BLI_findlink(&anim_data, channel_index);
        if (ale == NULL) {
                /* channel not found */
-               printf("Error: animation channel (index = %d) not found in mouse_anim_channels() \n", channel_index);
+               if (G.f & G_DEBUG)
+                       printf("Error: animation channel (index = %d) not found in mouse_anim_channels() \n", channel_index);
                
                BLI_freelistN(&anim_data);
                return 0;
@@ -277,7 +279,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
                        break;
                case ANIMTYPE_NLAACTION:
                {
-                       AnimData *adt= BKE_animdata_from_id(ale->owner); /* this won't crash, right? */
+                       AnimData *adt= BKE_animdata_from_id(ale->id);