else
{
sample_t* buf = m_buffer->getBuffer();
- float volume;
+ float volume = 1.0f;
for(int i = 0; i < length * specs.channels; i++)
{
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")
}
if(message.type == AUD_MSG_LOOP)
{
m_loop = message.loopcount;
+ m_samples = message.time * m_reader->getSpecs().rate;
m_reader->notify(message);
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);
*/
int m_loop;
+ /**
+ * The left samples.
+ */
+ int m_samples;
+
public:
/**
* Creates a new loop reader.
AUD_DEVICE_SAMPLE_SIZE(specs),
specs.rate);
- if(alGetError() != AL_NO_ERROR)
+ if((err = alGetError()) != AL_NO_ERROR)
{
sound->data_end = true;
break;
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;
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();
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,
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);
{
m_reader->seek(position / m_factor);
src_reset(m_src);
+ m_position = position;
}
int AUD_SRCResampleReader::getLength()
int AUD_SRCResampleReader::getPosition()
{
- return m_reader->getPosition() * m_factor;
+ return m_position;
}
AUD_Specs AUD_SRCResampleReader::getSpecs()
buffer = m_buffer->getBuffer();
length = src_callback_read(m_src, m_factor, length, buffer);
+
+ m_position += length;
}
*/
SRC_STATE* m_src;
+ /**
+ * The current playback position;
+ */
+ int m_position;
+
public:
/**
* Creates a resampling reader.
#include <cstdlib>
#include <cstring>
+#include <cmath>
#include "AUD_NULLDevice.h"
#include "AUD_I3DDevice.h"
#include "AUD_ReadDevice.h"
#include "AUD_SourceCaps.h"
#include "AUD_IReader.h"
+#include "AUD_SequencerFactory.h"
#ifdef WITH_SDL
#include "AUD_SDLDevice.h"
}
}
-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);
}
}
-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
{
}
}
-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)
{
*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
typedef void AUD_Sound;
typedef void AUD_Handle;
typedef void AUD_Device;
+ typedef void AUD_SequencerEntry;
+ typedef float (*AUD_volumeFunction)(void*, void*, float);
#endif
/**
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.
/**
* 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.
*/
* 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.
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
#include "AUD_Mixer.h"
#include "AUD_SRCResampleFactory.h"
+#include "AUD_LinearResampleFactory.h"
#include "AUD_ChannelMapperFactory.h"
#include "AUD_IReader.h"
#include "AUD_Buffer.h"
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();
return reader;
}
+AUD_DeviceSpecs AUD_Mixer::getSpecs()
+{
+ return m_specs;
+}
+
void AUD_Mixer::setSpecs(AUD_DeviceSpecs specs)
{
m_specs = 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;
}
}
-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);
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);
#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;
struct AUD_MixerBuffer
{
sample_t* buffer;
+ int start;
int length;
float volume;
};
/**
* 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.
*/
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.
* \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.
--- /dev/null
+/*
+ * $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);
+}
--- /dev/null
+/*
+ * $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
--- /dev/null
+/*
+ * $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;
+}
--- /dev/null
+/*
+ * $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
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
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)
}
}
- // 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);
//#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
union
{
// loop reader
- int loopcount;
+ struct
+ {
+ int loopcount;
+ float time;
+ };
// volume reader
float volume;
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
* 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
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;
return;
default:
ABORT("Invalid ISPEC");
+ return;
}
if ( bnz != 0 ) {
//////////////////////////////////////////////////////////////////////
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;
float *_xVorticity, *_yVorticity, *_zVorticity, *_vorticity;
- int _vIndex = _slabSize + _xRes + 1;
int bb=0;
int bt=0;
int bb1=-1;
float xTotal = dx * res[0];
float yTotal = dx * res[1];
- float zTotal = dx * res[2];
float heighMin = 0.05;
float heighMax = 0.10;
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;
float* t1 = temp1;
const int sx= res[0];
const int sy= res[1];
- const int sz= res[2];
float*& phiN = oldField;
float*& phiN1 = newField;
#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;
{
// 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++) {
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) {
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());
{
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);
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
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()
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)
--- /dev/null
+# ##### 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()
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
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'
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="")
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")
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")
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)
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="")
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()
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")
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()
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()
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'
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")
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")
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")
struct DriverVar;
struct DriverTarget;
+struct bAction;
struct BezTriple;
struct StructRNA;
struct PointerRNA;
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);
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);
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);
struct bContext;
struct ListBase;
struct Main;
+struct Sequence;
void sound_init();
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
#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
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)
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')
#include "CCGSubSurf.h"
+#include "MEM_guardedalloc.h"
#include "BLO_sys_types.h" // for intptr_t support
#ifdef _MSC_VER
_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);
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;
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) {
_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;
#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)
#pragma omp critical
{
- CCGSUBSURF_free(ss, q);
- CCGSUBSURF_free(ss, r);
+ MEM_freeN(q);
+ MEM_freeN(r);
}
}
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];
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)
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];
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++) {
}
}
- if(freeF) CCGSUBSURF_free(ss, effectedF);
+ if(freeF) MEM_freeN(effectedF);
return eCCGError_None;
}
}
}
- if(freeF) CCGSUBSURF_free(ss, effectedF);
+ if(freeF) MEM_freeN(effectedF);
return eCCGError_None;
}
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;
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++) {
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;
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;
}
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;
}
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;
}
CPPFLAGS += -DWITH_QUICKTIME
endif
+ifeq ($(OS), darwin)
+ ifeq ($(WITH_BF_OPENMP), true)
+ CPPFLAGS += -DPARALLEL=1
+ endif
+endif
* 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;
return num_sols;
}
+#endif
// w3 is not perfect
}
#endif
+#if 0
static float projectPointOntoLine(float *p, float *a, float *b)
{
float ba[3], pa[3];
return 0;
}
-#if 0
static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair )
{
EdgeCollPair edgecollpair;
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;
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 */
/* ......... */
+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)
{
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);
+ }
+ }
}
}
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
+#include <errno.h>
#ifndef _WIN32
#include <unistd.h>
#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"
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;
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;
}
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;
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;
}
}
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");
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;
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);
/* Blender vars */
Object *ob;
Mesh *me;
- float vert[3];
+ float vert[3] = {0};
MVert *mvert, *vtmp;
MFace *mface, *ftmp;
/* Blender vars */
Object *ob;
Mesh *me;
- float vert[3];
+ float vert[3] = {0};
MVert *mvert;
MFace *mface;
{
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)
static int node_animation_properties(bNodeTree *ntree, bNode *node)
{
bNodeSocket *sock;
- ListBase *lb;
+ const ListBase *lb;
Link *link;
PointerRNA ptr;
PropertyRNA *prop;
#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"
#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]); }
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)
{
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;
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;
cache->flag |= PTCACHE_BAKING;
if(bake)
- endframe = MAX2(endframe, cache->endframe);
+ thread_data.endframe = MAX2(thread_data.endframe, cache->endframe);
}
cache->flag &= ~PTCACHE_BAKED;
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) {
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);
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 */
#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"
}
}
+ sound_create_scene(scen);
+
return scen;
}
if(sce->stats)
MEM_freeN(sce->stats);
+
+ sound_destroy_scene(sce);
}
Scene *add_scene(char *name)
sce->gm.flag = GAME_DISPLAY_LISTS;
sce->gm.matmode = GAME_MAT_MULTITEX;
+ sound_create_scene(sce);
+
return sce;
}
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;
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;
+}
+
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);
}
-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;
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;
/* 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;
}
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) {
}
}
}
- calc_sequence_disp(seq);
+ calc_sequence_disp(scene, 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) {
free_proxy_seq(seq);
- calc_sequence(seq);
+ calc_sequence(scene, seq);
}
void sort_seq(Scene *scene)
}
if(len_change)
- calc_sequence(seq);
+ calc_sequence(scene, seq);
}
return free_imbuf;
}
#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.
}
}
- calc_sequence_disp(seq);
+ calc_sequence_disp(evil_scene, seq);
}
/* return 0 if there werent enough space */
{
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.
}
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;
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;
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;
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) {
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;
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);
}
}
seq->machine= machine;
seq->mul= 1.0;
seq->blend_opacity = 100.0;
+ seq->volume = 1.0f;
return seq;
}
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);
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);
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) {
/* 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;
#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"
#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>
sound_load(main, sound);
- if(!sound->handle)
+ if(!sound->playback_handle)
{
free_libblock(&main->sound, sound);
sound = NULL;
sound_load(CTX_data_main(C), sound);
- if(!sound->handle)
+ if(!sound->playback_handle)
{
free_libblock(&CTX_data_main(C)->sound, sound);
sound = NULL;
sound_load(CTX_data_main(C), sound);
- if(!sound->handle)
+ if(!sound->playback_handle)
{
free_libblock(&CTX_data_main(C)->sound, sound);
sound = NULL;
{
sound_free(sound);
- sound_unlink(C, sound);
-
free_libblock(&CTX_data_main(C)->sound, sound);
}
}
AUD_unload(sound->cache);
sound->cache = AUD_bufferSound(sound->handle);
- sound->changed++;
+ sound->playback_handle = sound->cache;
}
void sound_delete_cache(struct bSound* sound)
{
AUD_unload(sound->cache);
sound->cache = NULL;
+ sound->playback_handle = sound->handle;
}
}
{
AUD_unload(sound->handle);
sound->handle = NULL;
+ sound->playback_handle = NULL;
}
// XXX unused currently
break;
}
#endif
- sound->changed++;
+ if(sound->cache)
+ sound->playback_handle = sound->cache;
+ else
+ sound->playback_handle = sound->handle;
}
}
{
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);
}
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;
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);
char *faceFlags = ccgdm->faceFlags;
int a, b, i, doDraw, numVerts, matnr, new_matnr, totface;
+ ccgdm_pbvh_update(ccgdm);
+
doDraw = 0;
numVerts = 0;
matnr = -1;
unsigned char *cp1, *cp2;
int useTwoSide=1;
+ ccgdm_pbvh_update(ccgdm);
+
cp1= col1;
if(col2) {
cp2= col2;
int i, totface, flag, gridSize = ccgSubSurf_getGridSize(ss);
int gridFaces = gridSize - 1;
+ ccgdm_pbvh_update(ccgdm);
+
if(!mcol)
mcol = dm->getFaceDataArray(dm, CD_MCOL);
bNode *give_current_material_texture_node(Material *ma)
{
- bNode *node;
-
if(ma && ma->use_nodes && ma->nodetree)
return nodeGetActiveID(ma->nodetree, ID_TE);
*
*/
-
#ifdef WITH_FFMPEG
#include <string.h>
#include <stdio.h>
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;
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;
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;
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;
}
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) {
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 */
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;
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) {
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;
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) {
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;
}
}
- 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.");
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;
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;
}
}
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;
}
fprintf(stderr, "Closing ffmpeg...\n");
- if (audio_stream && video_stream) {
+/* if (audio_stream) { SEE UPPER
write_audio_frames();
- }
+ }*/
if(audio_mixdown_device)
{
}
}
- 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;
}
}
} bAKey;
typedef struct bArgument {
+ bAKey *key;
BA_ArgCallback func;
void *data;
} bArgument;
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;
}
}
+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");
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;
} else {
func = default_cb;
data = default_data;
-
- if (func) {
- printf("calling default on %s\n", ba->argv[i]);
- }
}
if (func) {
// 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
/*
* Heapsort algorithm
*/
+#if 0
static void bvh_downheap(BVHNode **a, int i, int n, int lo, int axis)
{
BVHNode * d = a[lo+i-1];
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
{
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);
}
}
/* 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]
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];
}
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)
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];
vec[2]= z/noisesize;
nr++;
return turbulence_perlin(vec, 1.0, (float)(1<<nr));
-}
+}*/
/******************/
/* VORONOI/WORLEY */
{
/* 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 */
size= ftell(fp);
fseek(fp, 0, SEEK_SET);
- buf= malloc(size);
+ buf= MEM_mallocN(size, "file_as_lines");
if (buf) {
int i, last= 0;
}
}
- free(buf);
+ MEM_freeN(buf);
}
fclose(fp);
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;
#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);
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;
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);
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)
{
}
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 */
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);
}
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);
}
}
}
ma->vol.ms_intensity = 1.f;
}
}
-
}
if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) {
/* 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) {
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! */
/* 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);
}
}
}
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;
#include "BKE_material.h"
#include "BKE_object.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "UI_interface.h"
/* 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;
+ }
}
}
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 *********************** */
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 *********************** */
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 *********************** */
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;
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)) {
}
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 */
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);
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);
}
*/
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) ----------------------------- */
}
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);
{
/* 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);
}
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 */
DepthPeel *p1, *p2;
float *last_p = NULL;
float dist = FLT_MAX;
- float p[3];
+ float p[3] = {0};
float size = 0;
float mvalf[2];
/* ******************* 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);
{
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;
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;
}
}
}
+ CTX_DATA_END;
if (found == 0)
return OPERATOR_CANCELLED;
/* ******************* 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;
*/
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;
}
}
}
+ CTX_DATA_END;
}
/* free temp info */
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;
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;
}
*/
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;
}
}
if(!buf) {
- BLI_strncpy(str, "", maxlen);
+ str[0] = '\0';
}
else if(buf && buf != str) {
/* string was too long, we have to truncate */
/* 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) {
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;
/* 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;
}
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) ) {
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 */
}
}
}
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);
/* 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 */
{
int done = 0;
float noFramesf = (float)noFrames;
- float percentdone = 0.0;
+ float percentdone = 0.0, oldpercentdone = -1.0;
int lastRedraw = -1;
g_break= 0;
// 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
#endif
} // redraw
}
- end_progress_bar();
+ end_progress_bar(CTX_wm_window(C));
}
BLI_end_threads(&threads);
} // El'Beem API init, thread creation
// 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?
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;
}
}
+ 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) {
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"));
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;
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);
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);
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 *********************** */
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 **************************** */
/* 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 **************************** */
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 *********************** */
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);
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 *********************** */
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.");
}
* 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");
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 **************************** */
/* 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 **************************** */
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 *********************** */
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
}
/* 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)) )
{
#include "BKE_animsys.h"
#include "BKE_nla.h"
#include "BKE_context.h"
+#include "BKE_global.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
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;
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);