Merged changes in the trunk up to revision 25613.

This commit is contained in:
2009-12-29 21:46:36 +00:00
294 changed files with 19336 additions and 17280 deletions

View File

@@ -47,18 +47,21 @@ if MACOSX_ARCHITECTURE == 'ppc':
# CC = 'gcc-3.3' # CC = 'gcc-3.3'
# CXX = 'g++-3.3' # CXX = 'g++-3.3'
MAC_MIN_VERS = '10.4' MAC_MIN_VERS = '10.4'
MACOSX_DEPLOYMENT_TARGET = '10.4'
MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
LCGDIR = '#../lib/darwin-8.0.0-powerpc' LCGDIR = '#../lib/darwin-8.0.0-powerpc'
CC = 'gcc-4.0' CC = 'gcc-4.0'
CXX = 'g++-4.0' CXX = 'g++-4.0'
elif MACOSX_ARCHITECTURE == 'i386': elif MACOSX_ARCHITECTURE == 'i386':
MAC_MIN_VERS = '10.4' MAC_MIN_VERS = '10.4'
MACOSX_DEPLOYMENT_TARGET = '10.4'
MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk' MACOSX_SDK='/Developer/SDKs/MacOSX10.4u.sdk'
LCGDIR = '#../lib/darwin-8.x.i386' LCGDIR = '#../lib/darwin-8.x.i386'
CC = 'gcc-4.0' CC = 'gcc-4.0'
CXX = 'g++-4.0' CXX = 'g++-4.0'
else : else :
MAC_MIN_VERS = '10.5' MAC_MIN_VERS = '10.5'
MACOSX_DEPLOYMENT_TARGET = '10.5'
MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk' MACOSX_SDK='/Developer/SDKs/MacOSX10.5.sdk'
LCGDIR = '#../lib/darwin-9.x.universal' LCGDIR = '#../lib/darwin-9.x.universal'
CC = 'gcc-4.2' CC = 'gcc-4.2'

View File

@@ -793,7 +793,7 @@ btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,c
// //
btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,const btScalar* vertices, btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,const btScalar* vertices,
const int* triangles, const int* triangles,
int ntriangles) int ntriangles, bool randomizeConstraints)
{ {
int maxidx=0; int maxidx=0;
int i,j,ni; int i,j,ni;
@@ -828,14 +828,16 @@ btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo
#undef IDX #undef IDX
psb->appendFace(idx[0],idx[1],idx[2]); psb->appendFace(idx[0],idx[1],idx[2]);
} }
// don't randomize now, let's give a chance to the application to set face data if (randomizeConstraints)
//psb->randomizeConstraints(); {
psb->randomizeConstraints();
}
return(psb); return(psb);
} }
// //
btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo, const btVector3* vertices, btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo, const btVector3* vertices,
int nvertices) int nvertices, bool randomizeConstraints)
{ {
HullDesc hdsc(QF_TRIANGLES,nvertices,vertices); HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
HullResult hres; HullResult hres;
@@ -855,6 +857,9 @@ btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldI
psb->appendFace(idx[0],idx[1],idx[2]); psb->appendFace(idx[0],idx[1],idx[2]);
} }
hlib.ReleaseResult(hres); hlib.ReleaseResult(hres);
if (randomizeConstraints)
{
psb->randomizeConstraints(); psb->randomizeConstraints();
}
return(psb); return(psb);
} }

View File

@@ -109,11 +109,13 @@ struct btSoftBodyHelpers
static btSoftBody* CreateFromTriMesh( btSoftBodyWorldInfo& worldInfo, static btSoftBody* CreateFromTriMesh( btSoftBodyWorldInfo& worldInfo,
const btScalar* vertices, const btScalar* vertices,
const int* triangles, const int* triangles,
int ntriangles); int ntriangles,
bool randomizeConstraints = true);
/* Create from convex-hull */ /* Create from convex-hull */
static btSoftBody* CreateFromConvexHull( btSoftBodyWorldInfo& worldInfo, static btSoftBody* CreateFromConvexHull( btSoftBodyWorldInfo& worldInfo,
const btVector3* vertices, const btVector3* vertices,
int nvertices); int nvertices,
bool randomizeConstraints = true);
}; };
#endif //SOFT_BODY_HELPERS_H #endif //SOFT_BODY_HELPERS_H

View File

@@ -40,11 +40,6 @@ IF(WITH_OPENAL)
SET(INC ${INC} OpenAL ${OPENAL_INCLUDE_DIR}) SET(INC ${INC} OpenAL ${OPENAL_INCLUDE_DIR})
FILE(GLOB OPENALSRC OpenAL/*.cpp) FILE(GLOB OPENALSRC OpenAL/*.cpp)
ADD_DEFINITIONS(-DWITH_OPENAL) ADD_DEFINITIONS(-DWITH_OPENAL)
STRING(REGEX MATCH ".*ramework.*" FRAMEWORK ${OPENAL_INCLUDE_DIR})
IF(FRAMEWORK)
ADD_DEFINITIONS(-DAPPLE_FRAMEWORK_FIX)
ENDIF(FRAMEWORK)
ENDIF(WITH_OPENAL) ENDIF(WITH_OPENAL)
IF(WITH_JACK) IF(WITH_JACK)
@@ -59,6 +54,12 @@ IF(WITH_SNDFILE)
ADD_DEFINITIONS(-DWITH_SNDFILE) ADD_DEFINITIONS(-DWITH_SNDFILE)
ENDIF(WITH_SNDFILE) ENDIF(WITH_SNDFILE)
SET(SRC ${SRC} ${FFMPEGSRC} ${SNDFILESRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC}) IF(WITH_FFTW3)
SET(INC ${INC} fftw ${FFTW3_INC})
FILE(GLOB FFTW3SRC fftw/*.cpp)
ADD_DEFINITIONS(-DWITH_FFTW3)
ENDIF(WITH_FFTW3)
SET(SRC ${SRC} ${FFMPEGSRC} ${SNDFILESRC} ${FFTW3SRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC})
BLENDERLIB(bf_audaspace "${SRC}" "${INC}") BLENDERLIB(bf_audaspace "${SRC}" "${INC}")

View File

@@ -38,7 +38,7 @@ private:
/** /**
* The loop count. * The loop count.
*/ */
float m_loop; int m_loop;
public: public:
/** /**

View File

@@ -0,0 +1,45 @@
/*
* $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_RectifyFactory.h"
#include "AUD_RectifyReader.h"
AUD_RectifyFactory::AUD_RectifyFactory(AUD_IFactory* factory) :
AUD_EffectFactory(factory) {}
AUD_RectifyFactory::AUD_RectifyFactory() :
AUD_EffectFactory(0) {}
AUD_IReader* AUD_RectifyFactory::createReader()
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
reader = new AUD_RectifyReader(reader); AUD_NEW("reader")
}
return reader;
}

View File

@@ -0,0 +1,51 @@
/*
* $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_RECTIFYFACTORY
#define AUD_RECTIFYFACTORY
#include "AUD_EffectFactory.h"
/**
* This factory rectifies another factory.
*/
class AUD_RectifyFactory : public AUD_EffectFactory
{
public:
/**
* Creates a new rectify factory.
* \param factory The input factory.
*/
AUD_RectifyFactory(AUD_IFactory* factory = 0);
/**
* Creates a new rectify factory.
*/
AUD_RectifyFactory();
virtual AUD_IReader* createReader();
};
#endif //AUD_RECTIFYFACTORY

View File

@@ -0,0 +1,82 @@
/*
* $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_RectifyReader.h"
#include "AUD_Buffer.h"
#include <cstring>
AUD_RectifyReader::AUD_RectifyReader(AUD_IReader* reader) :
AUD_EffectReader(reader)
{
int bigendian = 1;
bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian
switch(m_reader->getSpecs().format)
{
case AUD_FORMAT_S16:
m_rectify = AUD_rectify<int16_t>;
break;
case AUD_FORMAT_S32:
m_rectify = AUD_rectify<int32_t>;
break;
case AUD_FORMAT_FLOAT32:
m_rectify = AUD_rectify<float>;
break;
case AUD_FORMAT_FLOAT64:
m_rectify = AUD_rectify<double>;
break;
case AUD_FORMAT_U8:
m_rectify = AUD_rectify_u8;
break;
case AUD_FORMAT_S24:
m_rectify = bigendian ? AUD_rectify_s24_be : AUD_rectify_s24_le;
break;
default:
delete m_reader;
AUD_THROW(AUD_ERROR_READER);
}
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
}
AUD_RectifyReader::~AUD_RectifyReader()
{
delete m_buffer; AUD_DELETE("buffer")
}
void AUD_RectifyReader::read(int & length, sample_t* & buffer)
{
sample_t* buf;
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buf);
if(m_buffer->getSize() < length*AUD_SAMPLE_SIZE(specs))
m_buffer->resize(length*AUD_SAMPLE_SIZE(specs));
buffer = m_buffer->getBuffer();
m_rectify(buffer, buf, length * specs.channels);
}

View File

@@ -0,0 +1,65 @@
/*
* $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_RECTIFYREADER
#define AUD_RECTIFYREADER
#include "AUD_EffectReader.h"
#include "AUD_ConverterFunctions.h"
class AUD_Buffer;
/**
* This class reads another reader and rectifies it.
*/
class AUD_RectifyReader : public AUD_EffectReader
{
private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
/**
* Rectifying function.
*/
AUD_rectify_f m_rectify;
public:
/**
* Creates a new rectify reader.
* \param reader The reader to read from.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_RectifyReader(AUD_IReader* reader);
/**
* Destroys the reader.
*/
virtual ~AUD_RectifyReader();
virtual void read(int & length, sample_t* & buffer);
};
#endif //AUD_RECTIFYREADER

View File

@@ -56,6 +56,10 @@ ifeq ($(WITH_SNDFILE),true)
DIRS += sndfile DIRS += sndfile
endif endif
ifeq ($(WITH_FFTW3),true)
DIRS += fftw
endif
include nan_subdirs.mk include nan_subdirs.mk
install: $(ALL_OR_DEBUG) install: $(ALL_OR_DEBUG)
@@ -80,6 +84,10 @@ ifeq ($(WITH_SNDFILE),true)
@../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaud_sndfile.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaud_sndfile.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)
endif endif
ifeq ($(WITH_FFTW3),true)
@../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaud_fftw.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)
endif
ifeq ($(OS),darwin) ifeq ($(OS),darwin)
ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaudaspace.a ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaudaspace.a
ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_src.a ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_src.a
@@ -102,5 +110,9 @@ ifeq ($(WITH_SNDFILE),true)
ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_sndfile.a ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_sndfile.a
endif endif
ifeq ($(WITH_FFTW3),true)
ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_fftw.a
endif
endif endif
@../tools/cpifdiff.sh intern/*.h $(NAN_AUDASPACE)/include/ @../tools/cpifdiff.sh intern/*.h $(NAN_AUDASPACE)/include/

View File

@@ -31,4 +31,9 @@ if env['WITH_BF_SNDFILE']:
incs += ' sndfile ' + env['BF_SNDFILE_INC'] incs += ' sndfile ' + env['BF_SNDFILE_INC']
defs.append('WITH_SNDFILE') defs.append('WITH_SNDFILE')
if env['WITH_BF_FFTW3']:
sources += env.Glob('fftw/*.cpp')
incs += ' fftw ' + env['BF_FFTW3_INC']
defs.append('WITH_FFTW3')
env.BlenderLib ('bf_audaspace', sources, Split(incs), defs, libtype=['intern','player'], priority = [25,215] ) env.BlenderLib ('bf_audaspace', sources, Split(incs), defs, libtype=['intern','player'], priority = [25,215] )

View File

@@ -0,0 +1,79 @@
/*
* $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_BandPassFactory.h"
#include "AUD_BandPassReader.h"
AUD_BandPassFactory::AUD_BandPassFactory(AUD_IFactory* factory, float low,
float high) :
AUD_EffectFactory(factory),
m_low(low),
m_high(high) {}
AUD_BandPassFactory::AUD_BandPassFactory(float low, float high) :
AUD_EffectFactory(0),
m_low(low),
m_high(high) {}
float AUD_BandPassFactory::getLow()
{
return m_low;
}
float AUD_BandPassFactory::getHigh()
{
return m_high;
}
void AUD_BandPassFactory::setLow(float low)
{
m_low = low;
}
void AUD_BandPassFactory::setHigh(float high)
{
m_high = high;
}
AUD_IReader* AUD_BandPassFactory::createReader()
{
AUD_IReader* reader = getReader();
if(reader != 0)
{
if(reader->getSpecs().format == AUD_FORMAT_FLOAT32)
{
reader = new AUD_BandPassReader(reader, m_low, m_high);
AUD_NEW("reader")
}
else
{
delete reader; AUD_DELETE("reader")
return 0;
}
}
return reader;
}

View File

@@ -0,0 +1,88 @@
/*
* $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_BANDPASSFACTORY
#define AUD_BANDPASSFACTORY
#include "AUD_EffectFactory.h"
/**
* This factory creates a band pass filter for a sound wave.
*/
class AUD_BandPassFactory : public AUD_EffectFactory
{
private:
/**
* The lowest frequency to be passed.
*/
float m_low;
/**
* The highest frequency to be passed.
*/
float m_high;
public:
/**
* Creates a new band pass factory.
* \param factory The input factory.
* \param low The lowest passed frequency.
* \param high The highest passed frequency.
*/
AUD_BandPassFactory(AUD_IFactory* factory, float low, float high);
/**
* Creates a new band pass factory.
* \param low The lowest passed frequency.
* \param high The highest passed frequency.
*/
AUD_BandPassFactory(float low, float high);
/**
* Returns the lowest passed frequency.
*/
float getLow();
/**
* Returns the highest passed frequency.
*/
float getHigh();
/**
* Sets the lowest passed frequency.
* \param low The lowest passed frequency.
*/
void setLow(float low);
/**
* Sets the highest passed frequency.
* \param high The highest passed frequency.
*/
void setHigh(float hight);
virtual AUD_IReader* createReader();
};
#endif //AUD_BANDPASSFACTORY

View File

@@ -0,0 +1,126 @@
/*
* $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_BandPassReader.h"
#include "AUD_Buffer.h"
#include <cstring>
#include <stdio.h>
AUD_BandPassReader::AUD_BandPassReader(AUD_IReader* reader, float low,
float high) :
AUD_EffectReader(reader), m_low(low), m_high(high)
{
m_buffer = new AUD_Buffer(); AUD_NEW("buffer")
m_in = new AUD_Buffer(); AUD_NEW("buffer")
m_out = new AUD_Buffer(); AUD_NEW("buffer")
m_length = 0;
}
AUD_BandPassReader::~AUD_BandPassReader()
{
if(m_length != 0)
{
fftw_destroy_plan(m_forward);
fftw_destroy_plan(m_backward);
}
delete m_buffer; AUD_DELETE("buffer")
delete m_in; AUD_DELETE("buffer")
delete m_out; AUD_DELETE("buffer")
}
AUD_ReaderType AUD_BandPassReader::getType()
{
return m_reader->getType();
}
void AUD_BandPassReader::read(int & length, sample_t* & buffer)
{
AUD_Specs specs = m_reader->getSpecs();
m_reader->read(length, buffer);
if(length > 0)
{
if(length * AUD_SAMPLE_SIZE(specs) > m_buffer->getSize())
m_buffer->resize(length * AUD_SAMPLE_SIZE(specs));
if(length != m_length)
{
if(m_length != 0)
{
fftw_destroy_plan(m_forward);
fftw_destroy_plan(m_backward);
}
m_length = length;
printf("WINDOW: %d\n", m_length);
if(m_length * sizeof(double) > m_in->getSize())
{
m_in->resize(m_length * sizeof(double));
m_out->resize((m_length / 2 + 1) * sizeof(fftw_complex));
}
m_forward = fftw_plan_dft_r2c_1d(m_length,
(double*)m_in->getBuffer(),
(fftw_complex*)m_out->getBuffer(),
FFTW_ESTIMATE);
m_backward = fftw_plan_dft_c2r_1d(m_length,
(fftw_complex*)m_out->getBuffer(),
(double*)m_in->getBuffer(),
FFTW_ESTIMATE);
}
float* source = (float*) buffer;
double* target = (double*) m_in->getBuffer();
float* target2 = (float*) m_buffer->getBuffer();
fftw_complex* complex = (fftw_complex*) m_out->getBuffer();
float frequency;
for(int channel = 0; channel < specs.channels; channel++)
{
for(int i = 0; i < m_length; i++)
target[i] = source[i * specs.channels + channel];
fftw_execute(m_forward);
for(int i = 0; i < m_length / 2 + 1; i++)
{
frequency = i * specs.rate / (m_length / 2.0 + 1.0);
if((frequency < m_low) || (frequency > m_high))
complex[i][0] = complex[i][1] = 0.0;
}
fftw_execute(m_backward);
for(int i = 0; i < m_length; i++)
target2[i * specs.channels + channel] = target[i] / m_length;
}
}
buffer = m_buffer->getBuffer();
}

View File

@@ -0,0 +1,99 @@
/*
* $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_BANDPASSREADER
#define AUD_BANDPASSREADER
#include <fftw3.h>
#include "AUD_EffectReader.h"
class AUD_Buffer;
/**
* This class only passes a specific frequency band of another reader.
*/
class AUD_BandPassReader : public AUD_EffectReader
{
private:
/**
* The playback buffer.
*/
AUD_Buffer *m_buffer;
/**
* The input buffer for fourier transformations.
*/
AUD_Buffer *m_in;
/**
* The output buffer for fourier transformations.
*/
AUD_Buffer *m_out;
/**
* The lowest passed frequency.
*/
float m_low;
/**
* The highest passed frequency.
*/
float m_high;
/**
* The fftw plan for forward transformation.
*/
fftw_plan m_forward;
/**
* The fftw plan for backward transformation.
*/
fftw_plan m_backward;
/**
* The length of the plans.
*/
int m_length;
public:
/**
* Creates a new band pass reader.
* \param reader The reader to read from.
* \param low The lowest passed frequency.
* \param high The highest passed frequency.
* \exception AUD_Exception Thrown if the reader specified is NULL.
*/
AUD_BandPassReader(AUD_IReader* reader, float low, float high);
/**
* Destroys the reader.
*/
virtual ~AUD_BandPassReader();
virtual AUD_ReaderType getType();
virtual void read(int & length, sample_t* & buffer);
};
#endif //AUD_BANDPASSREADER

View File

@@ -0,0 +1,42 @@
#
# $Id$
#
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): none yet.
#
# ***** END GPL LICENSE BLOCK *****
#
#
LIBNAME = aud_fftw
DIR = $(OCGDIR)/intern/audaspace
include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I../intern
CPPFLAGS += -I../FX
CPPFLAGS += -I..
CPPFLAGS += -I.
CPPFLAGS += -I$(BF_FFTW3)/include

View File

@@ -81,7 +81,7 @@ void AUD_BufferReader::read(int & length, sample_t* & buffer)
buffer = m_buffer.get()->getBuffer()+m_position*sample_size; buffer = m_buffer.get()->getBuffer()+m_position*sample_size;
// in case the end of the buffer is reach // in case the end of the buffer is reached
if(m_buffer.get()->getSize() < (m_position+length)*sample_size) if(m_buffer.get()->getSize() < (m_position+length)*sample_size)
length = m_buffer.get()->getSize()/sample_size-m_position; length = m_buffer.get()->getSize()/sample_size-m_position;

View File

@@ -31,6 +31,7 @@
#include "AUD_LimiterFactory.h" #include "AUD_LimiterFactory.h"
#include "AUD_PingPongFactory.h" #include "AUD_PingPongFactory.h"
#include "AUD_LoopFactory.h" #include "AUD_LoopFactory.h"
#include "AUD_RectifyFactory.h"
#include "AUD_ReadDevice.h" #include "AUD_ReadDevice.h"
#include "AUD_SourceCaps.h" #include "AUD_SourceCaps.h"
#include "AUD_IReader.h" #include "AUD_IReader.h"
@@ -285,6 +286,20 @@ int AUD_stopLoop(AUD_Handle* handle)
return false; return false;
} }
AUD_Sound* AUD_rectifySound(AUD_Sound* sound)
{
assert(sound);
try
{
return new AUD_RectifyFactory(sound);
}
catch(AUD_Exception)
{
return NULL;
}
}
void AUD_unload(AUD_Sound* sound) void AUD_unload(AUD_Sound* sound)
{ {
assert(sound); assert(sound);

View File

@@ -149,6 +149,13 @@ extern AUD_Sound* AUD_loopSound(AUD_Sound* sound);
*/ */
extern int AUD_stopLoop(AUD_Handle* handle); extern int AUD_stopLoop(AUD_Handle* handle);
/**
* Rectifies a sound.
* \param sound The sound to rectify.
* \return A handle of the rectified sound.
*/
extern AUD_Sound* AUD_rectifySound(AUD_Sound* sound);
/** /**
* Unloads a sound of any type. * Unloads a sound of any type.
* \param sound The handle of the sound. * \param sound The handle of the sound.

View File

@@ -500,3 +500,43 @@ void AUD_volume_adjust_s24_be(sample_t* target, sample_t* source,
} }
} }
void AUD_rectify_u8(sample_t* target, sample_t* source, int count)
{
for(int i=0; i<count; i++)
target[i] = source[i] < 0x80 ? 0x0100 - source[i] : source[i];
}
void AUD_rectify_s24_le(sample_t* target, sample_t* source, int count)
{
count *= 3;
int value;
for(int i=0; i<count; i+=3)
{
value = source[i+2] << 16 | source[i+1] << 8 | source[i];
value |= (((value & 0x800000) >> 23) * 255) << 24;
if(value < 0)
value = -value;
target[i+2] = value >> 16;
target[i+1] = value >> 8;
target[i] = value;
}
}
void AUD_rectify_s24_be(sample_t* target, sample_t* source, int count)
{
count *= 3;
int value;
for(int i=0; i < count; i+=3)
{
value = source[i] << 16 | source[i+1] << 8 | source[i+2];
value |= (((value & 0x800000) >> 23) * 255) << 24;
if(value < 0)
value = -value;
target[i] = value >> 16;
target[i+1] = value >> 8;
target[i+2] = value;
}
}

View File

@@ -46,6 +46,8 @@ typedef void (*AUD_convert_f)(sample_t* target, sample_t* source, int length);
typedef void (*AUD_volume_adjust_f)(sample_t* target, sample_t* source, typedef void (*AUD_volume_adjust_f)(sample_t* target, sample_t* source,
int count, float volume); int count, float volume);
typedef void (*AUD_rectify_f)(sample_t* target, sample_t* source, int count);
template <class T> template <class T>
void AUD_convert_copy(sample_t* target, sample_t* source, int length) void AUD_convert_copy(sample_t* target, sample_t* source, int length)
{ {
@@ -153,4 +155,19 @@ void AUD_volume_adjust_s24_le(sample_t* target, sample_t* source,
void AUD_volume_adjust_s24_be(sample_t* target, sample_t* source, void AUD_volume_adjust_s24_be(sample_t* target, sample_t* source,
int count, float volume); int count, float volume);
template <class T>
void AUD_rectify(sample_t* target, sample_t* source, int count)
{
T* t = (T*)target;
T* s = (T*)source;
for(int i=0; i < count; i++)
t[i] = s[i] < 0 ? -s[i] : s[i];
}
void AUD_rectify_u8(sample_t* target, sample_t* source, int count);
void AUD_rectify_s24_le(sample_t* target, sample_t* source, int count);
void AUD_rectify_s24_be(sample_t* target, sample_t* source, int count);
#endif //AUD_CONVERTERFUNCTIONS #endif //AUD_CONVERTERFUNCTIONS

View File

@@ -59,9 +59,10 @@ endif
ifeq ($(WITH_SNDFILE),true) ifeq ($(WITH_SNDFILE),true)
CPPFLAGS += -DWITH_SNDFILE CPPFLAGS += -DWITH_SNDFILE
CPPFLAGS += -I../sndfile CPPFLAGS += -I../sndfile
CPPFLAGS += -I$(NAN_SNDFILE)/include
endif endif
CPPFLAGS += -I$(LCGDIR)/samplerate/include/ CPPFLAGS += -I$(NAN_SAMPLERATE)/include/
CPPFLAGS += -I../ffmpeg CPPFLAGS += -I../ffmpeg
CPPFLAGS += -I../FX CPPFLAGS += -I../FX
CPPFLAGS += -I../SDL CPPFLAGS += -I../SDL

View File

@@ -44,7 +44,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="2" Optimization="2"
InlineFunctionExpansion="2" InlineFunctionExpansion="2"
AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include" AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include;..\..\..\..\..\lib\windows\fftw3\include"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL" PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
@@ -118,7 +118,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include" AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include;..\..\..\..\..\lib\windows\fftw3\include"
PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL" PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
@@ -193,7 +193,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
InlineFunctionExpansion="2" InlineFunctionExpansion="2"
AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include" AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include;..\..\..\..\..\lib\windows\fftw3\include"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL" PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
StringPooling="true" StringPooling="true"
RuntimeLibrary="2" RuntimeLibrary="2"
@@ -267,7 +267,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include" AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include;..\..\..\..\..\lib\windows\fftw3\include"
PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL" PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
@@ -629,6 +629,22 @@
RelativePath="..\..\FX\AUD_PitchReader.h" RelativePath="..\..\FX\AUD_PitchReader.h"
> >
</File> </File>
<File
RelativePath="..\..\FX\AUD_RectifyFactory.cpp"
>
</File>
<File
RelativePath="..\..\FX\AUD_RectifyFactory.h"
>
</File>
<File
RelativePath="..\..\FX\AUD_RectifyReader.cpp"
>
</File>
<File
RelativePath="..\..\FX\AUD_RectifyReader.h"
>
</File>
<File <File
RelativePath="..\..\FX\AUD_ReverseFactory.cpp" RelativePath="..\..\FX\AUD_ReverseFactory.cpp"
> >
@@ -762,6 +778,26 @@
> >
</File> </File>
</Filter> </Filter>
<Filter
Name="fftw"
>
<File
RelativePath="..\..\fftw\AUD_BandPassFactory.cpp"
>
</File>
<File
RelativePath="..\..\fftw\AUD_BandPassFactory.h"
>
</File>
<File
RelativePath="..\..\fftw\AUD_BandPassReader.cpp"
>
</File>
<File
RelativePath="..\..\fftw\AUD_BandPassReader.h"
>
</File>
</Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>

View File

@@ -35,6 +35,7 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_SNDFILE)/include
CPPFLAGS += -I../intern CPPFLAGS += -I../intern
CPPFLAGS += -I.. CPPFLAGS += -I..
CPPFLAGS += -I. CPPFLAGS += -I.

View File

@@ -283,8 +283,12 @@ sgstrf (superlu_options_t *options, SuperMatrix *A,
* -------------------------------------- */ * -------------------------------------- */
/* Determine the union of the row structure of the snode */ /* Determine the union of the row structure of the snode */
if ( (*info = ssnode_dfs(jcol, kcol, asub, xa_begin, xa_end, if ( (*info = ssnode_dfs(jcol, kcol, asub, xa_begin, xa_end,
xprune, marker, &Glu)) != 0 ) xprune, marker, &Glu)) != 0 ) {
if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r);
SUPERLU_FREE (iperm_c);
SUPERLU_FREE (relax_end);
return; return;
}
nextu = xusub[jcol]; nextu = xusub[jcol];
nextlu = xlusup[jcol]; nextlu = xlusup[jcol];
@@ -293,9 +297,13 @@ sgstrf (superlu_options_t *options, SuperMatrix *A,
new_next = nextlu + (xlsub[fsupc+1]-xlsub[fsupc])*(kcol-jcol+1); new_next = nextlu + (xlsub[fsupc+1]-xlsub[fsupc])*(kcol-jcol+1);
nzlumax = Glu.nzlumax; nzlumax = Glu.nzlumax;
while ( new_next > nzlumax ) { while ( new_next > nzlumax ) {
if ( (*info = sLUMemXpand(jcol, nextlu, LUSUP, &nzlumax, &Glu)) ) if ( (*info = sLUMemXpand(jcol, nextlu, LUSUP, &nzlumax, &Glu)) ) {
if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r);
SUPERLU_FREE (iperm_c);
SUPERLU_FREE (relax_end);
return; return;
} }
}
for (icol = jcol; icol<= kcol; icol++) { for (icol = jcol; icol<= kcol; icol++) {
xusub[icol+1] = nextu; xusub[icol+1] = nextu;
@@ -350,17 +358,31 @@ sgstrf (superlu_options_t *options, SuperMatrix *A,
if ((*info = scolumn_dfs(m, jj, perm_r, &nseg, &panel_lsub[k], if ((*info = scolumn_dfs(m, jj, perm_r, &nseg, &panel_lsub[k],
segrep, &repfnz[k], xprune, marker, segrep, &repfnz[k], xprune, marker,
parent, xplore, &Glu)) != 0) return; parent, xplore, &Glu)) != 0) {
if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r);
SUPERLU_FREE (iperm_c);
SUPERLU_FREE (relax_end);
return;
}
/* Numeric updates */ /* Numeric updates */
if ((*info = scolumn_bmod(jj, (nseg - nseg1), &dense[k], if ((*info = scolumn_bmod(jj, (nseg - nseg1), &dense[k],
tempv, &segrep[nseg1], &repfnz[k], tempv, &segrep[nseg1], &repfnz[k],
jcol, &Glu, stat)) != 0) return; jcol, &Glu, stat)) != 0) {
if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r);
SUPERLU_FREE (iperm_c);
SUPERLU_FREE (relax_end);
return;
}
/* Copy the U-segments to ucol[*] */ /* Copy the U-segments to ucol[*] */
if ((*info = scopy_to_ucol(jj, nseg, segrep, &repfnz[k], if ((*info = scopy_to_ucol(jj, nseg, segrep, &repfnz[k],
perm_r, &dense[k], &Glu)) != 0) perm_r, &dense[k], &Glu)) != 0) {
if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r);
SUPERLU_FREE (iperm_c);
SUPERLU_FREE (relax_end);
return; return;
}
if ( (*info = spivotL(jj, diag_pivot_thresh, &usepr, perm_r, if ( (*info = spivotL(jj, diag_pivot_thresh, &usepr, perm_r,
iperm_r, iperm_c, &pivrow, &Glu, stat)) ) iperm_r, iperm_c, &pivrow, &Glu, stat)) )
@@ -429,5 +451,4 @@ sgstrf (superlu_options_t *options, SuperMatrix *A,
if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r); if ( iperm_r_allocated ) SUPERLU_FREE (iperm_r);
SUPERLU_FREE (iperm_c); SUPERLU_FREE (iperm_c);
SUPERLU_FREE (relax_end); SUPERLU_FREE (relax_end);
} }

View File

@@ -415,6 +415,10 @@
RelativePath="..\..\..\source\blender\editors\interface\interface_layout.c" RelativePath="..\..\..\source\blender\editors\interface\interface_layout.c"
> >
</File> </File>
<File
RelativePath="..\..\..\source\blender\editors\interface\interface_ops.c"
>
</File>
<File <File
RelativePath="..\..\..\source\blender\editors\interface\interface_panel.c" RelativePath="..\..\..\source\blender\editors\interface\interface_panel.c"
> >

View File

@@ -1126,23 +1126,21 @@ class Export3DS(bpy.types.Operator):
def execute(self, context): def execute(self, context):
save_3ds(self.properties.path, context) save_3ds(self.properties.path, context)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
def poll(self, context): # Poll isnt working yet def poll(self, context): # Poll isnt working yet
return context.active_object != None return context.active_object != None
bpy.ops.add(Export3DS) bpy.types.register(Export3DS)
# Add to a menu # Add to a menu
import dynamic_menu
def menu_func(self, context): def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".3ds") default_path = bpy.data.filename.replace(".blend", ".3ds")
self.layout.operator(Export3DS.bl_idname, text="Autodesk 3DS...").path = default_path self.layout.operator(Export3DS.bl_idname, text="Autodesk 3DS...").path = default_path
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) bpy.types.INFO_MT_file_export.append(menu_func)

View File

@@ -651,8 +651,8 @@ def write(filename, batch_objects = None, \
}''' % (curtime)) }''' % (curtime))
file.write('\nCreationTime: "%.4i-%.2i-%.2i %.2i:%.2i:%.2i:000"' % curtime) file.write('\nCreationTime: "%.4i-%.2i-%.2i %.2i:%.2i:%.2i:000"' % curtime)
file.write('\nCreator: "Blender3D version 2.5"') file.write('\nCreator: "Blender3D version %s"' % bpy.version_string)
# file.write('\nCreator: "Blender3D version %.2f"' % Blender.Get('version'))
pose_items = [] # list of (fbxName, matrix) to write pose data for, easier to collect allong the way pose_items = [] # list of (fbxName, matrix) to write pose data for, easier to collect allong the way
@@ -3426,15 +3426,15 @@ class ExportFBX(bpy.types.Operator):
self.properties.BATCH_FILE_PREFIX, self.properties.BATCH_FILE_PREFIX,
self.properties.BATCH_OWN_DIR) self.properties.BATCH_OWN_DIR)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
bpy.ops.add(ExportFBX) bpy.types.register(ExportFBX)
# if __name__ == "__main__": # if __name__ == "__main__":
# bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply") # bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply")
@@ -3462,13 +3462,8 @@ bpy.ops.add(ExportFBX)
# SMALL or COSMETICAL # SMALL or COSMETICAL
# - find a way to get blender version, and put it in bpy.util?, old was Blender.Get('version') # - find a way to get blender version, and put it in bpy.util?, old was Blender.Get('version')
# Add to a menu
import dynamic_menu
def menu_func(self, context): def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".fbx") default_path = bpy.data.filename.replace(".blend", ".fbx")
self.layout.operator(ExportFBX.bl_idname, text="Autodesk FBX...").path = default_path self.layout.operator(ExportFBX.bl_idname, text="Autodesk FBX...").path = default_path
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) menu_item = bpy.types.INFO_MT_file_export.append(menu_func)

View File

@@ -159,7 +159,7 @@ class ExportMDD(bpy.types.Operator):
# List of operator properties, the attributes will be assigned # List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling. # to the class instance from the operator settings before calling.
path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen= 1024, default= "") path = StringProperty(name="File Path", description="File path used for exporting the MDD file", maxlen=1024)
fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25) fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25)
start_frame = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1) start_frame = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1)
end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250) end_frame = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250)
@@ -173,24 +173,21 @@ class ExportMDD(bpy.types.Operator):
raise Exception("filename not set") raise Exception("filename not set")
write(self.properties.path, context.scene, context.active_object, write(self.properties.path, context.scene, context.active_object,
self.properties.start_frame, self.properties.end_frame, self.properties.fps) self.properties.start_frame, self.properties.end_frame, self.properties.fps)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
bpy.ops.add(ExportMDD) bpy.types.register(ExportMDD)
# Add to a menu
import dynamic_menu
def menu_func(self, context): def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".mdd") default_path = bpy.data.filename.replace(".blend", ".mdd")
self.layout.operator(ExportMDD.bl_idname, text="Vertex Keyframe Animation (.mdd)...").path = default_path self.layout.operator(ExportMDD.bl_idname, text="Vertex Keyframe Animation (.mdd)...").path = default_path
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) bpy.types.INFO_MT_file_export.append(menu_func)
if __name__ == '__main__': if __name__ == '__main__':
bpy.ops.export.mdd(path="/tmp/test.mdd") bpy.ops.export.mdd(path="/tmp/test.mdd")

View File

@@ -40,29 +40,6 @@ All objects that can be represented as a mesh (mesh, curve, metaball, surface, t
will be exported as mesh data. will be exported as mesh data.
""" """
# --------------------------------------------------------------------------
# OBJ Export v1.1 by Campbell Barton (AKA Ideasman)
# --------------------------------------------------------------------------
# ***** 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 LICENCE BLOCK *****
# --------------------------------------------------------------------------
# import math and other in functions that use them for the sake of fast Blender startup # import math and other in functions that use them for the sake of fast Blender startup
# import math # import math
import os import os
@@ -384,8 +361,7 @@ def write(filename, objects, scene,
file = open(filename, "w") file = open(filename, "w")
# Write Header # Write Header
version = "2.5" file.write('# Blender3D v%s OBJ File: %s\n' % (bpy.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
file.write('# Blender3D v%s OBJ File: %s\n' % (version, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
file.write('# www.blender3d.org\n') file.write('# www.blender3d.org\n')
# Tell the obj file what material file to use. # Tell the obj file what material file to use.
@@ -444,7 +420,7 @@ def write(filename, objects, scene,
me = ob.create_mesh(EXPORT_APPLY_MODIFIERS, 'PREVIEW') me = ob.create_mesh(EXPORT_APPLY_MODIFIERS, 'PREVIEW')
if EXPORT_ROTX90: if EXPORT_ROTX90:
me.transform(ob_mat * mat_xrot90) me.transform(mat_xrot90 * ob_mat)
else: else:
me.transform(ob_mat) me.transform(ob_mat)
@@ -980,26 +956,20 @@ class ExportOBJ(bpy.types.Operator):
EXPORT_SEL_ONLY=self.properties.use_selection, EXPORT_SEL_ONLY=self.properties.use_selection,
EXPORT_ALL_SCENES=self.properties.use_all_scenes) EXPORT_ALL_SCENES=self.properties.use_all_scenes)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
bpy.types.register(ExportOBJ)
bpy.ops.add(ExportOBJ)
import dynamic_menu
def menu_func(self, context): def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".obj") default_path = bpy.data.filename.replace(".blend", ".obj")
self.layout.operator(ExportOBJ.bl_idname, text="Wavefront (.obj)...").path = default_path self.layout.operator(ExportOBJ.bl_idname, text="Wavefront (.obj)...").path = default_path
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) menu_item = bpy.types.INFO_MT_file_export.append(menu_func)
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.EXPORT_OT_obj(filename="/tmp/test.obj") bpy.ops.EXPORT_OT_obj(filename="/tmp/test.obj")

View File

@@ -205,8 +205,7 @@ def write(filename, scene, ob, \
file.write('ply\n') file.write('ply\n')
file.write('format ascii 1.0\n') file.write('format ascii 1.0\n')
version = "2.5" # Blender.Get('version') file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (bpy.version_string, bpy.data.filename.split('/')[-1].split('\\')[-1]))
file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (version, bpy.data.filename.split('/')[-1].split('\\')[-1]))
file.write('element vertex %d\n' % len(ply_verts)) file.write('element vertex %d\n' % len(ply_verts))
@@ -297,12 +296,12 @@ class ExportPLY(bpy.types.Operator):
EXPORT_COLORS=self.properties.use_colors, EXPORT_COLORS=self.properties.use_colors,
) )
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -316,16 +315,15 @@ class ExportPLY(bpy.types.Operator):
row.prop(props, "use_colors") row.prop(props, "use_colors")
bpy.ops.add(ExportPLY) bpy.types.register(ExportPLY)
import dynamic_menu
def menu_func(self, context): def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".ply") default_path = bpy.data.filename.replace(".blend", ".ply")
self.layout.operator(ExportPLY.bl_idname, text="Stanford (.ply)...").path = default_path self.layout.operator(ExportPLY.bl_idname, text="Stanford (.ply)...").path = default_path
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) bpy.types.INFO_MT_file_export.append(menu_func)
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.export.ply(path="/tmp/test.ply") bpy.ops.export.ply(path="/tmp/test.ply")

View File

@@ -1233,22 +1233,21 @@ class ExportX3D(bpy.types.Operator):
def execute(self, context): def execute(self, context):
x3d_export(self.properties.path, context, self.properties.apply_modifiers, self.properties.triangulate, self.properties.compress) x3d_export(self.properties.path, context, self.properties.apply_modifiers, self.properties.triangulate, self.properties.compress)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
bpy.ops.add(ExportX3D) bpy.types.register(ExportX3D)
import dynamic_menu
def menu_func(self, context): def menu_func(self, context):
default_path = bpy.data.filename.replace(".blend", ".x3d") default_path = bpy.data.filename.replace(".blend", ".x3d")
self.layout.operator(ExportX3D.bl_idname, text="X3D Extensible 3D (.x3d)...").path = default_path self.layout.operator(ExportX3D.bl_idname, text="X3D Extensible 3D (.x3d)...").path = default_path
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) bpy.types.INFO_MT_file_export.append(menu_func)
# NOTES # NOTES
# - blender version is hardcoded # - blender version is hardcoded

View File

@@ -887,17 +887,15 @@ class BvhImporter(bpy.types.Operator):
read_bvh(context, self.properties.path) read_bvh(context, self.properties.path)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
bpy.ops.add(BvhImporter) bpy.types.register(BvhImporter)
import dynamic_menu
menu_func = lambda self, context: self.layout.operator(BvhImporter.bl_idname, text="Motion Capture (.bvh)...") menu_func = lambda self, context: self.layout.operator(BvhImporter.bl_idname, text="Motion Capture (.bvh)...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_import, menu_func) bpy.types.INFO_MT_file_import.append(menu_func)

View File

@@ -1151,7 +1151,7 @@ class IMPORT_OT_autodesk_3ds(bpy.types.Operator):
# List of operator properties, the attributes will be assigned # List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling. # to the class instance from the operator settings before calling.
path = StringProperty(name="File Path", description="File path used for importing the 3DS file", maxlen= 1024, default= ""), path = StringProperty(name="File Path", description="File path used for importing the 3DS file", maxlen= 1024, default= "")
# size_constraint = FloatProperty(name="Size Constraint", description="Scale the model by 10 until it reacehs the size constraint. Zero Disables.", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=10.0), # size_constraint = FloatProperty(name="Size Constraint", description="Scale the model by 10 until it reacehs the size constraint. Zero Disables.", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=10.0),
# search_images = BoolProperty(name="Image Search", description="Search subdirectories for any assosiated images (Warning, may be slow)", default=True), # search_images = BoolProperty(name="Image Search", description="Search subdirectories for any assosiated images (Warning, may be slow)", default=True),
@@ -1159,19 +1159,18 @@ class IMPORT_OT_autodesk_3ds(bpy.types.Operator):
def execute(self, context): def execute(self, context):
load_3ds(self.properties.path, context, 0.0, False, False) load_3ds(self.properties.path, context, 0.0, False, False)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
bpy.ops.add(IMPORT_OT_autodesk_3ds) bpy.types.register(IMPORT_OT_autodesk_3ds)
import dynamic_menu
menu_func = lambda self, context: self.layout.operator(IMPORT_OT_autodesk_3ds.bl_idname, text="3D Studio (.3ds)...") menu_func = lambda self, context: self.layout.operator(IMPORT_OT_autodesk_3ds.bl_idname, text="3D Studio (.3ds)...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_import, menu_func) bpy.types.INFO_MT_file_import.append(menu_func)
# NOTES: # NOTES:
# why add 1 extra vertex? and remove it when done? # why add 1 extra vertex? and remove it when done? - "Answer - eekadoodle - would need to re-order UV's without this since face order isnt always what we give blender, BMesh will solve :D"
# disabled scaling to size, this requires exposing bb (easy) and understanding how it works (needs some time) # disabled scaling to size, this requires exposing bb (easy) and understanding how it works (needs some time)

View File

@@ -1616,20 +1616,19 @@ class IMPORT_OT_obj(bpy.types.Operator):
self.properties.IMAGE_SEARCH, self.properties.IMAGE_SEARCH,
self.properties.POLYGROUPS) self.properties.POLYGROUPS)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
bpy.ops.add(IMPORT_OT_obj) bpy.types.register(IMPORT_OT_obj)
import dynamic_menu
menu_func = lambda self, context: self.layout.operator(IMPORT_OT_obj.bl_idname, text="Wavefront (.obj)...") menu_func = lambda self, context: self.layout.operator(IMPORT_OT_obj.bl_idname, text="Wavefront (.obj)...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_import, menu_func) menu_item = bpy.types.INFO_MT_file_import.append(menu_func)
# NOTES (all line numbers refer to 2.4x import_obj.py, not this file) # NOTES (all line numbers refer to 2.4x import_obj.py, not this file)

View File

@@ -26,7 +26,7 @@ from netrender.utils import *
import netrender.client as client import netrender.client as client
import netrender.model import netrender.model
@rnaOperator @rnaType
class RENDER_OT_netslave_bake(bpy.types.Operator): class RENDER_OT_netslave_bake(bpy.types.Operator):
'''NEED DESCRIPTION''' '''NEED DESCRIPTION'''
bl_idname = "render.netslavebake" bl_idname = "render.netslavebake"
@@ -79,12 +79,12 @@ class RENDER_OT_netslave_bake(bpy.types.Operator):
#bpy.ops.wm.save_mainfile(path = path + os.sep + root + "_baked.blend") #bpy.ops.wm.save_mainfile(path = path + os.sep + root + "_baked.blend")
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientanim(bpy.types.Operator): class RENDER_OT_netclientanim(bpy.types.Operator):
'''Start rendering an animation on network''' '''Start rendering an animation on network'''
bl_idname = "render.netclientanim" bl_idname = "render.netclientanim"
@@ -106,12 +106,12 @@ class RENDER_OT_netclientanim(bpy.types.Operator):
bpy.ops.screen.render('INVOKE_AREA', animation=True) bpy.ops.screen.render('INVOKE_AREA', animation=True)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientsend(bpy.types.Operator): class RENDER_OT_netclientsend(bpy.types.Operator):
'''Send Render Job to the Network''' '''Send Render Job to the Network'''
bl_idname = "render.netclientsend" bl_idname = "render.netclientsend"
@@ -136,12 +136,12 @@ class RENDER_OT_netclientsend(bpy.types.Operator):
self.report('ERROR', str(err)) self.report('ERROR', str(err))
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientstatus(bpy.types.Operator): class RENDER_OT_netclientstatus(bpy.types.Operator):
'''Refresh the status of the current jobs''' '''Refresh the status of the current jobs'''
bl_idname = "render.netclientstatus" bl_idname = "render.netclientstatus"
@@ -176,12 +176,12 @@ class RENDER_OT_netclientstatus(bpy.types.Operator):
job.name = j.name job.name = j.name
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientblacklistslave(bpy.types.Operator): class RENDER_OT_netclientblacklistslave(bpy.types.Operator):
'''Operator documentation text, will be used for the operator tooltip and python docs.''' '''Operator documentation text, will be used for the operator tooltip and python docs.'''
bl_idname = "render.netclientblacklistslave" bl_idname = "render.netclientblacklistslave"
@@ -206,12 +206,12 @@ class RENDER_OT_netclientblacklistslave(bpy.types.Operator):
netsettings.slaves.remove(netsettings.active_slave_index) netsettings.slaves.remove(netsettings.active_slave_index)
netsettings.active_slave_index = -1 netsettings.active_slave_index = -1
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientwhitelistslave(bpy.types.Operator): class RENDER_OT_netclientwhitelistslave(bpy.types.Operator):
'''Operator documentation text, will be used for the operator tooltip and python docs.''' '''Operator documentation text, will be used for the operator tooltip and python docs.'''
bl_idname = "render.netclientwhitelistslave" bl_idname = "render.netclientwhitelistslave"
@@ -236,13 +236,13 @@ class RENDER_OT_netclientwhitelistslave(bpy.types.Operator):
netsettings.slaves_blacklist.remove(netsettings.active_blacklisted_slave_index) netsettings.slaves_blacklist.remove(netsettings.active_blacklisted_slave_index)
netsettings.active_blacklisted_slave_index = -1 netsettings.active_blacklisted_slave_index = -1
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientslaves(bpy.types.Operator): class RENDER_OT_netclientslaves(bpy.types.Operator):
'''Refresh status about available Render slaves''' '''Refresh status about available Render slaves'''
bl_idname = "render.netclientslaves" bl_idname = "render.netclientslaves"
@@ -282,12 +282,12 @@ class RENDER_OT_netclientslaves(bpy.types.Operator):
slave = netsettings.slaves[-1] slave = netsettings.slaves[-1]
slave.name = s.name slave.name = s.name
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientcancel(bpy.types.Operator): class RENDER_OT_netclientcancel(bpy.types.Operator):
'''Cancel the selected network rendering job.''' '''Cancel the selected network rendering job.'''
bl_idname = "render.netclientcancel" bl_idname = "render.netclientcancel"
@@ -311,12 +311,12 @@ class RENDER_OT_netclientcancel(bpy.types.Operator):
netsettings.jobs.remove(netsettings.active_job_index) netsettings.jobs.remove(netsettings.active_job_index)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class RENDER_OT_netclientcancelall(bpy.types.Operator): class RENDER_OT_netclientcancelall(bpy.types.Operator):
'''Cancel all running network rendering jobs.''' '''Cancel all running network rendering jobs.'''
bl_idname = "render.netclientcancelall" bl_idname = "render.netclientcancelall"
@@ -338,12 +338,12 @@ class RENDER_OT_netclientcancelall(bpy.types.Operator):
while(len(netsettings.jobs) > 0): while(len(netsettings.jobs) > 0):
netsettings.jobs.remove(0) netsettings.jobs.remove(0)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class netclientdownload(bpy.types.Operator): class netclientdownload(bpy.types.Operator):
'''Download render results from the network''' '''Download render results from the network'''
bl_idname = "render.netclientdownload" bl_idname = "render.netclientdownload"
@@ -383,13 +383,14 @@ class netclientdownload(bpy.types.Operator):
conn.close() conn.close()
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class netclientscan(bpy.types.Operator): class netclientscan(bpy.types.Operator):
__slots__ = []
'''Operator documentation text, will be used for the operator tooltip and python docs.''' '''Operator documentation text, will be used for the operator tooltip and python docs.'''
bl_idname = "render.netclientscan" bl_idname = "render.netclientscan"
bl_label = "Client Scan" bl_label = "Client Scan"
@@ -406,19 +407,21 @@ class netclientscan(bpy.types.Operator):
netsettings.server_address = address netsettings.server_address = address
netsettings.server_port = port netsettings.server_port = port
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
print(dir(self))
return self.execute(context) return self.execute(context)
@rnaOperator @rnaType
class netclientweb(bpy.types.Operator): class netclientweb(bpy.types.Operator):
'''Open new window with information about running rendering jobs''' '''Open new window with information about running rendering jobs'''
bl_idname = "render.netclientweb" bl_idname = "render.netclientweb"
bl_label = "Open Master Monitor" bl_label = "Open Master Monitor"
def poll(self, context): def poll(self, context):
return True netsettings = context.scene.network_render
return netsettings.server_address != "[default]"
def execute(self, context): def execute(self, context):
netsettings = context.scene.network_render netsettings = context.scene.network_render
@@ -432,7 +435,7 @@ class netclientweb(bpy.types.Operator):
webbrowser.open("http://%s:%i" % (netsettings.server_address, netsettings.server_port)) webbrowser.open("http://%s:%i" % (netsettings.server_address, netsettings.server_port))
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
return self.execute(context) return self.execute(context)

View File

@@ -78,6 +78,8 @@ class RENDER_PT_network_settings(RenderButtonsPanel):
else: else:
col.operator("render.netclientscan", icon='FILE_REFRESH', text="") col.operator("render.netclientscan", icon='FILE_REFRESH', text="")
col.operator("render.netclientweb", icon='QUESTION')
@rnaType @rnaType
class RENDER_PT_network_job(RenderButtonsPanel): class RENDER_PT_network_job(RenderButtonsPanel):
bl_label = "Job Settings" bl_label = "Job Settings"
@@ -104,7 +106,6 @@ class RENDER_PT_network_job(RenderButtonsPanel):
col.operator("render.netclientsend", icon='FILE_BLEND') col.operator("render.netclientsend", icon='FILE_BLEND')
if scene.network_render.job_id: if scene.network_render.job_id:
col.operator("screen.render", text="Get Results", icon='RENDER_ANIMATION').animation = True col.operator("screen.render", text="Get Results", icon='RENDER_ANIMATION').animation = True
col.operator("render.netclientweb", icon='QUESTION')
col.prop(scene.network_render, "job_name") col.prop(scene.network_render, "job_name")
col.prop(scene.network_render, "job_category") col.prop(scene.network_render, "job_category")
row = col.row() row = col.row()

View File

@@ -61,10 +61,6 @@ def rnaType(rna_type):
if bpy: bpy.types.register(rna_type) if bpy: bpy.types.register(rna_type)
return rna_type return rna_type
def rnaOperator(rna_op):
if bpy: bpy.ops.add(rna_op)
return rna_op
def reporting(report, message, errorType = None): def reporting(report, message, errorType = None):
if errorType: if errorType:
t = 'ERROR' t = 'ERROR'

View File

@@ -85,7 +85,6 @@ def _main():
# a bit nasty but this prevents help() and input() from locking blender # a bit nasty but this prevents help() and input() from locking blender
# Ideally we could have some way for the console to replace sys.stdin but # Ideally we could have some way for the console to replace sys.stdin but
# python would lock blender while waiting for a return value, not easy :| # python would lock blender while waiting for a return value, not easy :|
import sys
sys.stdin = None sys.stdin = None
# if "-d" in sys.argv: # Enable this to measure startup speed # if "-d" in sys.argv: # Enable this to measure startup speed
@@ -100,4 +99,10 @@ def _main():
else: else:
load_scripts() load_scripts()
# constants
version = _bpy._VERSION
version_string = _bpy._VERSION_STR
home = _bpy._HOME
_main() _main()

View File

@@ -21,7 +21,7 @@
# for slightly faster access # for slightly faster access
from _bpy import ops as ops_module from _bpy import ops as ops_module
op_add = ops_module.add # op_add = ops_module.add
op_remove = ops_module.remove op_remove = ops_module.remove
op_add_macro = ops_module.add_macro op_add_macro = ops_module.add_macro
op_dir = ops_module.dir op_dir = ops_module.dir

View File

@@ -42,25 +42,27 @@ class Object(bpy_types.ID):
@property @property
def children(self): def children(self):
"""All the children of this object"""
import bpy import bpy
return [child for child in bpy.data.objects if child.parent == self] return [child for child in bpy.data.objects if child.parent == self]
class _GenericBone: class _GenericBone:
''' """
functions for bones, common between Armature/Pose/Edit bones. functions for bones, common between Armature/Pose/Edit bones.
internal subclassing use only. internal subclassing use only.
''' """
__slots__ = () __slots__ = ()
def translate(self, vec): def translate(self, vec):
"""Utility function to add *vec* to the head and tail of this bone."""
self.head += vec self.head += vec
self.tail += vec self.tail += vec
def parent_index(self, parent_test): def parent_index(self, parent_test):
''' """
The same as 'bone in other_bone.parent_recursive' but saved generating a list. The same as 'bone in other_bone.parent_recursive' but saved generating a list.
''' """
# use the name so different types can be tested. # use the name so different types can be tested.
name = parent_test.name name = parent_test.name
@@ -76,11 +78,13 @@ class _GenericBone:
@property @property
def basename(self): def basename(self):
"""The name of this bone before any '.' character"""
#return self.name.rsplit(".", 1)[0] #return self.name.rsplit(".", 1)[0]
return self.name.split(".")[0] return self.name.split(".")[0]
@property @property
def parent_recursive(self): def parent_recursive(self):
"""A list of parents, starting with the immediate parent"""
parent_list = [] parent_list = []
parent = self.parent parent = self.parent
@@ -94,23 +98,26 @@ class _GenericBone:
@property @property
def length(self): def length(self):
"""The distance from head to tail, when set the head is moved to fit the length."""
return self.vector.length return self.vector.length
@length.setter @length.setter
def length(self, value): def length(self, value):
"""The distance from head to tail"""
self.tail = self.head + ((self.tail - self.head).normalize() * value) self.tail = self.head + ((self.tail - self.head).normalize() * value)
@property @property
def vector(self): def vector(self):
"""The direction this bone is pointing. Utility function for (tail - head)"""
return (self.tail - self.head) return (self.tail - self.head)
@property @property
def children(self): def children(self):
"""A list of all the bones children."""
return [child for child in self._other_bones if child.parent == self] return [child for child in self._other_bones if child.parent == self]
@property @property
def children_recursive(self): def children_recursive(self):
"""a list of all children from this bone."""
bones_children = [] bones_children = []
for bone in self._other_bones: for bone in self._other_bones:
index = bone.parent_index(self) index = bone.parent_index(self)
@@ -123,10 +130,11 @@ class _GenericBone:
@property @property
def children_recursive_basename(self): def children_recursive_basename(self):
''' """
Returns a chain of children with the same base name as this bone Returns a chain of children with the same base name as this bone
Only direct chains are supported, forks caused by multiple children with matching basenames will. Only direct chains are supported, forks caused by multiple children with matching basenames will
''' terminate the function and not be returned.
"""
basename = self.basename basename = self.basename
chain = [] chain = []
@@ -177,10 +185,10 @@ class EditBone(StructRNA, _GenericBone):
__slots__ = () __slots__ = ()
def align_orientation(self, other): def align_orientation(self, other):
''' """
Align this bone to another by moving its tail and settings its roll Align this bone to another by moving its tail and settings its roll
the length of the other bone is not used. the length of the other bone is not used.
''' """
vec = other.vector.normalize() * self.length vec = other.vector.normalize() * self.length
self.tail = self.head + vec self.tail = self.head + vec
self.roll = other.roll self.roll = other.roll
@@ -196,10 +204,10 @@ class Mesh(bpy_types.ID):
__slots__ = () __slots__ = ()
def from_pydata(self, verts, edges, faces): def from_pydata(self, verts, edges, faces):
''' """
Make a mesh from a list of verts/edges/faces Make a mesh from a list of verts/edges/faces
Until we have a nicer way to make geometry, use this. Until we have a nicer way to make geometry, use this.
''' """
self.add_geometry(len(verts), len(edges), len(faces)) self.add_geometry(len(verts), len(edges), len(faces))
verts_flat = [f for v in verts for f in v] verts_flat = [f for v in verts for f in v]
@@ -244,7 +252,7 @@ class Mesh(bpy_types.ID):
return [edge_face_count_dict.get(ed.key, 0) for ed in mesh.edges] return [edge_face_count_dict.get(ed.key, 0) for ed in mesh.edges]
def edge_loops(self, faces=None, seams=()): def edge_loops(self, faces=None, seams=()):
''' """
Edge loops defined by faces Edge loops defined by faces
Takes me.faces or a list of faces and returns the edge loops Takes me.faces or a list of faces and returns the edge loops
@@ -255,7 +263,7 @@ class Mesh(bpy_types.ID):
[ [(0,1), (4, 8), (3,8)], ...] [ [(0,1), (4, 8), (3,8)], ...]
optionaly, seams are edge keys that will be removed optionaly, seams are edge keys that will be removed
''' """
OTHER_INDEX = 2, 3, 0, 1 # opposite face index OTHER_INDEX = 2, 3, 0, 1 # opposite face index
@@ -372,6 +380,33 @@ class Macro(StructRNA, metaclass=OrderedMeta):
class Menu(StructRNA): class Menu(StructRNA):
__slots__ = () __slots__ = ()
@classmethod
def _dyn_menu_initialize(cls):
draw_funcs = getattr(cls.draw, "_draw_funcs", None)
if draw_funcs is None:
def draw_ls(*args):
for func in draw_ls._draw_funcs:
func(*args)
draw_funcs = draw_ls._draw_funcs = [cls.draw]
cls.draw = draw_ls
return draw_funcs
@classmethod
def append(cls, draw_func):
"""Prepend an draw function to this menu, takes the same arguments as the menus draw function."""
draw_funcs = cls._dyn_menu_initialize()
draw_funcs.append(draw_func)
@classmethod
def prepend(cls, draw_func):
"""Prepend a draw function to this menu, takes the same arguments as the menus draw function."""
draw_funcs = cls._dyn_menu_initialize()
draw_funcs.insert(0, draw_func)
def path_menu(self, searchpaths, operator): def path_menu(self, searchpaths, operator):
layout = self.layout layout = self.layout
# hard coded to set the operators 'path' to the filename. # hard coded to set the operators 'path' to the filename.
@@ -396,9 +431,9 @@ class Menu(StructRNA):
layout.operator(operator, text=bpy.utils.display_name(f)).path = path layout.operator(operator, text=bpy.utils.display_name(f)).path = path
def draw_preset(self, context): def draw_preset(self, context):
'''Define these on the subclass """Define these on the subclass
- preset_operator - preset_operator
- preset_subdir - preset_subdir
''' """
import bpy import bpy
self.path_menu(bpy.utils.preset_paths(self.preset_subdir), self.preset_operator) self.path_menu(bpy.utils.preset_paths(self.preset_subdir), self.preset_operator)

View File

@@ -1,118 +0,0 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
def collect_baseclasses(_class, bases):
if _class is type or _class is object:
return bases
bases.append(_class)
for _superclass in _class.__bases__:
collect_baseclasses(_superclass, bases)
return bases
def collect_subclasses(_class, subs):
if _class is type or _class is object:
return subs
subs.append(_class)
for _subclass in _class.__subclasses__():
collect_subclasses(_subclass, subs)
return subs
class DynMenu(bpy.types.Menu):
def draw(self, context):
'''
This is a draw function that is used to call all subclasses draw functions
starting from the registered classes draw function and working down.
DynMenu.setup() must be called first.
Sort/group classes could be nice
'''
subclass_ls = []
collect_subclasses(self.__class__, subclass_ls)
# print(subclass_ls)
for subclass in subclass_ls:
# print("drawwing", subclass) # , dir(subclass))
subclass.internal_draw(self, context)
# print("subclass.internal_draw", subclass.internal_draw)
def setup(menu_class):
'''
Setup subclasses (not needed when self.add() is used)
'''
bases = collect_baseclasses(menu_class, [])
# Incase 'DynMenu' isnt last
while bases[-1] is not DynMenu:
bases.pop()
bases.pop() # remove 'DynMenu'
root_class = bases[-1] # this is the registered class
for subclass in collect_subclasses(root_class, []):
#print(subclass)
draw = getattr(subclass, 'draw', None)
if draw and not hasattr(subclass, 'internal_draw'):
# print("replace", subclass, draw)
try:
del subclass.draw
except:
pass
subclass.internal_draw = draw
root_class.draw = DynMenu.draw
def add(menu_class, func):
'''
Add a single function directly without having to make a class
important that the returned value should be stored in the module that called it.
'''
newclass = type('<menuclass>', (menu_class,), {})
newclass.internal_draw = func
setup(menu_class)
return newclass
'''
# so we dont need to import this module
DynMenu.setup = setup
DynMenu.add = add
# Only so we can access as bpy.types.
# dont ever use this directly!
bpy.types.register(DynMenu)
'''

View File

@@ -19,9 +19,8 @@
# <pep8 compliant> # <pep8 compliant>
import bpy import bpy
from rigify import RigifyError, get_layer_dict from rigify import RigifyError
from rigify_utils import bone_class_instance, copy_bone_simple, blend_bone_list, get_side_name, get_base_name, add_pole_target_bone from rigify_utils import bone_class_instance, copy_bone_simple, add_pole_target_bone
from rna_prop_ui import rna_idprop_ui_prop_get
from Mathutils import Vector from Mathutils import Vector
METARIG_NAMES = "hips", "thigh", "shin", "foot", "toe" METARIG_NAMES = "hips", "thigh", "shin", "foot", "toe"

View File

@@ -90,6 +90,7 @@ def metarig_template():
pbone = obj.pose.bones['rib_cage'] pbone = obj.pose.bones['rib_cage']
pbone['type'] = 'spine_pivot_flex' pbone['type'] = 'spine_pivot_flex'
def metarig_definition(obj, orig_bone_name): def metarig_definition(obj, orig_bone_name):
''' '''
The bone given is the second in a chain. The bone given is the second in a chain.

View File

@@ -16,13 +16,37 @@
# #
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# classes for extracting info from blenders internal classes # classes for extracting info from blenders internal classes
import bpy import bpy
# use to strip python paths
script_paths = bpy.utils.script_paths()
def range_str(val):
if val < -10000000:
return '-inf'
elif val > 10000000:
return 'inf'
elif type(val) == float:
return '%g' % val
else:
return str(val)
def float_as_string(f):
val_str = "%g" % f
if '.' not in val_str and '-' not in val_str: # value could be 1e-05
val_str += '.0'
return val_str
class InfoStructRNA: class InfoStructRNA:
global_lookup = {} global_lookup = {}
def __init__(self, rna_type): def __init__(self, rna_type):
self.bl_rna = rna_type self.bl_rna = rna_type
@@ -43,18 +67,53 @@ class InfoStructRNA:
def build(self): def build(self):
rna_type = self.bl_rna rna_type = self.bl_rna
parent_id = self.identifier parent_id = self.identifier
self.properties[:] = [GetInfoPropertyRNA(rna_prop, parent_id) for rna_prop in rna_type.properties.values()] self.properties[:] = [GetInfoPropertyRNA(rna_prop, parent_id) for rna_id, rna_prop in rna_type.properties.items() if rna_id != "rna_type"]
self.functions[:] = [GetInfoFunctionRNA(rna_prop, parent_id) for rna_prop in rna_type.functions.values()] self.functions[:] = [GetInfoFunctionRNA(rna_prop, parent_id) for rna_prop in rna_type.functions.values()]
def getNestedProperties(self, ls = None): def get_bases(self):
bases = []
item = self
while item:
item = item.base
if item:
bases.append(item)
return bases
def get_nested_properties(self, ls=None):
if not ls: if not ls:
ls = self.properties[:] ls = self.properties[:]
if self.nested: if self.nested:
self.nested.getNestedProperties(ls) self.nested.get_nested_properties(ls)
return ls return ls
def _get_py_visible_attrs(self):
attrs = []
py_class = getattr(bpy.types, self.identifier)
for attr_str in dir(py_class):
if attr_str.startswith("_"):
continue
attrs.append((attr_str, getattr(py_class, attr_str)))
return attrs
def get_py_properties(self):
properties = []
for identifier, attr in self._get_py_visible_attrs():
if type(attr) is property:
properties.append((identifier, attr))
return properties
def get_py_functions(self):
import types
functions = []
for identifier, attr in self._get_py_visible_attrs():
if type(attr) in (types.FunctionType, types.MethodType):
functions.append((identifier, attr))
return functions
def __repr__(self): def __repr__(self):
txt = '' txt = ''
@@ -74,44 +133,137 @@ class InfoStructRNA:
class InfoPropertyRNA: class InfoPropertyRNA:
global_lookup = {} global_lookup = {}
def __init__(self, rna_prop): def __init__(self, rna_prop):
self.bl_prop = rna_prop self.bl_prop = rna_prop
self.identifier = rna_prop.identifier self.identifier = rna_prop.identifier
self.name = rna_prop.name self.name = rna_prop.name
self.description = rna_prop.description.strip() self.description = rna_prop.description.strip()
self.default_str = "<UNKNOWN>"
def build(self): def build(self):
rna_prop = self.bl_prop rna_prop = self.bl_prop
self.enum_items = [] self.enum_items = []
self.min = -1 self.min = getattr(rna_prop, "hard_min", -1)
self.max = -1 self.max = getattr(rna_prop, "hard_max", -1)
self.array_length = getattr(rna_prop, "array_length", 0) self.array_length = getattr(rna_prop, "array_length", 0)
self.collection_type = GetInfoStructRNA(rna_prop.srna)
self.is_required = rna_prop.is_required
self.is_readonly = rna_prop.is_readonly
self.is_never_none = rna_prop.is_never_none
self.type = rna_prop.type.lower() self.type = rna_prop.type.lower()
self.fixed_type = GetInfoStructRNA(rna_prop.fixed_type) # valid for pointer/collections fixed_type = getattr(rna_prop, "fixed_type", "")
if fixed_type:
self.fixed_type = GetInfoStructRNA(fixed_type) # valid for pointer/collections
else:
self.fixed_type = None
if self.type == "enum":
self.enum_items[:] = rna_prop.items.keys()
if self.array_length:
self.default = tuple(getattr(rna_prop, "default_array", ()))
self.default_str = ''
# special case for floats
if len(self.default) > 0:
if type(self.default[0]) is float:
self.default_str = "(%s)" % ", ".join([float_as_string(f) for f in self.default])
if not self.default_str:
self.default_str = str(self.default)
else:
self.default = getattr(rna_prop, "default", "")
if type(self.default) is float:
self.default_str = float_as_string(self.default)
else:
self.default_str = str(self.default)
self.srna = GetInfoStructRNA(rna_prop.srna) # valid for pointer/collections self.srna = GetInfoStructRNA(rna_prop.srna) # valid for pointer/collections
def get_default_string(self):
# pointer has no default, just set as None
if self.type == "pointer":
return "None"
elif self.type == "string":
return '"' + self.default_str + '"'
elif self.type == "enum":
if self.default_str:
return "'" + self.default_str + "'"
else:
return ""
return self.default_str
def get_arg_default(self, force=True):
default = self.get_default_string()
if default and (force or self.is_required == False):
return "%s=%s" % (self.identifier, default)
return self.identifier
def get_type_description(self, as_arg=False, class_fmt="%s"):
type_str = ""
if self.fixed_type is None:
type_str += self.type
if self.array_length:
type_str += " array of %d items" % (self.array_length)
if self.type in ("float", "int"):
type_str += " in [%s, %s]" % (range_str(self.min), range_str(self.max))
elif self.type == "enum":
type_str += " in [%s]" % ', '.join([("'%s'" % s) for s in self.enum_items])
else:
if self.type == "collection":
if self.collection_type:
collection_str = (class_fmt % self.collection_type.identifier) + " collection of "
else:
collection_str = "Collection of "
else:
collection_str = ""
type_str += collection_str + (class_fmt % self.fixed_type.identifier)
if as_arg:
if not self.is_required:
type_str += ", (optional)"
else: # readonly is only useful for selfs, not args
if self.is_readonly:
type_str += ", (readonly)"
if self.is_never_none:
type_str += ", (never None)"
return type_str
def __repr__(self): def __repr__(self):
txt = '' txt = ''
txt += ' * ' + self.identifier + ': ' + self.description txt += ' * ' + self.identifier + ': ' + self.description
return txt return txt
class InfoFunctionRNA: class InfoFunctionRNA:
global_lookup = {} global_lookup = {}
def __init__(self, rna_func): def __init__(self, rna_func):
self.bl_func = rna_func self.bl_func = rna_func
self.identifier = rna_func.identifier self.identifier = rna_func.identifier
# self.name = rna_func.name # functions have no name! # self.name = rna_func.name # functions have no name!
self.description = rna_func.description.strip() self.description = rna_func.description.strip()
self.args = [] # todo self.args = []
self.return_value = None # todo self.return_value = None
def build(self): def build(self):
rna_prop = self.bl_prop rna_func = self.bl_func
pass parent_id = rna_func
for rna_prop in rna_func.parameters.values():
prop = GetInfoPropertyRNA(rna_prop, parent_id)
if rna_prop.use_return:
self.return_value = prop
else:
self.args.append(prop)
def __repr__(self): def __repr__(self):
txt = '' txt = ''
@@ -123,6 +275,56 @@ class InfoFunctionRNA:
return txt return txt
class InfoOperatorRNA:
global_lookup = {}
def __init__(self, rna_op):
self.bl_op = rna_op
self.identifier = rna_op.identifier
mod, name = self.identifier.split("_OT_", 1)
self.module_name = mod.lower()
self.func_name = name
# self.name = rna_func.name # functions have no name!
self.description = rna_op.description.strip()
self.args = []
def build(self):
rna_op = self.bl_op
parent_id = self.identifier
for rna_id, rna_prop in rna_op.properties.items():
if rna_id == "rna_type":
continue
prop = GetInfoPropertyRNA(rna_prop, parent_id)
self.args.append(prop)
def get_location(self):
op_class = getattr(bpy.types, self.identifier)
op_func = getattr(op_class, "execute", None)
if op_func is None:
op_func = getattr(op_class, "invoke", None)
if op_func is None:
op_func = getattr(op_class, "poll", None)
if op_func:
op_code = op_func.__code__
source_path = op_code.co_filename
# clear the prefix
for p in script_paths:
source_path = source_path.split(p)[-1]
if source_path[0] in "/\\":
source_path = source_path[1:]
return source_path, op_code.co_firstlineno
else:
return None, None
def _GetInfoRNA(bl_rna, cls, parent_id=''): def _GetInfoRNA(bl_rna, cls, parent_id=''):
if bl_rna == None: if bl_rna == None:
@@ -139,13 +341,19 @@ def _GetInfoRNA(bl_rna, cls, parent_id=''):
def GetInfoStructRNA(bl_rna): def GetInfoStructRNA(bl_rna):
return _GetInfoRNA(bl_rna, InfoStructRNA) return _GetInfoRNA(bl_rna, InfoStructRNA)
def GetInfoPropertyRNA(bl_rna, parent_id): def GetInfoPropertyRNA(bl_rna, parent_id):
return _GetInfoRNA(bl_rna, InfoPropertyRNA, parent_id) return _GetInfoRNA(bl_rna, InfoPropertyRNA, parent_id)
def GetInfoFunctionRNA(bl_rna, parent_id): def GetInfoFunctionRNA(bl_rna, parent_id):
return _GetInfoRNA(bl_rna, InfoFunctionRNA, parent_id) return _GetInfoRNA(bl_rna, InfoFunctionRNA, parent_id)
def GetInfoOperatorRNA(bl_rna):
return _GetInfoRNA(bl_rna, InfoOperatorRNA)
def BuildRNAInfo(): def BuildRNAInfo():
# Use for faster lookups # Use for faster lookups
# use rna_struct.identifier as the key for each dict # use rna_struct.identifier as the key for each dict
@@ -166,7 +374,8 @@ def BuildRNAInfo():
return True return True
if "_PT_" in rna_id: if "_PT_" in rna_id:
return True return True
if "_HT_" in rna_id:
return True
return False return False
def full_rna_struct_path(rna_struct): def full_rna_struct_path(rna_struct):
@@ -181,8 +390,10 @@ def BuildRNAInfo():
# def write_func(rna_func, ident): # def write_func(rna_func, ident):
def base_id(rna_struct): def base_id(rna_struct):
try: return rna_struct.base.identifier try:
except: return '' # invalid id return rna_struct.base.identifier
except:
return "" # invalid id
#structs = [(base_id(rna_struct), rna_struct.identifier, rna_struct) for rna_struct in bpy.doc.structs.values()] #structs = [(base_id(rna_struct), rna_struct.identifier, rna_struct) for rna_struct in bpy.doc.structs.values()]
''' '''
@@ -194,8 +405,7 @@ def BuildRNAInfo():
for rna_type_name in dir(bpy.types): for rna_type_name in dir(bpy.types):
rna_type = getattr(bpy.types, rna_type_name) rna_type = getattr(bpy.types, rna_type_name)
try: rna_struct = rna_type.bl_rna rna_struct = getattr(rna_type, "bl_rna", None)
except: rna_struct = None
if rna_struct: if rna_struct:
#if not rna_type_name.startswith('__'): #if not rna_type_name.startswith('__'):
@@ -276,9 +486,10 @@ def BuildRNAInfo():
for rna_prop_identifier, rna_prop in rna_struct.properties.items(): for rna_prop_identifier, rna_prop in rna_struct.properties.items():
if rna_prop_identifier=='RNA': continue if rna_prop_identifier == 'RNA' or \
if rna_id_ignore(rna_prop_identifier): continue rna_id_ignore(rna_prop_identifier) or \
if rna_prop_identifier in rna_base_prop_keys: continue rna_prop_identifier in rna_base_prop_keys:
continue
for rna_prop_ptr in (getattr(rna_prop, "fixed_type", None), getattr(rna_prop, "srna", None)): for rna_prop_ptr in (getattr(rna_prop, "fixed_type", None), getattr(rna_prop, "srna", None)):
@@ -289,13 +500,15 @@ def BuildRNAInfo():
for rna_func in rna_struct.functions: for rna_func in rna_struct.functions:
for rna_prop_identifier, rna_prop in rna_func.parameters.items(): for rna_prop_identifier, rna_prop in rna_func.parameters.items():
if rna_prop_identifier=='RNA': continue if rna_prop_identifier == 'RNA' or \
if rna_id_ignore(rna_prop_identifier): continue rna_id_ignore(rna_prop_identifier) or \
if rna_prop_identifier in rna_base_func_keys: continue rna_prop_identifier in rna_base_func_keys:
continue
try:
try: rna_prop_ptr = rna_prop.fixed_type rna_prop_ptr = rna_prop.fixed_type
except: rna_prop_ptr = None except:
rna_prop_ptr = None
# Does this property point to me? # Does this property point to me?
if rna_prop_ptr: if rna_prop_ptr:
@@ -347,9 +560,42 @@ def BuildRNAInfo():
for rna_info in InfoStructRNA.global_lookup.values(): for rna_info in InfoStructRNA.global_lookup.values():
rna_info.build() rna_info.build()
for prop in rna_info.properties:
prop.build()
for func in rna_info.functions:
func.build()
for prop in func.args:
prop.build()
if func.return_value:
func.return_value.build()
for rna_info in InfoStructRNA.global_lookup.values(): # now for operators
print(rna_info) op_mods = dir(bpy.ops)
return InfoStructRNA.global_lookup, InfoFunctionRNA.global_lookup, InfoPropertyRNA.global_lookup for op_mod_name in sorted(op_mods):
if op_mod_name.startswith('__') or op_mod_name in ("add", "remove"):
continue
op_mod = getattr(bpy.ops, op_mod_name)
operators = dir(op_mod)
for op in sorted(operators):
try:
rna_prop = getattr(op_mod, op).get_rna()
except AttributeError:
rna_prop = None
except TypeError:
rna_prop = None
if rna_prop:
GetInfoOperatorRNA(rna_prop.bl_rna)
for rna_info in InfoOperatorRNA.global_lookup.values():
rna_info.build()
for rna_prop in rna_info.args:
rna_prop.build()
#for rna_info in InfoStructRNA.global_lookup.values():
# print(rna_info)
return InfoStructRNA.global_lookup, InfoFunctionRNA.global_lookup, InfoOperatorRNA.global_lookup, InfoPropertyRNA.global_lookup

View File

@@ -143,7 +143,7 @@ rna_max = FloatProperty(name="Max", default=1.0, precision=3)
class WM_OT_properties_edit(bpy.types.Operator): class WM_OT_properties_edit(bpy.types.Operator):
'''Internal use (edit a property path)''' '''Internal use (edit a property path)'''
bl_idname = "wm.properties_edit" bl_idname = "wm.properties_edit"
bl_label = "Edit Property!" bl_label = "Edit Property"
path = rna_path path = rna_path
property = rna_property property = rna_property
@@ -196,7 +196,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
prop_ui['description'] = self.properties.description prop_ui['description'] = self.properties.description
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
@@ -216,7 +216,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
#return wm.invoke_props_popup(self, event) #return wm.invoke_props_popup(self, event)
wm.invoke_props_popup(self, event) wm.invoke_props_popup(self, event)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
class WM_OT_properties_add(bpy.types.Operator): class WM_OT_properties_add(bpy.types.Operator):
@@ -242,7 +242,7 @@ class WM_OT_properties_add(bpy.types.Operator):
property = unique_name(item.keys()) property = unique_name(item.keys())
item[property] = 1.0 item[property] = 1.0
return ('FINISHED',) return {'FINISHED'}
class WM_OT_properties_remove(bpy.types.Operator): class WM_OT_properties_remove(bpy.types.Operator):
@@ -256,4 +256,4 @@ class WM_OT_properties_remove(bpy.types.Operator):
def execute(self, context): def execute(self, context):
item = eval("context.%s" % self.properties.path) item = eval("context.%s" % self.properties.path)
del item[self.properties.property] del item[self.properties.property]
return ('FINISHED',) return {'FINISHED'}

View File

@@ -23,6 +23,7 @@ from math import cos, sin, pi
# could this be stored elsewhere? # could this be stored elsewhere?
def metarig_template(): def metarig_template():
# generated by rigify.write_meta_rig # generated by rigify.write_meta_rig
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='EDIT')
@@ -607,17 +608,16 @@ class AddHuman(bpy.types.Operator):
bones.remove(bones[0]) bones.remove(bones[0])
metarig_template() metarig_template()
bpy.ops.object.mode_set(mode=mode_orig) bpy.ops.object.mode_set(mode=mode_orig)
return ('FINISHED',) return {'FINISHED'}
# Register the operator # Register the operator
bpy.ops.add(AddHuman) bpy.types.register(AddHuman)
# Add to a menu # Add to a menu
import dynamic_menu menu_func = (lambda self, context: self.layout.operator(AddHuman.bl_idname,
icon='OUTLINER_OB_ARMATURE', text="Human (Meta-Rig)"))
menu_func = (lambda self, context: self.layout.operator(AddHuman.bl_idname, icon='OUTLINER_OB_ARMATURE', text="Human (Meta-Rig)")) bpy.types.INFO_MT_armature_add.append(menu_func)
menu_item = dynamic_menu.add(bpy.types.INFO_MT_armature_add, menu_func)
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.mesh.armature_human_advanced_add() bpy.ops.mesh.armature_human_advanced_add()

View File

@@ -122,18 +122,16 @@ class AddTorus(bpy.types.Operator):
ob_new.location = tuple(context.scene.cursor_location) ob_new.location = tuple(context.scene.cursor_location)
return ('FINISHED',) return {'FINISHED'}
# Register the operator # Register the operator
bpy.ops.add(AddTorus) bpy.types.register(AddTorus)
# Add to a menu
import dynamic_menu
# Add to the menu
menu_func = (lambda self, context: self.layout.operator(AddTorus.bl_idname, menu_func = (lambda self, context: self.layout.operator(AddTorus.bl_idname,
text="Torus", icon='MESH_DONUT')) text="Torus", icon='MESH_DONUT'))
menu_item = dynamic_menu.add(bpy.types.INFO_MT_mesh_add, menu_func) bpy.types.INFO_MT_mesh_add.append(menu_func)
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.mesh.primitive_torus_add() bpy.ops.mesh.primitive_torus_add()

View File

@@ -79,10 +79,10 @@ def execute(context):
try: try:
line = sc.history[-1].line line = sc.history[-1].line
except: except:
return ('CANCELLED',) return {'CANCELLED'}
if sc.console_type != 'PYTHON': if sc.console_type != 'PYTHON':
return ('CANCELLED',) return {'CANCELLED'}
console, stdout, stderr = get_console(hash(context.region)) console, stdout, stderr = get_console(hash(context.region))
@@ -136,7 +136,7 @@ def execute(context):
if output_err: if output_err:
add_scrollback(output_err, 'ERROR') add_scrollback(output_err, 'ERROR')
return ('FINISHED',) return {'FINISHED'}
def autocomplete(context): def autocomplete(context):
@@ -150,10 +150,10 @@ def autocomplete(context):
line = current_line.line line = current_line.line
if not console: if not console:
return ('CANCELLED',) return {'CANCELLED'}
if sc.console_type != 'PYTHON': if sc.console_type != 'PYTHON':
return ('CANCELLED',) return {'CANCELLED'}
# This function isnt aware of the text editor or being an operator # This function isnt aware of the text editor or being an operator
# just does the autocomp then copy its results back # just does the autocomp then copy its results back
@@ -172,7 +172,7 @@ def autocomplete(context):
context.area.tag_redraw() context.area.tag_redraw()
return ('FINISHED',) return {'FINISHED'}
def banner(context): def banner(context):
@@ -195,4 +195,4 @@ def banner(context):
console = get_console(hash(context.region))[0] console = get_console(hash(context.region))[0]
console.locals["C"] = bpy.context console.locals["C"] = bpy.context
return ('FINISHED',) return {'FINISHED'}

View File

@@ -49,7 +49,7 @@ def execute(context):
try: try:
line = sc.history[-1].line line = sc.history[-1].line
except: except:
return ('CANCELLED',) return {'CANCELLED'}
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT') bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
@@ -60,13 +60,13 @@ def execute(context):
remove_duplicates=True) remove_duplicates=True)
sc.prompt = os.getcwd() + PROMPT sc.prompt = os.getcwd() + PROMPT
return ('FINISHED',) return {'FINISHED'}
def autocomplete(context): def autocomplete(context):
# sc = context.space_data # sc = context.space_data
# TODO # TODO
return ('CANCELLED',) return {'CANCELLED'}
def banner(context): def banner(context):
@@ -75,4 +75,4 @@ def banner(context):
shell_run("bash --version") shell_run("bash --version")
sc.prompt = os.getcwd() + PROMPT sc.prompt = os.getcwd() + PROMPT
return ('FINISHED',) return {'FINISHED'}

View File

@@ -65,11 +65,11 @@ class MeshSelectInteriorFaces(bpy.types.Operator):
def execute(self, context): def execute(self, context):
main(context) main(context)
return ('FINISHED',) return {'FINISHED'}
# Register the operator # Register the operator
bpy.ops.add(MeshSelectInteriorFaces) bpy.types.register(MeshSelectInteriorFaces)
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.mesh.faces_select_interior() bpy.ops.mesh.faces_select_interior()

View File

@@ -249,17 +249,16 @@ def mesh_faces_extend(me, faces, mat_idx = 0):
def getSelectedEdges(context, me, ob): def getSelectedEdges(context, me, ob):
MESH_MODE= context.scene.tool_settings.mesh_selection_mode MESH_MODE = tuple(context.tool_settings.mesh_selection_mode)
context.tool_settings.mesh_selection_mode = False, True, False
if MESH_MODE in ('EDGE', 'VERTEX'): if not MESH_MODE[2]:
context.scene.tool_settings.mesh_selection_mode = 'EDGE'
edges= [ ed for ed in me.edges if ed.selected ] edges= [ ed for ed in me.edges if ed.selected ]
# print len(edges), len(me.edges) # print len(edges), len(me.edges)
context.scene.tool_settings.mesh_selection_mode = MESH_MODE context.scene.tool_settings.mesh_selection_mode = MESH_MODE
return edges return edges
if MESH_MODE == 'FACE': else:
context.scene.tool_settings.mesh_selection_mode = 'EDGE'
# value is [edge, face_sel_user_in] # value is [edge, face_sel_user_in]
edge_dict= dict((ed.key, [ed, 0]) for ed in me.edges) edge_dict= dict((ed.key, [ed, 0]) for ed in me.edges)
@@ -268,7 +267,7 @@ def getSelectedEdges(context, me, ob):
for edkey in f.edge_keys: for edkey in f.edge_keys:
edge_dict[edkey][1] += 1 edge_dict[edkey][1] += 1
context.scene.tool_settings.mesh_selection_mode = MESH_MODE context.tool_settings.mesh_selection_mode = MESH_MODE
return [ ed_data[0] for ed_data in edge_dict.values() if ed_data[1] == 1 ] return [ ed_data[0] for ed_data in edge_dict.values() if ed_data[1] == 1 ]
@@ -644,15 +643,14 @@ class MESH_OT_skin(bpy.types.Operator):
def execute(self, context): def execute(self, context):
main(context) main(context)
return ('FINISHED',) return {'FINISHED'}
# Register the operator # Register the operator
bpy.ops.add(MESH_OT_skin) bpy.types.register(MESH_OT_skin)
# Add to a menu # Add to a menu
import dynamic_menu bpy.types.VIEW3D_MT_edit_mesh_faces.append((lambda self, context: self.layout.operator("mesh.skin", text="Bridge Faces")))
menu_item = dynamic_menu.add(bpy.types.VIEW3D_MT_edit_mesh_faces, (lambda self, context: self.layout.operator("mesh.skin", text="Bridge Faces")) )
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.mesh.skin() bpy.ops.mesh.skin()

View File

@@ -57,13 +57,13 @@ class SelectPattern(bpy.types.Operator):
elif not self.properties.extend: elif not self.properties.extend:
item.selected = False item.selected = False
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
# return wm.invoke_props_popup(self, event) # return wm.invoke_props_popup(self, event)
wm.invoke_props_popup(self, event) wm.invoke_props_popup(self, event)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -84,27 +84,45 @@ class SubdivisionSet(bpy.types.Operator):
bl_undo = True bl_undo = True
level = IntProperty(name="Level", level = IntProperty(name="Level",
default=1, min=0, max=100, soft_min=0, soft_max=6) default=1, min=-100, max=100, soft_min=-6, soft_max=6)
relative = BoolProperty(name="Relative", description="Apply the subsurf level as an offset relative to the current level", default=False)
def poll(self, context): def poll(self, context):
ob = context.active_object obs = context.selected_editable_objects
return (ob and ob.type == 'MESH') return (obs is not None)
def execute(self, context): def execute(self, context):
level = self.properties.level level = self.properties.level
relative = self.properties.relative
if relative and level == 0:
return {'CANCELLED'} # nothing to do
def set_object_subd(obj): def set_object_subd(obj):
for mod in obj.modifiers: for mod in obj.modifiers:
if mod.type == 'MULTIRES': if mod.type == 'MULTIRES':
if level < mod.total_levels: if level <= mod.total_levels:
if obj.mode == 'SCULPT' and mod.sculpt_levels != level: if obj.mode == 'SCULPT':
if relative:
mod.sculpt_levels += level
else:
if mod.sculpt_levels != level:
mod.sculpt_levels = level mod.sculpt_levels = level
elif obj.mode == 'OBJECT' and mod.levels != level: elif obj.mode == 'OBJECT':
if relative:
mod.levels += level
else:
if mod.levels != level:
mod.levels = level mod.levels = level
return return
elif mod.type == 'SUBSURF': elif mod.type == 'SUBSURF':
if relative:
mod.levels += level
else:
if mod.levels != level: if mod.levels != level:
mod.levels = level mod.levels = level
return return
# adda new modifier # adda new modifier
@@ -114,7 +132,7 @@ class SubdivisionSet(bpy.types.Operator):
for obj in context.selected_editable_objects: for obj in context.selected_editable_objects:
set_object_subd(obj) set_object_subd(obj)
return ('FINISHED',) return {'FINISHED'}
class Retopo(bpy.types.Operator): class Retopo(bpy.types.Operator):
@@ -128,9 +146,175 @@ class Retopo(bpy.types.Operator):
def execute(self, context): def execute(self, context):
import retopo import retopo
retopo.main() retopo.main()
return ('FINISHED',) return {'FINISHED'}
bpy.ops.add(SelectPattern) class ShapeTransfer(bpy.types.Operator):
bpy.ops.add(SubdivisionSet) '''Copy the active objects current shape to other selected objects with the same number of verts'''
bpy.ops.add(Retopo)
bl_idname = "object.shape_key_transfer"
bl_label = "Transfer Shape Key"
bl_register = True
bl_undo = True
mode = EnumProperty(items=(
('OFFSET', "Offset", "Apply the relative positional offset"),
('RELATIVE_FACE', "Relative Face", "Calculate the geometricly relative position (using faces)."),
('RELATIVE_EDGE', "Relative Edge", "Calculate the geometricly relative position (using edges).")),
name="Transformation Mode",
description="Method to apply relative shape positions to the new shape",
default='OFFSET')
use_clamp = BoolProperty(name="Clamp Offset",
description="Clamp the transformation to the distance each vertex moves in the original shape.",
default=False)
def _main(self, ob_act, objects, mode='OFFSET', use_clamp=False):
def me_nos(verts):
return [v.normal.copy() for v in verts]
def me_cos(verts):
return [v.co.copy() for v in verts]
def ob_add_shape(ob):
me = ob.data
ob.add_shape_key(from_mix=False)
if len(me.shape_keys.keys) == 1:
ob.add_shape_key(from_mix=False) # we need a rest
ob.active_shape_key_index = len(me.shape_keys.keys) - 1
ob.shape_key_lock = True
from Geometry import BarycentricTransform
from Mathutils import Vector
if use_clamp and mode == 'OFFSET':
use_clamp = False
me = ob_act.data
orig_shape_coords = me_cos(ob_act.active_shape_key.data)
orig_normals = me_nos(me.verts)
orig_coords = me_cos(me.verts)
for ob_other in objects:
me_other = ob_other.data
if len(me_other.verts) != len(me.verts):
self.report({'WARNING'}, "Skipping '%s', vertex count differs" % ob_other.name)
continue
target_normals = me_nos(me_other.verts)
target_coords = me_cos(me_other.verts)
ob_add_shape(ob_other)
# editing the final coords, only list that stores wrapped coords
target_shape_coords = [v.co for v in ob_other.active_shape_key.data]
median_coords = [[] for i in range(len(me.verts))]
# Method 1, edge
if mode == 'OFFSET':
for i, vert_cos in enumerate(median_coords):
vert_cos.append(target_coords[i] + (orig_shape_coords[i] - orig_coords[i]))
elif mode == 'RELATIVE_FACE':
for face in me.faces:
i1, i2, i3, i4 = face.verts_raw
if i4 != 0:
pt = BarycentricTransform(orig_shape_coords[i1],
orig_coords[i4], orig_coords[i1], orig_coords[i2],
target_coords[i4], target_coords[i1], target_coords[i2])
median_coords[i1].append(pt)
pt = BarycentricTransform(orig_shape_coords[i2],
orig_coords[i1], orig_coords[i2], orig_coords[i3],
target_coords[i1], target_coords[i2], target_coords[i3])
median_coords[i2].append(pt)
pt = BarycentricTransform(orig_shape_coords[i3],
orig_coords[i2], orig_coords[i3], orig_coords[i4],
target_coords[i2], target_coords[i3], target_coords[i4])
median_coords[i3].append(pt)
pt = BarycentricTransform(orig_shape_coords[i4],
orig_coords[i3], orig_coords[i4], orig_coords[i1],
target_coords[i3], target_coords[i4], target_coords[i1])
median_coords[i4].append(pt)
else:
pt = BarycentricTransform(orig_shape_coords[i1],
orig_coords[i3], orig_coords[i1], orig_coords[i2],
target_coords[i3], target_coords[i1], target_coords[i2])
median_coords[i1].append(pt)
pt = BarycentricTransform(orig_shape_coords[i2],
orig_coords[i1], orig_coords[i2], orig_coords[i3],
target_coords[i1], target_coords[i2], target_coords[i3])
median_coords[i2].append(pt)
pt = BarycentricTransform(orig_shape_coords[i3],
orig_coords[i2], orig_coords[i3], orig_coords[i1],
target_coords[i2], target_coords[i3], target_coords[i1])
median_coords[i3].append(pt)
elif mode == 'RELATIVE_EDGE':
for ed in me.edges:
i1, i2 = ed.verts
v1, v2 = orig_coords[i1], orig_coords[i2]
edge_length = (v1 - v2).length
n1loc = v1 + orig_normals[i1] * edge_length
n2loc = v2 + orig_normals[i2] * edge_length
# now get the target nloc's
v1_to, v2_to = target_coords[i1], target_coords[i2]
edlen_to = (v1_to - v2_to).length
n1loc_to = v1_to + target_normals[i1] * edlen_to
n2loc_to = v2_to + target_normals[i2] * edlen_to
pt = BarycentricTransform(orig_shape_coords[i1],
v2, v1, n1loc,
v2_to, v1_to, n1loc_to)
median_coords[i1].append(pt)
pt = BarycentricTransform(orig_shape_coords[i2],
v1, v2, n2loc,
v1_to, v2_to, n2loc_to)
median_coords[i2].append(pt)
# apply the offsets to the new shape
from functools import reduce
VectorAdd = Vector.__add__
for i, vert_cos in enumerate(median_coords):
if vert_cos:
co = reduce(VectorAdd, vert_cos) / len(vert_cos)
if use_clamp:
# clamp to the same movement as the original
# breaks copy between different scaled meshes.
len_from = (orig_shape_coords[i] - orig_coords[i]).length
ofs = co - target_coords[i]
ofs.length = len_from
co = target_coords[i] + ofs
target_shape_coords[i][:] = co
return {'FINISHED'}
def poll(self, context):
obj = context.active_object
return (obj and obj.mode != 'EDIT')
def execute(self, context):
C = bpy.context
ob_act = C.active_object
objects = [ob for ob in C.selected_editable_objects if ob != ob_act]
return self._main(ob_act, objects, self.properties.mode, self.properties.use_clamp)
bpy.types.register(SelectPattern)
bpy.types.register(SubdivisionSet)
bpy.types.register(Retopo)
bpy.types.register(ShapeTransfer)

View File

@@ -40,7 +40,7 @@ class AddPresetBase(bpy.types.Operator):
def execute(self, context): def execute(self, context):
if not self.properties.name: if not self.properties.name:
return ('FINISHED',) return {'FINISHED'}
filename = self._as_filename(self.properties.name) + ".py" filename = self._as_filename(self.properties.name) + ".py"
@@ -53,7 +53,7 @@ class AddPresetBase(bpy.types.Operator):
file_preset.close() file_preset.close()
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
@@ -61,7 +61,7 @@ class AddPresetBase(bpy.types.Operator):
#return wm.invoke_props_popup(self, event) #return wm.invoke_props_popup(self, event)
wm.invoke_props_popup(self, event) wm.invoke_props_popup(self, event)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
class AddPresetRender(AddPresetBase): class AddPresetRender(AddPresetBase):
@@ -125,6 +125,6 @@ class AddPresetCloth(AddPresetBase):
preset_subdir = "cloth" preset_subdir = "cloth"
bpy.ops.add(AddPresetRender) bpy.types.register(AddPresetRender)
bpy.ops.add(AddPresetSSS) bpy.types.register(AddPresetSSS)
bpy.ops.add(AddPresetCloth) bpy.types.register(AddPresetCloth)

View File

@@ -17,14 +17,17 @@
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
# ***** END GPL LICENCE BLOCK ***** # ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
# <pep8 compliant>
# History # History
# #
# Originally written by Matt Ebb # Originally written by Matt Ebb
import bpy import bpy
import subprocess, os, platform import subprocess
import os
import platform
# from BKE_add_image_extension() # from BKE_add_image_extension()
img_format_exts = { img_format_exts = {
@@ -56,8 +59,8 @@ movie_formats = ('QUICKTIME_QTKIT',
'AVIJPEG', 'AVIJPEG',
'AVICODEC', 'AVICODEC',
'XVID', 'XVID',
'THEORA' 'THEORA')
)
def guess_player_path(preset): def guess_player_path(preset):
if preset == 'BLENDER24': if preset == 'BLENDER24':
@@ -146,4 +149,4 @@ class PlayRenderedAnim(bpy.types.Operator):
return('FINISHED',) return('FINISHED',)
bpy.ops.add(PlayRenderedAnim) bpy.types.register(PlayRenderedAnim)

View File

@@ -257,16 +257,13 @@ class FollowActiveQuads(bpy.types.Operator):
def execute(self, context): def execute(self, context):
main(context, self) main(context, self)
return ('FINISHED',) return {'FINISHED'}
bpy.ops.add(FollowActiveQuads) bpy.types.register(FollowActiveQuads)
# Add to a menu # Add to a menu
import dynamic_menu
menu_func = (lambda self, context: self.layout.operator(FollowActiveQuads.bl_idname)) menu_func = (lambda self, context: self.layout.operator(FollowActiveQuads.bl_idname))
bpy.types.VIEW3D_MT_uv_map.append(menu_func)
menu_item = dynamic_menu.add(bpy.types.VIEW3D_MT_uv_map, menu_func)
if __name__ == '__main__': if __name__ == '__main__':
bpy.ops.uv.follow_active_quads() bpy.ops.uv.follow_active_quads()

View File

@@ -1109,6 +1109,8 @@ def main(context, island_margin, projection_limit):
""" """
from bpy.props import * from bpy.props import *
class SmartProject(bpy.types.Operator): class SmartProject(bpy.types.Operator):
'''This script projection unwraps the selected faces of a mesh. it operates on all selected mesh objects, and can be used unwrap selected faces, or all faces.''' '''This script projection unwraps the selected faces of a mesh. it operates on all selected mesh objects, and can be used unwrap selected faces, or all faces.'''
bl_idname = "uv.smart_project" bl_idname = "uv.smart_project"
@@ -1130,18 +1132,15 @@ class SmartProject(bpy.types.Operator):
def execute(self, context): def execute(self, context):
main(context, self.properties.island_margin, self.properties.angle_limit) main(context, self.properties.island_margin, self.properties.angle_limit)
return ('FINISHED',) return {'FINISHED'}
bpy.ops.add(SmartProject) bpy.types.register(SmartProject)
# Add to a menu # Add to a menu
import dynamic_menu
menu_func = (lambda self, context: self.layout.operator(SmartProject.bl_idname, menu_func = (lambda self, context: self.layout.operator(SmartProject.bl_idname,
text="Smart Project")) text="Smart Project"))
menu_item = dynamic_menu.add(bpy.types.VIEW3D_MT_uv_map, menu_func) bpy.types.VIEW3D_MT_uv_map.append(menu_func)
if __name__ == '__main__': if __name__ == '__main__':
bpy.ops.uv.smart_project() bpy.ops.uv.smart_project()

View File

@@ -158,24 +158,23 @@ class VertexPaintDirt(bpy.types.Operator):
dirt_only = BoolProperty(name="Dirt Only", description="Dont calculate cleans for convex areas", default=False) dirt_only = BoolProperty(name="Dirt Only", description="Dont calculate cleans for convex areas", default=False)
def execute(self, context): def execute(self, context):
sce = context.scene obj = context.object
ob = context.object
if not ob or ob.type != 'MESH': if not obj or obj.type != 'MESH':
print('Error, no active mesh object, aborting.') print('Error, no active mesh object, aborting.')
return('CANCELLED',) return('CANCELLED',)
me = ob.data mesh = obj.data
t = time.time() t = time.time()
applyVertexDirt(me, self.properties.blur_iterations, self.properties.blur_strength, math.radians(self.properties.dirt_angle), math.radians(self.properties.clean_angle), self.properties.dirt_only) applyVertexDirt(mesh, self.properties.blur_iterations, self.properties.blur_strength, math.radians(self.properties.dirt_angle), math.radians(self.properties.clean_angle), self.properties.dirt_only)
print('Dirt calculated in %.6f' % (time.time() - t)) print('Dirt calculated in %.6f' % (time.time() - t))
return('FINISHED',) return('FINISHED',)
bpy.ops.add(VertexPaintDirt) bpy.types.register(VertexPaintDirt)
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.mesh.vertex_paint_dirt() bpy.ops.mesh.vertex_paint_dirt()

View File

@@ -34,7 +34,7 @@ class MESH_OT_delete_edgeloop(bpy.types.Operator):
bpy.ops.mesh.select_more() bpy.ops.mesh.select_more()
bpy.ops.mesh.remove_doubles() bpy.ops.mesh.remove_doubles()
return ('FINISHED',) return {'FINISHED'}
rna_path_prop = StringProperty(name="Context Attributes", rna_path_prop = StringProperty(name="Context Attributes",
description="rna context string", maxlen=1024, default="") description="rna context string", maxlen=1024, default="")
@@ -60,15 +60,16 @@ def context_path_validate(context, path):
def execute_context_assign(self, context): def execute_context_assign(self, context):
if context_path_validate(context, self.properties.path) is Ellipsis: if context_path_validate(context, self.properties.path) is Ellipsis:
return ('PASS_THROUGH',) return {'PASS_THROUGH'}
exec("context.%s=self.properties.value" % self.properties.path) exec("context.%s=self.properties.value" % self.properties.path)
return ('FINISHED',) return {'FINISHED'}
class WM_OT_context_set_boolean(bpy.types.Operator): class WM_OT_context_set_boolean(bpy.types.Operator):
'''Set a context value.''' '''Set a context value.'''
bl_idname = "wm.context_set_boolean" bl_idname = "wm.context_set_boolean"
bl_label = "Context Set" bl_label = "Context Set Boolean"
bl_undo = True
path = rna_path_prop path = rna_path_prop
value = BoolProperty(name="Value", value = BoolProperty(name="Value",
@@ -81,6 +82,7 @@ class WM_OT_context_set_int(bpy.types.Operator): # same as enum
'''Set a context value.''' '''Set a context value.'''
bl_idname = "wm.context_set_int" bl_idname = "wm.context_set_int"
bl_label = "Context Set" bl_label = "Context Set"
bl_undo = True
path = rna_path_prop path = rna_path_prop
value = IntProperty(name="Value", description="Assign value", default=0) value = IntProperty(name="Value", description="Assign value", default=0)
@@ -91,7 +93,8 @@ class WM_OT_context_set_int(bpy.types.Operator): # same as enum
class WM_OT_context_set_float(bpy.types.Operator): # same as enum class WM_OT_context_set_float(bpy.types.Operator): # same as enum
'''Set a context value.''' '''Set a context value.'''
bl_idname = "wm.context_set_float" bl_idname = "wm.context_set_float"
bl_label = "Context Set" bl_label = "Context Set Float"
bl_undo = True
path = rna_path_prop path = rna_path_prop
value = FloatProperty(name="Value", value = FloatProperty(name="Value",
@@ -103,7 +106,8 @@ class WM_OT_context_set_float(bpy.types.Operator): # same as enum
class WM_OT_context_set_string(bpy.types.Operator): # same as enum class WM_OT_context_set_string(bpy.types.Operator): # same as enum
'''Set a context value.''' '''Set a context value.'''
bl_idname = "wm.context_set_string" bl_idname = "wm.context_set_string"
bl_label = "Context Set" bl_label = "Context Set String"
bl_undo = True
path = rna_path_prop path = rna_path_prop
value = StringProperty(name="Value", value = StringProperty(name="Value",
@@ -115,7 +119,8 @@ class WM_OT_context_set_string(bpy.types.Operator): # same as enum
class WM_OT_context_set_enum(bpy.types.Operator): class WM_OT_context_set_enum(bpy.types.Operator):
'''Set a context value.''' '''Set a context value.'''
bl_idname = "wm.context_set_enum" bl_idname = "wm.context_set_enum"
bl_label = "Context Set" bl_label = "Context Set Enum"
bl_undo = True
path = rna_path_prop path = rna_path_prop
value = StringProperty(name="Value", value = StringProperty(name="Value",
@@ -125,27 +130,48 @@ class WM_OT_context_set_enum(bpy.types.Operator):
execute = execute_context_assign execute = execute_context_assign
class WM_OT_context_set_value(bpy.types.Operator):
'''Set a context value.'''
bl_idname = "wm.context_set_value"
bl_label = "Context Set Value"
bl_undo = True
path = rna_path_prop
value = StringProperty(name="Value",
description="Assignment value (as a string)",
maxlen=1024, default="")
def execute(self, context):
if context_path_validate(context, self.properties.path) is Ellipsis:
return {'PASS_THROUGH'}
exec("context.%s=%s" % (self.properties.path, self.properties.value))
return {'FINISHED'}
class WM_OT_context_toggle(bpy.types.Operator): class WM_OT_context_toggle(bpy.types.Operator):
'''Toggle a context value.''' '''Toggle a context value.'''
bl_idname = "wm.context_toggle" bl_idname = "wm.context_toggle"
bl_label = "Context Toggle" bl_label = "Context Toggle"
bl_undo = True
path = rna_path_prop path = rna_path_prop
def execute(self, context): def execute(self, context):
if context_path_validate(context, self.properties.path) is Ellipsis: if context_path_validate(context, self.properties.path) is Ellipsis:
return ('PASS_THROUGH',) return {'PASS_THROUGH'}
exec("context.%s=not (context.%s)" % exec("context.%s=not (context.%s)" %
(self.properties.path, self.properties.path)) (self.properties.path, self.properties.path))
return ('FINISHED',) return {'FINISHED'}
class WM_OT_context_toggle_enum(bpy.types.Operator): class WM_OT_context_toggle_enum(bpy.types.Operator):
'''Toggle a context value.''' '''Toggle a context value.'''
bl_idname = "wm.context_toggle_enum" bl_idname = "wm.context_toggle_enum"
bl_label = "Context Toggle Values" bl_label = "Context Toggle Values"
bl_undo = True
path = rna_path_prop path = rna_path_prop
value_1 = StringProperty(name="Value", \ value_1 = StringProperty(name="Value", \
@@ -157,14 +183,14 @@ class WM_OT_context_toggle_enum(bpy.types.Operator):
def execute(self, context): def execute(self, context):
if context_path_validate(context, self.properties.path) is Ellipsis: if context_path_validate(context, self.properties.path) is Ellipsis:
return ('PASS_THROUGH',) return {'PASS_THROUGH'}
exec("context.%s = ['%s', '%s'][context.%s!='%s']" % \ exec("context.%s = ['%s', '%s'][context.%s!='%s']" % \
(self.properties.path, self.properties.value_1,\ (self.properties.path, self.properties.value_1,\
self.properties.value_2, self.properties.path, self.properties.value_2, self.properties.path,
self.properties.value_2)) self.properties.value_2))
return ('FINISHED',) return {'FINISHED'}
class WM_OT_context_cycle_int(bpy.types.Operator): class WM_OT_context_cycle_int(bpy.types.Operator):
@@ -172,6 +198,8 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
vertex keys, groups' etc.''' vertex keys, groups' etc.'''
bl_idname = "wm.context_cycle_int" bl_idname = "wm.context_cycle_int"
bl_label = "Context Int Cycle" bl_label = "Context Int Cycle"
bl_undo = True
path = rna_path_prop path = rna_path_prop
reverse = rna_reverse_prop reverse = rna_reverse_prop
@@ -179,7 +207,7 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
value = context_path_validate(context, self.properties.path) value = context_path_validate(context, self.properties.path)
if value is Ellipsis: if value is Ellipsis:
return ('PASS_THROUGH',) return {'PASS_THROUGH'}
self.properties.value = value self.properties.value = value
if self.properties.reverse: if self.properties.reverse:
@@ -196,13 +224,14 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
self.properties.value = - (1 << 32) self.properties.value = - (1 << 32)
execute_context_assign(self, context) execute_context_assign(self, context)
return ('FINISHED',) return {'FINISHED'}
class WM_OT_context_cycle_enum(bpy.types.Operator): class WM_OT_context_cycle_enum(bpy.types.Operator):
'''Toggle a context value.''' '''Toggle a context value.'''
bl_idname = "wm.context_cycle_enum" bl_idname = "wm.context_cycle_enum"
bl_label = "Context Enum Cycle" bl_label = "Context Enum Cycle"
bl_undo = True
path = rna_path_prop path = rna_path_prop
reverse = rna_reverse_prop reverse = rna_reverse_prop
@@ -211,7 +240,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
value = context_path_validate(context, self.properties.path) value = context_path_validate(context, self.properties.path)
if value is Ellipsis: if value is Ellipsis:
return ('PASS_THROUGH',) return {'PASS_THROUGH'}
orig_value = value orig_value = value
@@ -247,7 +276,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
# set the new value # set the new value
exec("context.%s=advance_enum" % self.properties.path) exec("context.%s=advance_enum" % self.properties.path)
return ('FINISHED',) return {'FINISHED'}
doc_id = StringProperty(name="Doc ID", doc_id = StringProperty(name="Doc ID",
description="", maxlen=1024, default="", hidden=True) description="", maxlen=1024, default="", hidden=True)
@@ -275,26 +304,26 @@ class WM_OT_doc_view(bpy.types.Operator):
def execute(self, context): def execute(self, context):
id_split = self.properties.doc_id.split('.') id_split = self.properties.doc_id.split('.')
if len(id_split) == 1: # rna, class if len(id_split) == 1: # rna, class
url = '%s/bpy.types.%s-class.html' % (self._prefix, id_split[0]) url = '%s/bpy.types.%s.html' % (self._prefix, id_split[0])
elif len(id_split) == 2: # rna, class.prop elif len(id_split) == 2: # rna, class.prop
class_name, class_prop = id_split class_name, class_prop = id_split
if hasattr(bpy.types, class_name.upper() + '_OT_' + class_prop): if hasattr(bpy.types, class_name.upper() + '_OT_' + class_prop):
url = '%s/bpy.ops.%s-module.html#%s' % \ url = '%s/bpy.ops.%s.html#bpy.ops.%s.%s' % \
(self._prefix, class_name, class_prop) (self._prefix, class_name, class_name, class_prop)
else: else:
# It so happens that epydoc nests these # It so happens that epydoc nests these, not sphinx
class_name_full = self._nested_class_string(class_name) # class_name_full = self._nested_class_string(class_name)
url = '%s/bpy.types.%s-class.html#%s' % \ url = '%s/bpy.types.%s.html#bpy.types.%s.%s' % \
(self._prefix, class_name_full, class_prop) (self._prefix, class_name, class_name, class_prop)
else: else:
return ('PASS_THROUGH',) return {'PASS_THROUGH'}
import webbrowser import webbrowser
webbrowser.open(url) webbrowser.open(url)
return ('FINISHED',) return {'FINISHED'}
class WM_OT_doc_edit(bpy.types.Operator): class WM_OT_doc_edit(bpy.types.Operator):
@@ -325,7 +354,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
class_name, class_prop = doc_id.split('.') class_name, class_prop = doc_id.split('.')
if not doc_new: if not doc_new:
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
# check if this is an operator # check if this is an operator
op_name = class_name.upper() + '_OT_' + class_prop op_name = class_name.upper() + '_OT_' + class_prop
@@ -338,7 +367,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
rna = op_class.bl_rna rna = op_class.bl_rna
doc_orig = rna.description doc_orig = rna.description
if doc_orig == doc_new: if doc_orig == doc_new:
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
print("op - old:'%s' -> new:'%s'" % (doc_orig, doc_new)) print("op - old:'%s' -> new:'%s'" % (doc_orig, doc_new))
upload["title"] = 'OPERATOR %s:%s' % (doc_id, doc_orig) upload["title"] = 'OPERATOR %s:%s' % (doc_id, doc_orig)
@@ -350,7 +379,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
rna = getattr(bpy.types, class_name).bl_rna rna = getattr(bpy.types, class_name).bl_rna
doc_orig = rna.properties[class_prop].description doc_orig = rna.properties[class_prop].description
if doc_orig == doc_new: if doc_orig == doc_new:
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
print("rna - old:'%s' -> new:'%s'" % (doc_orig, doc_new)) print("rna - old:'%s' -> new:'%s'" % (doc_orig, doc_new))
upload["title"] = 'RNA %s:%s' % (doc_id, doc_orig) upload["title"] = 'RNA %s:%s' % (doc_id, doc_orig)
@@ -359,7 +388,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
self._send_xmlrpc(upload) self._send_xmlrpc(upload)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
@@ -374,28 +403,29 @@ class WM_OT_reload_scripts(bpy.types.Operator):
def execute(self, context): def execute(self, context):
MOD = type(bpy) MOD = type(bpy)
bpy.load_scripts(True) bpy.load_scripts(True)
return ('FINISHED',) return {'FINISHED'}
bpy.ops.add(MESH_OT_delete_edgeloop) bpy.types.register(MESH_OT_delete_edgeloop)
bpy.ops.add(WM_OT_context_set_boolean) bpy.types.register(WM_OT_context_set_boolean)
bpy.ops.add(WM_OT_context_set_int) bpy.types.register(WM_OT_context_set_int)
bpy.ops.add(WM_OT_context_set_float) bpy.types.register(WM_OT_context_set_float)
bpy.ops.add(WM_OT_context_set_string) bpy.types.register(WM_OT_context_set_string)
bpy.ops.add(WM_OT_context_set_enum) bpy.types.register(WM_OT_context_set_enum)
bpy.ops.add(WM_OT_context_toggle) bpy.types.register(WM_OT_context_set_value)
bpy.ops.add(WM_OT_context_toggle_enum) bpy.types.register(WM_OT_context_toggle)
bpy.ops.add(WM_OT_context_cycle_enum) bpy.types.register(WM_OT_context_toggle_enum)
bpy.ops.add(WM_OT_context_cycle_int) bpy.types.register(WM_OT_context_cycle_enum)
bpy.types.register(WM_OT_context_cycle_int)
bpy.ops.add(WM_OT_doc_view) bpy.types.register(WM_OT_doc_view)
bpy.ops.add(WM_OT_doc_edit) bpy.types.register(WM_OT_doc_edit)
bpy.ops.add(WM_OT_reload_scripts) bpy.types.register(WM_OT_reload_scripts)
# experemental! # experemental!
import rna_prop_ui import rna_prop_ui
bpy.ops.add(rna_prop_ui.WM_OT_properties_edit) bpy.types.register(rna_prop_ui.WM_OT_properties_edit)
bpy.ops.add(rna_prop_ui.WM_OT_properties_add) bpy.types.register(rna_prop_ui.WM_OT_properties_add)
bpy.ops.add(rna_prop_ui.WM_OT_properties_remove) bpy.types.register(rna_prop_ui.WM_OT_properties_remove)

View File

@@ -30,7 +30,7 @@ class ExportSomeData(bpy.types.Operator):
write_some_data(self.properties.path, context, self.properties.use_setting) write_some_data(self.properties.path, context, self.properties.use_setting)
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
@@ -38,7 +38,7 @@ class ExportSomeData(bpy.types.Operator):
if True: if True:
# File selector # File selector
wm.add_fileselect(self) # will run self.execute() wm.add_fileselect(self) # will run self.execute()
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
elif 0: elif 0:
# Redo popup # Redo popup
return wm.invoke_props_popup(self, event) # return wm.invoke_props_popup(self, event) #
@@ -46,13 +46,11 @@ class ExportSomeData(bpy.types.Operator):
return self.execute(context) return self.execute(context)
bpy.ops.add(ExportSomeData) bpy.types.register(ExportSomeData)
# Only needed if you want to add into a dynamic menu # Only needed if you want to add into a dynamic menu
import dynamic_menu
menu_func = lambda self, context: self.layout.operator("export.some_data", text="Example Exporter...") menu_func = lambda self, context: self.layout.operator("export.some_data", text="Example Exporter...")
menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func) bpy.types.INFO_MT_file_export.append(menu_func)
# Use for running this script directly
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.export.some_data(path="/tmp/test.ply") bpy.ops.export.some_data(path="/tmp/test.ply")

View File

@@ -13,9 +13,9 @@ class SimpleOperator(bpy.types.Operator):
def execute(self, context): def execute(self, context):
main(context) main(context)
return ('FINISHED',) return {'FINISHED'}
bpy.ops.add(SimpleOperator) bpy.types.register(SimpleOperator)
if __name__ == "__main__": if __name__ == "__main__":
bpy.ops.object.simple_operator() bpy.ops.object.simple_operator()

View File

@@ -138,7 +138,7 @@ class Reload(bpy.types.Operator):
def execute(self, context): def execute(self, context):
DATA_PT_template.templates[:] = metarig_templates() DATA_PT_template.templates[:] = metarig_templates()
return ('FINISHED',) return {'FINISHED'}
def rigify_report_exception(operator, exception): def rigify_report_exception(operator, exception):
@@ -180,7 +180,7 @@ class Generate(bpy.types.Operator):
except rigify.RigifyError as rig_exception: except rigify.RigifyError as rig_exception:
rigify_report_exception(self, rig_exception) rigify_report_exception(self, rig_exception)
return ('FINISHED',) return {'FINISHED'}
class Validate(bpy.types.Operator): class Validate(bpy.types.Operator):
@@ -196,7 +196,7 @@ class Validate(bpy.types.Operator):
rigify.validate_rig(context, context.object) rigify.validate_rig(context, context.object)
except rigify.RigifyError as rig_exception: except rigify.RigifyError as rig_exception:
rigify_report_exception(self, rig_exception) rigify_report_exception(self, rig_exception)
return ('FINISHED',) return {'FINISHED'}
class Sample(bpy.types.Operator): class Sample(bpy.types.Operator):
@@ -219,7 +219,7 @@ class Sample(bpy.types.Operator):
if obj_gen: if obj_gen:
obj_gen.location.x = i * 1.0 obj_gen.location.x = i * 1.0
return ('FINISHED',) return {'FINISHED'}
class Graph(bpy.types.Operator): class Graph(bpy.types.Operator):
@@ -244,7 +244,7 @@ class Graph(bpy.types.Operator):
os.system("dot -Tpng %s > %s; gnome-open %s &" % (path_dot, path_png, path_png)) os.system("dot -Tpng %s > %s; gnome-open %s &" % (path_dot, path_png, path_png))
#os.system("python /b/xdot.py '%s' &" % path_dot) #os.system("python /b/xdot.py '%s' &" % path_dot)
return ('FINISHED',) return {'FINISHED'}
class AsScript(bpy.types.Operator): class AsScript(bpy.types.Operator):
@@ -267,7 +267,7 @@ class AsScript(bpy.types.Operator):
file.write(code) file.write(code)
file.close() file.close()
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
import os import os
@@ -275,7 +275,7 @@ class AsScript(bpy.types.Operator):
self.properties.path = os.path.splitext(bpy.data.filename)[0] + "-" + bpy.utils.clean_name(obj.name) + ".py" self.properties.path = os.path.splitext(bpy.data.filename)[0] + "-" + bpy.utils.clean_name(obj.name) + ".py"
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
# operators that use the GUI # operators that use the GUI
@@ -294,7 +294,7 @@ class ActiveAssign(bpy.types.Operator):
pose_templates = scene.pose_templates pose_templates = scene.pose_templates
template_name = DATA_PT_template.templates[pose_templates.active_template_index] template_name = DATA_PT_template.templates[pose_templates.active_template_index]
context.active_pose_bone["type"] = template_name context.active_pose_bone["type"] = template_name
return ('FINISHED',) return {'FINISHED'}
class ActiveClear(bpy.types.Operator): class ActiveClear(bpy.types.Operator):
@@ -310,14 +310,10 @@ class ActiveClear(bpy.types.Operator):
def execute(self, context): def execute(self, context):
scene = context.scene scene = context.scene
del context.active_pose_bone["type"] del context.active_pose_bone["type"]
return ('FINISHED',) return {'FINISHED'}
import space_info class INFO_MT_armature_metarig_add(bpy.types.Menu):
import dynamic_menu
class INFO_MT_armature_metarig_add(dynamic_menu.DynMenu):
bl_idname = "INFO_MT_armature_metarig_add" bl_idname = "INFO_MT_armature_metarig_add"
bl_label = "Meta-Rig" bl_label = "Meta-Rig"
@@ -336,18 +332,19 @@ bpy.types.register(DATA_PT_template)
bpy.types.register(PoseTemplateSettings) bpy.types.register(PoseTemplateSettings)
bpy.types.register(PoseTemplate) bpy.types.register(PoseTemplate)
bpy.ops.add(Reload) bpy.types.register(Reload)
bpy.ops.add(Generate) bpy.types.register(Generate)
bpy.ops.add(Validate) bpy.types.register(Validate)
bpy.ops.add(Sample) bpy.types.register(Sample)
bpy.ops.add(Graph) bpy.types.register(Graph)
bpy.ops.add(AsScript) bpy.types.register(AsScript)
bpy.ops.add(ActiveAssign) bpy.types.register(ActiveAssign)
bpy.ops.add(ActiveClear) bpy.types.register(ActiveClear)
bpy.types.register(INFO_MT_armature_metarig_add) bpy.types.register(INFO_MT_armature_metarig_add)
import space_info
menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE')) menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE'))
menu_item = dynamic_menu.add(bpy.types.INFO_MT_armature_add, menu_func) space_info.INFO_MT_armature_add.append(menu_func)

View File

@@ -602,16 +602,24 @@ class DATA_PT_modifiers(DataButtonsPanel):
layout.label(text="See Soft Body panel.") layout.label(text="See Soft Body panel.")
def SOLIDIFY(self, layout, ob, md, wide_ui): def SOLIDIFY(self, layout, ob, md, wide_ui):
layout.prop(md, "offset")
split = layout.split() split = layout.split()
col = split.column() col = split.column()
col.prop(md, "offset") col.label(text="Crease:")
col.prop(md, "edge_crease_inner",text="Inner")
col.prop(md, "edge_crease_outer", text="Outer")
col.prop(md, "edge_crease_rim", text="Rim")
if wide_ui:
col = split.column()
col.label()
col.prop(md, "use_rim") col.prop(md, "use_rim")
col.prop(md, "use_even_offset") col.prop(md, "use_even_offset")
col.prop(md, "use_quality_normals") col.prop(md, "use_quality_normals")
col.prop(md, "edge_crease_inner")
col.prop(md, "edge_crease_outer") # col = layout.column()
col.prop(md, "edge_crease_rim")
# col.label(text="Vertex Group:") # col.label(text="Vertex Group:")
# col.prop_object(md, "vertex_group", ob, "vertex_groups", text="") # col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
@@ -638,15 +646,16 @@ class DATA_PT_modifiers(DataButtonsPanel):
def UV_PROJECT(self, layout, ob, md, wide_ui): def UV_PROJECT(self, layout, ob, md, wide_ui):
if ob.type == 'MESH': if ob.type == 'MESH':
split = layout.split() split = layout.split()
col = split.column()
col.label(text="UV Layer:")
col.prop_object(md, "uv_layer", ob.data, "uv_textures", text="")
if wide_ui:
col = split.column() col = split.column()
col.label(text="Image:") col.label(text="Image:")
col.prop(md, "image", text="") col.prop(md, "image", text="")
if wide_ui:
col = split.column()
col.label(text="UV Layer:")
col.prop_object(md, "uv_layer", ob.data, "uv_textures", text="")
split = layout.split() split = layout.split()
col = split.column() col = split.column()
col.prop(md, "override_image") col.prop(md, "override_image")

View File

@@ -274,8 +274,7 @@ class RENDER_PT_game_stereo(RenderButtonsPanel):
# stereo: # stereo:
if stereo_mode == 'STEREO': if stereo_mode == 'STEREO':
layout.prop(gs, "stereo_mode") layout.prop(gs, "stereo_mode")
# layout.label(text="To do: Focal Length") # to be done after 2.5alpha0 is out layout.prop(gs, "eye_separation")
# layout.label(text="To do: Eye Separation") # to be done after 2.5alpha0 is out
# dome: # dome:
elif stereo_mode == 'DOME': elif stereo_mode == 'DOME':

View File

@@ -264,6 +264,7 @@ class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
layout.label(text="Diagnostics:") layout.label(text="Diagnostics:")
layout.prop(softbody, "diagnose") layout.prop(softbody, "diagnose")
layout.prop(softbody, "estimate_matrix")
class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel): class PHYSICS_PT_softbody_field_weights(PhysicButtonsPanel):

View File

@@ -581,8 +581,42 @@ class RENDER_PT_stamp(RenderButtonsPanel):
sub.prop(rd, "stamp_note_text", text="") sub.prop(rd, "stamp_note_text", text="")
bpy.types.register(RENDER_MT_presets) class RENDER_PT_bake(RenderButtonsPanel):
bl_label = "Bake"
bl_default_closed = True
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
rd = context.scene.render_data
wide_ui = context.region.width > narrowui
row = layout.row()
row.operator("object.bake_image", icon='RENDER_STILL')
row.prop(rd, "bake_type", text="")
col = layout.column()
col.active = (rd.bake_type == 'NORMALS')
col.prop(rd, "bake_normal_space")
# col.prop(rd, "bake_aa_mode")
# col.prop(rd, "bake_enable_aa")
col = layout.column()
row = col.row(align=True)
row.prop(rd, "bake_active")
row.prop(rd, "bake_normalized")
row = col.row(align=True)
row.prop(rd, "bake_clear")
row.prop(rd, "bake_margin")
row = col.row(align=True)
row.prop(rd, "bake_distance")
row.prop(rd, "bake_bias")
bpy.types.register(RENDER_MT_presets)
bpy.types.register(RENDER_PT_render) bpy.types.register(RENDER_PT_render)
bpy.types.register(RENDER_PT_layers) bpy.types.register(RENDER_PT_layers)
bpy.types.register(RENDER_PT_dimensions) bpy.types.register(RENDER_PT_dimensions)
@@ -593,3 +627,4 @@ bpy.types.register(RENDER_PT_encoding)
bpy.types.register(RENDER_PT_performance) bpy.types.register(RENDER_PT_performance)
bpy.types.register(RENDER_PT_post_processing) bpy.types.register(RENDER_PT_post_processing)
bpy.types.register(RENDER_PT_stamp) bpy.types.register(RENDER_PT_stamp)
bpy.types.register(RENDER_PT_bake)

View File

@@ -131,7 +131,7 @@ class ConsoleExec(bpy.types.Operator):
return execute(context) return execute(context)
else: else:
print("Error: bpy.ops.console.execute_" + sc.language + " - not found") print("Error: bpy.ops.console.execute_" + sc.language + " - not found")
return ('FINISHED',) return {'FINISHED'}
class ConsoleAutocomplete(bpy.types.Operator): class ConsoleAutocomplete(bpy.types.Operator):
@@ -153,11 +153,13 @@ class ConsoleAutocomplete(bpy.types.Operator):
return autocomplete(context) return autocomplete(context)
else: else:
print("Error: bpy.ops.console.autocomplete_" + sc.language + " - not found") print("Error: bpy.ops.console.autocomplete_" + sc.language + " - not found")
return ('FINISHED',) return {'FINISHED'}
class ConsoleBanner(bpy.types.Operator): class ConsoleBanner(bpy.types.Operator):
'''Print a message whem the terminal initializes'''
bl_idname = "console.banner" bl_idname = "console.banner"
bl_label = "Console Banner"
def execute(self, context): def execute(self, context):
sc = context.space_data sc = context.space_data
@@ -173,12 +175,13 @@ class ConsoleBanner(bpy.types.Operator):
return banner(context) return banner(context)
else: else:
print("Error: bpy.ops.console.banner_" + sc.language + " - not found") print("Error: bpy.ops.console.banner_" + sc.language + " - not found")
return ('FINISHED',) return {'FINISHED'}
class ConsoleLanguage(bpy.types.Operator): class ConsoleLanguage(bpy.types.Operator):
'''Set the current language for this console''' '''Set the current language for this console'''
bl_idname = "console.language" bl_idname = "console.language"
bl_label = "Console Language"
language = StringProperty(name="Language", maxlen=32, default="") language = StringProperty(name="Language", maxlen=32, default="")
def execute(self, context): def execute(self, context):
@@ -193,7 +196,7 @@ class ConsoleLanguage(bpy.types.Operator):
bpy.ops.console.history_append(text="", current_character=0, bpy.ops.console.history_append(text="", current_character=0,
remove_duplicates=True) remove_duplicates=True)
return ('FINISHED',) return {'FINISHED'}
bpy.types.register(CONSOLE_HT_header) bpy.types.register(CONSOLE_HT_header)
@@ -202,9 +205,9 @@ bpy.types.register(CONSOLE_MT_report)
bpy.types.register(CONSOLE_MT_language) bpy.types.register(CONSOLE_MT_language)
# Stubs that call the language operators # Stubs that call the language operators
bpy.ops.add(ConsoleExec) bpy.types.register(ConsoleExec)
bpy.ops.add(ConsoleAutocomplete) bpy.types.register(ConsoleAutocomplete)
bpy.ops.add(ConsoleBanner) bpy.types.register(ConsoleBanner)
# Set the language and call the banner # Set the language and call the banner
bpy.ops.add(ConsoleLanguage) bpy.types.register(ConsoleLanguage)

View File

@@ -19,9 +19,6 @@
# <pep8 compliant> # <pep8 compliant>
import bpy import bpy
import dynamic_menu
# reload(dynamic_menu)
class INFO_HT_header(bpy.types.Header): class INFO_HT_header(bpy.types.Header):
bl_space_type = 'INFO' bl_space_type = 'INFO'
@@ -79,7 +76,7 @@ class INFO_MT_file(bpy.types.Menu):
layout.operator("wm.read_homefile", text="New", icon='NEW') layout.operator("wm.read_homefile", text="New", icon='NEW')
layout.operator_context = 'INVOKE_AREA' layout.operator_context = 'INVOKE_AREA'
layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER') layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
layout.operator_menu_enum("wm.open_recentfile", "file", text="Open Recent") layout.menu("INFO_MT_file_open_recent")
layout.operator("wm.recover_last_session") layout.operator("wm.recover_last_session")
layout.operator("wm.recover_auto_save", text="Recover Auto Save...") layout.operator("wm.recover_auto_save", text="Recover Auto Save...")
@@ -115,21 +112,22 @@ class INFO_MT_file(bpy.types.Menu):
layout.operator_context = 'EXEC_AREA' layout.operator_context = 'EXEC_AREA'
layout.operator("wm.exit_blender", text="Quit", icon='QUIT') layout.operator("wm.exit_blender", text="Quit", icon='QUIT')
# test for expanding menus
''' class INFO_MT_file_open_recent(bpy.types.Menu):
class INFO_MT_file_more(INFO_MT_file): bl_idname = "INFO_MT_file_open_recent"
bl_label = "File" bl_label = "Open Recent..."
def draw(self, context): def draw(self, context):
import os
layout = self.layout layout = self.layout
layout.operator_context = 'EXEC_AREA'
file = open(os.path.join(bpy.home, ".Blog"), "rU")
for line in file:
line = line.rstrip()
layout.operator("wm.open_mainfile", text=line, icon='FILE_BLEND').path = line
file.close()
layout.operator("wm.read_homefile", text="TESTING ") class INFO_MT_file_import(bpy.types.Menu):
dynamic_menu.setup(INFO_MT_file_more)
'''
class INFO_MT_file_import(dynamic_menu.DynMenu):
bl_idname = "INFO_MT_file_import" bl_idname = "INFO_MT_file_import"
bl_label = "Import" bl_label = "Import"
@@ -138,7 +136,7 @@ class INFO_MT_file_import(dynamic_menu.DynMenu):
self.layout.operator("wm.collada_import", text="COLLADA (.dae)...") self.layout.operator("wm.collada_import", text="COLLADA (.dae)...")
class INFO_MT_file_export(dynamic_menu.DynMenu): class INFO_MT_file_export(bpy.types.Menu):
bl_idname = "INFO_MT_file_export" bl_idname = "INFO_MT_file_export"
bl_label = "Export" bl_label = "Export"
@@ -164,9 +162,9 @@ class INFO_MT_file_external_data(bpy.types.Menu):
layout.operator("file.find_missing_files") layout.operator("file.find_missing_files")
class INFO_MT_mesh_add(dynamic_menu.DynMenu): class INFO_MT_mesh_add(bpy.types.Menu):
bl_idname = "INFO_MT_mesh_add" bl_idname = "INFO_MT_mesh_add"
bl_label = "Mesh" bl_label = "Add Mesh"
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -183,7 +181,7 @@ class INFO_MT_mesh_add(dynamic_menu.DynMenu):
layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey") layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
class INFO_MT_armature_add(dynamic_menu.DynMenu): class INFO_MT_armature_add(bpy.types.Menu):
bl_idname = "INFO_MT_armature_add" bl_idname = "INFO_MT_armature_add"
bl_label = "Armature" bl_label = "Armature"
@@ -290,6 +288,7 @@ class INFO_MT_help(bpy.types.Menu):
bpy.types.register(INFO_HT_header) bpy.types.register(INFO_HT_header)
bpy.types.register(INFO_MT_file) bpy.types.register(INFO_MT_file)
bpy.types.register(INFO_MT_file_open_recent)
bpy.types.register(INFO_MT_file_import) bpy.types.register(INFO_MT_file_import)
bpy.types.register(INFO_MT_file_export) bpy.types.register(INFO_MT_file_export)
bpy.types.register(INFO_MT_file_external_data) bpy.types.register(INFO_MT_file_external_data)
@@ -308,7 +307,7 @@ class HelpOperator(bpy.types.Operator):
def execute(self, context): def execute(self, context):
import webbrowser import webbrowser
webbrowser.open(self._url) webbrowser.open(self._url)
return ('FINISHED',) return {'FINISHED'}
class HELP_OT_manual(HelpOperator): class HELP_OT_manual(HelpOperator):
@@ -391,14 +390,14 @@ class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
textblock.write('\n'.join(op_strings)) textblock.write('\n'.join(op_strings))
textblock.name = "OperatorList.txt" textblock.name = "OperatorList.txt"
print("See OperatorList.txt textblock") print("See OperatorList.txt textblock")
return ('FINISHED',) return {'FINISHED'}
bpy.ops.add(HELP_OT_manual) bpy.types.register(HELP_OT_manual)
bpy.ops.add(HELP_OT_release_logs) bpy.types.register(HELP_OT_release_logs)
bpy.ops.add(HELP_OT_blender_website) bpy.types.register(HELP_OT_blender_website)
bpy.ops.add(HELP_OT_blender_eshop) bpy.types.register(HELP_OT_blender_eshop)
bpy.ops.add(HELP_OT_developer_community) bpy.types.register(HELP_OT_developer_community)
bpy.ops.add(HELP_OT_user_community) bpy.types.register(HELP_OT_user_community)
bpy.ops.add(HELP_OT_report_bug) bpy.types.register(HELP_OT_report_bug)
bpy.ops.add(HELP_OT_python_api) bpy.types.register(HELP_OT_python_api)
bpy.ops.add(HELP_OT_operator_cheat_sheet) bpy.types.register(HELP_OT_operator_cheat_sheet)

View File

@@ -102,6 +102,7 @@ class TIME_MT_view(bpy.types.Menu):
layout.operator("marker.camera_bind") layout.operator("marker.camera_bind")
class TIME_MT_frame(bpy.types.Menu): class TIME_MT_frame(bpy.types.Menu):
bl_label = "Frame" bl_label = "Frame"

View File

@@ -21,71 +21,79 @@ import bpy
KM_HIERARCHY = [ KM_HIERARCHY = [
('Window', 'EMPTY', 'WINDOW', []), # file save, window change, exit ('Window', 'EMPTY', 'WINDOW', []), # file save, window change, exit
('Screen', 'EMPTY', 'WINDOW', [ # full screen, undo, screenshot
('Screen Editing', 'EMPTY', 'WINDOW', []), # resizing, action corners ('Screen Editing', 'EMPTY', 'WINDOW', []), # resizing, action corners
('Screen', 'EMPTY', 'WINDOW', []), # full screen, undo, screenshot ]),
('View2D', 'EMPTY', 'WINDOW', []), # view 2d navigation (per region) ('View2D', 'EMPTY', 'WINDOW', []), # view 2d navigation (per region)
('Frames', 'EMPTY', 'WINDOW', []), # frame navigation (per region) ('View2D Buttons List', 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation
('Header', 'EMPTY', 'WINDOW', []), # header stuff (per region) ('Header', 'EMPTY', 'WINDOW', []), # header stuff (per region)
('Markers', 'EMPTY', 'WINDOW', []), # markers (per region)
('Animation', 'EMPTY', 'WINDOW', []), # frame change on click, preview range (per region)
('Grease Pencil', 'EMPTY', 'WINDOW', []), # grease pencil stuff (per region) ('Grease Pencil', 'EMPTY', 'WINDOW', []), # grease pencil stuff (per region)
('View2D Buttons List', 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation ('3D View', 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform)
('Animation_Channels', 'EMPTY', 'WINDOW', []),
('Buttons Generic', 'PROPERTIES', 'WINDOW', []), # align context menu
('TimeLine', 'TIMELINE', 'WINDOW', []),
('Outliner', 'OUTLINER', 'WINDOW', []),
('View3D', 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform)
('Pose', 'EMPTY', 'WINDOW', []),
('Object Mode', 'EMPTY', 'WINDOW', []), ('Object Mode', 'EMPTY', 'WINDOW', []),
('Vertex Paint', 'EMPTY', 'WINDOW', []), ('Mesh', 'EMPTY', 'WINDOW', []),
('Weight Paint', 'EMPTY', 'WINDOW', []),
('Face Mask', 'EMPTY', 'WINDOW', []),
('Sculpt', 'EMPTY', 'WINDOW', []),
('EditMesh', 'EMPTY', 'WINDOW', []),
('Curve', 'EMPTY', 'WINDOW', []), ('Curve', 'EMPTY', 'WINDOW', []),
('Armature', 'EMPTY', 'WINDOW', []), ('Armature', 'EMPTY', 'WINDOW', []),
('Metaball', 'EMPTY', 'WINDOW', []), ('Metaball', 'EMPTY', 'WINDOW', []),
('Lattice', 'EMPTY', 'WINDOW', []), ('Lattice', 'EMPTY', 'WINDOW', []),
('Armature_Sketch', 'EMPTY', 'WINDOW', []),
('Particle', 'EMPTY', 'WINDOW', []),
('Font', 'EMPTY', 'WINDOW', []), ('Font', 'EMPTY', 'WINDOW', []),
('Object Non-modal', 'EMPTY', 'WINDOW', []), # mode change
('Pose', 'EMPTY', 'WINDOW', []),
('Vertex Paint', 'EMPTY', 'WINDOW', []),
('Weight Paint', 'EMPTY', 'WINDOW', []),
('Face Mask', 'EMPTY', 'WINDOW', []),
('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
('View3D Generic', 'VIEW_3D', 'WINDOW', []) # toolbar and properties ('Sculpt', 'EMPTY', 'WINDOW', []),
('Armature Sketch', 'EMPTY', 'WINDOW', []),
('Particle', 'EMPTY', 'WINDOW', []),
('Object Non-modal', 'EMPTY', 'WINDOW', []), # mode change
('3D View Generic', 'VIEW_3D', 'WINDOW', []) # toolbar and properties
]), ]),
('GraphEdit Keys', 'GRAPH_EDITOR', 'WINDOW', [
('GraphEdit Generic', 'GRAPH_EDITOR', 'WINDOW', []) ('Frames', 'EMPTY', 'WINDOW', []), # frame navigation (per region)
('Markers', 'EMPTY', 'WINDOW', []), # markers (per region)
('Animation', 'EMPTY', 'WINDOW', []), # frame change on click, preview range (per region)
('Animation Channels', 'EMPTY', 'WINDOW', []),
('Graph Editor', 'GRAPH_EDITOR', 'WINDOW', [
('Graph Editor Generic', 'GRAPH_EDITOR', 'WINDOW', [])
]),
('Dopesheet', 'DOPESHEET_EDITOR', 'WINDOW', []),
('NLA Editor', 'NLA_EDITOR', 'WINDOW', [
('NLA Channels', 'NLA_EDITOR', 'WINDOW', []),
('NLA Generic', 'NLA_EDITOR', 'WINDOW', [])
]), ]),
('Image', 'IMAGE_EDITOR', 'WINDOW', [ ('Image', 'IMAGE_EDITOR', 'WINDOW', [
('UVEdit', 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image ('UV Editor', 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image
('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
('Image Generic', 'IMAGE_EDITOR', 'WINDOW', []) ('Image Generic', 'IMAGE_EDITOR', 'WINDOW', [])
]), ]),
('Node Generic', 'NODE_EDITOR', 'WINDOW', [ ('Timeline', 'TIMELINE', 'WINDOW', []),
('Node', 'NODE_EDITOR', 'WINDOW', []) ('Outliner', 'OUTLINER', 'WINDOW', []),
('Node Editor', 'NODE_EDITOR', 'WINDOW', [
('Node Generic', 'NODE_EDITOR', 'WINDOW', [])
]), ]),
('File', 'FILE_BROWSER', 'WINDOW', [ ('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', []),
('FileMain', 'FILE_BROWSER', 'WINDOW', []), ('Logic Editor', 'LOGIC_EDITOR', 'WINDOW', []),
('FileButtons', 'FILE_BROWSER', 'WINDOW', [])
]), ('File Browser', 'FILE_BROWSER', 'WINDOW', [
('Action_Keys', 'DOPESHEET_EDITOR', 'WINDOW', []), ('File Browser Main', 'FILE_BROWSER', 'WINDOW', []),
('NLA Generic', 'NLA_EDITOR', 'WINDOW', [ ('File Browser Buttons', 'FILE_BROWSER', 'WINDOW', [])
('NLA Channels', 'NLA_EDITOR', 'WINDOW', []),
('NLA Data', 'NLA_EDITOR', 'WINDOW', [])
]), ]),
('Property Editor', 'PROPERTIES', 'WINDOW', []), # align context menu
('Script', 'SCRIPTS_WINDOW', 'WINDOW', []), ('Script', 'SCRIPTS_WINDOW', 'WINDOW', []),
('Text', 'TEXT_EDITOR', 'WINDOW', []), ('Text', 'TEXT_EDITOR', 'WINDOW', []),
('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', []),
('Logic Generic', 'LOGIC_EDITOR', 'WINDOW', []),
('Console', 'CONSOLE', 'WINDOW', []), ('Console', 'CONSOLE', 'WINDOW', []),
('View3D Gesture Circle', 'EMPTY', 'WINDOW', []), ('View3D Gesture Circle', 'EMPTY', 'WINDOW', []),
('Gesture Border', 'EMPTY', 'WINDOW', []), ('Gesture Border', 'EMPTY', 'WINDOW', []),
('Standard Modal Map', 'EMPTY', 'WINDOW', []), ('Standard Modal Map', 'EMPTY', 'WINDOW', []),
@@ -503,8 +511,6 @@ class USERPREF_PT_system(bpy.types.Panel):
sub.template_color_ramp(system, "weight_color_range", expand=True) sub.template_color_ramp(system, "weight_color_range", expand=True)
class USERPREF_PT_theme(bpy.types.Panel): class USERPREF_PT_theme(bpy.types.Panel):
bl_space_type = 'USER_PREFERENCES' bl_space_type = 'USER_PREFERENCES'
bl_label = "Themes" bl_label = "Themes"
@@ -1324,7 +1330,6 @@ class USERPREF_PT_input(bpy.types.Panel):
for entry in children: for entry in children:
self.draw_entry(kc, entry, col, level + 1) self.draw_entry(kc, entry, col, level + 1)
def draw_kmi(self, kc, km, kmi, layout, level): def draw_kmi(self, kc, km, kmi, layout, level):
layout.set_context_pointer("keyitem", kmi) layout.set_context_pointer("keyitem", kmi)
@@ -1475,8 +1480,9 @@ class USERPREF_PT_input(bpy.types.Panel):
if len(filtered_items) != 0: if len(filtered_items) != 0:
km = km.active() km = km.active()
layout.set_context_pointer("keymap", km)
col = layout.column() col = layout.column()
col.set_context_pointer("keymap", km)
row = col.row() row = col.row()
row.label(text=km.name, icon="DOT") row.label(text=km.name, icon="DOT")
@@ -1491,6 +1497,12 @@ class USERPREF_PT_input(bpy.types.Panel):
for kmi in filtered_items: for kmi in filtered_items:
self.draw_kmi(kc, km, kmi, col, 1) self.draw_kmi(kc, km, kmi, col, 1)
# "Add New" at end of keymap item list
col = self.indented_layout(layout, 1)
subcol = col.split(percentage=0.2).column()
subcol.active = km.user_defined
subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
def draw_hierarchy(self, defkc, layout): def draw_hierarchy(self, defkc, layout):
for entry in KM_HIERARCHY: for entry in KM_HIERARCHY:
self.draw_entry(defkc, entry, layout) self.draw_entry(defkc, entry, layout)
@@ -1540,6 +1552,7 @@ bpy.types.register(USERPREF_PT_input)
from bpy.props import * from bpy.props import *
class WM_OT_keyconfig_test(bpy.types.Operator): class WM_OT_keyconfig_test(bpy.types.Operator):
"Test keyconfig for conflicts." "Test keyconfig for conflicts."
bl_idname = "wm.keyconfig_test" bl_idname = "wm.keyconfig_test"
@@ -1547,6 +1560,7 @@ class WM_OT_keyconfig_test(bpy.types.Operator):
def testEntry(self, kc, entry, src=None, parent=None): def testEntry(self, kc, entry, src=None, parent=None):
result = False result = False
def kmistr(kmi): def kmistr(kmi):
if km.modal: if km.modal:
s = ["kmi = km.add_modal_item(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value)] s = ["kmi = km.add_modal_item(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value)]
@@ -1638,7 +1652,8 @@ class WM_OT_keyconfig_test(bpy.types.Operator):
if self.testConfig(kc): if self.testConfig(kc):
print("CONFLICT") print("CONFLICT")
return ('FINISHED',) return {'FINISHED'}
def _string_value(value): def _string_value(value):
result = "" result = ""
@@ -1667,6 +1682,7 @@ def _string_value(value):
return result return result
class WM_OT_keyconfig_export(bpy.types.Operator): class WM_OT_keyconfig_export(bpy.types.Operator):
"Export key configuration to a python script." "Export key configuration to a python script."
bl_idname = "wm.keyconfig_export" bl_idname = "wm.keyconfig_export"
@@ -1728,12 +1744,12 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
f.close() f.close()
return ('FINISHED',) return {'FINISHED'}
def invoke(self, context, event): def invoke(self, context, event):
wm = context.manager wm = context.manager
wm.add_fileselect(self) wm.add_fileselect(self)
return ('RUNNING_MODAL',) return {'RUNNING_MODAL'}
class WM_OT_keymap_edit(bpy.types.Operator): class WM_OT_keymap_edit(bpy.types.Operator):
@@ -1745,7 +1761,7 @@ class WM_OT_keymap_edit(bpy.types.Operator):
wm = context.manager wm = context.manager
km = context.keymap km = context.keymap
km.copy_to_user() km.copy_to_user()
return ('FINISHED',) return {'FINISHED'}
class WM_OT_keymap_restore(bpy.types.Operator): class WM_OT_keymap_restore(bpy.types.Operator):
@@ -1765,7 +1781,8 @@ class WM_OT_keymap_restore(bpy.types.Operator):
km = context.keymap km = context.keymap
km.restore_to_default() km.restore_to_default()
return ('FINISHED',) return {'FINISHED'}
class WM_OT_keyitem_restore(bpy.types.Operator): class WM_OT_keyitem_restore(bpy.types.Operator):
"Restore key map item." "Restore key map item."
@@ -1784,7 +1801,8 @@ class WM_OT_keyitem_restore(bpy.types.Operator):
km.restore_item_to_default(kmi) km.restore_item_to_default(kmi)
return ('FINISHED',) return {'FINISHED'}
class WM_OT_keyitem_add(bpy.types.Operator): class WM_OT_keyitem_add(bpy.types.Operator):
"Add key map item." "Add key map item."
@@ -1794,11 +1812,20 @@ class WM_OT_keyitem_add(bpy.types.Operator):
def execute(self, context): def execute(self, context):
wm = context.manager wm = context.manager
km = context.keymap km = context.keymap
kc = wm.default_keyconfig
if km.modal: if km.modal:
km.add_modal_item("", 'A', 'PRESS') # kmi km.add_modal_item("", 'A', 'PRESS') # kmi
else: else:
km.add_item("", 'A', 'PRESS') # kmi km.add_item("none", 'A', 'PRESS') # kmi
return ('FINISHED',)
# clear filter and expand keymap so we can see the newly added item
if kc.filter != '':
kc.filter = ''
km.items_expanded = True
km.children_expanded = True
return {'FINISHED'}
class WM_OT_keyitem_remove(bpy.types.Operator): class WM_OT_keyitem_remove(bpy.types.Operator):
@@ -1811,12 +1838,12 @@ class WM_OT_keyitem_remove(bpy.types.Operator):
kmi = context.keyitem kmi = context.keyitem
km = context.keymap km = context.keymap
km.remove_item(kmi) km.remove_item(kmi)
return ('FINISHED',) return {'FINISHED'}
bpy.ops.add(WM_OT_keyconfig_export) bpy.types.register(WM_OT_keyconfig_export)
bpy.ops.add(WM_OT_keyconfig_test) bpy.types.register(WM_OT_keyconfig_test)
bpy.ops.add(WM_OT_keymap_edit) bpy.types.register(WM_OT_keymap_edit)
bpy.ops.add(WM_OT_keymap_restore) bpy.types.register(WM_OT_keymap_restore)
bpy.ops.add(WM_OT_keyitem_add) bpy.types.register(WM_OT_keyitem_add)
bpy.ops.add(WM_OT_keyitem_remove) bpy.types.register(WM_OT_keyitem_remove)
bpy.ops.add(WM_OT_keyitem_restore) bpy.types.register(WM_OT_keyitem_restore)

View File

@@ -18,7 +18,6 @@
# <pep8 compliant> # <pep8 compliant>
import bpy import bpy
import dynamic_menu
class VIEW3D_HT_header(bpy.types.Header): class VIEW3D_HT_header(bpy.types.Header):
@@ -205,7 +204,7 @@ class VIEW3D_MT_snap(bpy.types.Menu):
layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active") layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
class VIEW3D_MT_uv_map(dynamic_menu.DynMenu): class VIEW3D_MT_uv_map(bpy.types.Menu):
bl_label = "UV Mapping" bl_label = "UV Mapping"
def draw(self, context): def draw(self, context):
@@ -456,6 +455,7 @@ class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
layout.separator() layout.separator()
layout.operator("mesh.select_random", text="Random...") layout.operator("mesh.select_random", text="Random...")
layout.operator("mesh.select_nth", text="Select Nth...")
layout.operator("mesh.edges_select_sharp", text="Sharp Edges") layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces") layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
layout.operator("mesh.faces_select_interior", text="Interior Faces") layout.operator("mesh.faces_select_interior", text="Interior Faces")
@@ -902,6 +902,24 @@ class VIEW3D_MT_particle(bpy.types.Menu):
layout.menu("VIEW3D_MT_particle_showhide") layout.menu("VIEW3D_MT_particle_showhide")
class VIEW3D_MT_particle_specials(bpy.types.Menu):
bl_label = "Specials"
def draw(self, context):
layout = self.layout
particle_edit = context.tool_settings.particle_edit
layout.operator("particle.rekey")
layout.separator()
if particle_edit.selection_mode == 'POINT':
layout.operator("particle.subdivide")
layout.operator("particle.select_first")
layout.operator("particle.select_last")
layout.operator("particle.remove_doubles")
class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide): class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
_operator_name = "particle" _operator_name = "particle"
@@ -1121,6 +1139,27 @@ class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
layout.operator("mesh.select_vertex_path") layout.operator("mesh.select_vertex_path")
class VIEW3D_MT_edit_mesh_selection_mode(bpy.types.Menu):
bl_label = "Mesh Select Mode"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
prop.value = "(True, False, False)"
prop.path = "tool_settings.mesh_selection_mode"
prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
prop.value = "(False, True, False)"
prop.path = "tool_settings.mesh_selection_mode"
prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
prop.value = "(False, False, True)"
prop.path = "tool_settings.mesh_selection_mode"
class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu): class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
bl_label = "Vertices" bl_label = "Vertices"
@@ -1190,7 +1229,7 @@ class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
layout.operator("mesh.region_to_loop") layout.operator("mesh.region_to_loop")
class VIEW3D_MT_edit_mesh_faces(dynamic_menu.DynMenu): class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu):
bl_label = "Faces" bl_label = "Faces"
bl_idname = "VIEW3D_MT_edit_mesh_faces" bl_idname = "VIEW3D_MT_edit_mesh_faces"
@@ -1323,6 +1362,20 @@ class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
layout.operator("curve.switch_direction") layout.operator("curve.switch_direction")
class VIEW3D_MT_edit_curve_specials(bpy.types.Menu):
bl_label = "Specials"
def draw(self, context):
layout = self.layout
layout.operator("curve.subdivide")
layout.operator("curve.switch_direction")
layout.operator("curve.spline_weight_set")
layout.operator("curve.radius_set")
layout.operator("curve.smooth")
layout.operator("curve.smooth_radius")
class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide): class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
_operator_name = "curve" _operator_name = "curve"
@@ -1902,6 +1955,7 @@ bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
bpy.types.register(VIEW3D_MT_paint_vertex) bpy.types.register(VIEW3D_MT_paint_vertex)
bpy.types.register(VIEW3D_MT_particle)# Particle Menu bpy.types.register(VIEW3D_MT_particle)# Particle Menu
bpy.types.register(VIEW3D_MT_particle_specials)
bpy.types.register(VIEW3D_MT_particle_showhide) bpy.types.register(VIEW3D_MT_particle_showhide)
bpy.types.register(VIEW3D_MT_pose) # POSE Menu bpy.types.register(VIEW3D_MT_pose) # POSE Menu
@@ -1915,6 +1969,7 @@ bpy.types.register(VIEW3D_MT_pose_showhide)
bpy.types.register(VIEW3D_MT_edit_mesh) bpy.types.register(VIEW3D_MT_edit_mesh)
bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings
bpy.types.register(VIEW3D_MT_edit_mesh_selection_mode) # Only as a menu for keybindings
bpy.types.register(VIEW3D_MT_edit_mesh_vertices) bpy.types.register(VIEW3D_MT_edit_mesh_vertices)
bpy.types.register(VIEW3D_MT_edit_mesh_edges) bpy.types.register(VIEW3D_MT_edit_mesh_edges)
bpy.types.register(VIEW3D_MT_edit_mesh_faces) bpy.types.register(VIEW3D_MT_edit_mesh_faces)
@@ -1924,6 +1979,7 @@ bpy.types.register(VIEW3D_MT_edit_mesh_showhide)
bpy.types.register(VIEW3D_MT_edit_curve) bpy.types.register(VIEW3D_MT_edit_curve)
bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints) bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints)
bpy.types.register(VIEW3D_MT_edit_curve_segments) bpy.types.register(VIEW3D_MT_edit_curve_segments)
bpy.types.register(VIEW3D_MT_edit_curve_specials)
bpy.types.register(VIEW3D_MT_edit_curve_showhide) bpy.types.register(VIEW3D_MT_edit_curve_showhide)
bpy.types.register(VIEW3D_MT_edit_surface) bpy.types.register(VIEW3D_MT_edit_surface)

View File

@@ -498,7 +498,15 @@ class VIEW3D_PT_tools_brush(PaintPanel):
if not context.particle_edit_object: if not context.particle_edit_object:
col = layout.split().column() col = layout.split().column()
row = col.row() row = col.row()
row.template_list(settings, "brushes", settings, "active_brush_index", rows=2)
if context.sculpt_object and brush:
defaulttools = 8
elif context.texture_paint_object and brush:
defaulttools = 4
else:
defaulttools = 2
row.template_list(settings, "brushes", settings, "active_brush_index", rows=2, maxrows=defaulttools)
col.template_ID(settings, "brush", new="brush.add") col.template_ID(settings, "brush", new="brush.add")
@@ -531,8 +539,6 @@ class VIEW3D_PT_tools_brush(PaintPanel):
elif context.sculpt_object and brush: elif context.sculpt_object and brush:
col = layout.column() col = layout.column()
col.separator() col.separator()
col.prop(brush, "sculpt_tool", expand=True)
col.separator()
row = col.row(align=True) row = col.row(align=True)
row.prop(brush, "size", slider=True) row.prop(brush, "size", slider=True)
@@ -563,12 +569,6 @@ class VIEW3D_PT_tools_brush(PaintPanel):
# Texture Paint Mode # # Texture Paint Mode #
elif context.texture_paint_object and brush: elif context.texture_paint_object and brush:
col = layout.column(align=True)
col.prop_enum(settings, "tool", 'DRAW')
col.prop_enum(settings, "tool", 'SOFTEN')
col.prop_enum(settings, "tool", 'CLONE')
col.prop_enum(settings, "tool", 'SMEAR')
col = layout.column() col = layout.column()
col.prop(brush, "color", text="") col.prop(brush, "color", text="")
@@ -624,6 +624,33 @@ class VIEW3D_PT_tools_brush(PaintPanel):
#row.prop(brush, "jitter", slider=True) #row.prop(brush, "jitter", slider=True)
#row.prop(brush, "use_jitter_pressure", toggle=True, text="") #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
class VIEW3D_PT_tools_brush_tool(PaintPanel):
bl_label = "Tool"
bl_default_closed = True
def poll(self, context):
settings = self.paint_settings(context)
return (settings and settings.brush and (context.sculpt_object or
context.texture_paint_object))
def draw(self, context):
layout = self.layout
settings = self.paint_settings(context)
brush = settings.brush
texture_paint = context.texture_paint_object
sculpt = context.sculpt_object
col = layout.column(align=True)
if context.sculpt_object:
col.prop(brush, "sculpt_tool", expand=True)
elif context.texture_paint_object:
col.prop_enum(settings, "tool", 'DRAW')
col.prop_enum(settings, "tool", 'SOFTEN')
col.prop_enum(settings, "tool", 'CLONE')
col.prop_enum(settings, "tool", 'SMEAR')
class VIEW3D_PT_tools_brush_stroke(PaintPanel): class VIEW3D_PT_tools_brush_stroke(PaintPanel):
bl_label = "Stroke" bl_label = "Stroke"
@@ -690,7 +717,7 @@ class VIEW3D_PT_sculpt_options(PaintPanel):
bl_label = "Options" bl_label = "Options"
def poll(self, context): def poll(self, context):
return context.sculpt_object return (context.sculpt_object and context.tool_settings.sculpt)
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -826,24 +853,50 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel):
col.active = (ipaint.use_normal_falloff and use_projection) col.active = (ipaint.use_normal_falloff and use_projection)
col.prop(ipaint, "normal_angle", text="") col.prop(ipaint, "normal_angle", text="")
split = layout.split(percentage=0.7) col = layout.column(align=False)
row = col.row()
row.active = (use_projection)
row.prop(ipaint, "use_stencil_layer", text="Stencil")
col = split.column(align=False) row2 = row.row(align=False)
col.active = (use_projection) row2.active = (use_projection and ipaint.use_stencil_layer)
col.prop(ipaint, "use_stencil_layer") row2.menu("VIEW3D_MT_tools_projectpaint_stencil", text=context.active_object.data.uv_texture_stencil.name)
row2.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
col = split.column(align=False)
col.active = (use_projection and ipaint.use_stencil_layer)
col.prop(ipaint, "invert_stencil", text="Inv")
col = layout.column() col = layout.column()
sub = col.column() sub = col.column()
sub.active = (settings.tool == 'CLONE') row = sub.row()
sub.prop(ipaint, "use_clone_layer") row.active = (settings.tool == 'CLONE')
row.prop(ipaint, "use_clone_layer", text="Clone")
row.menu("VIEW3D_MT_tools_projectpaint_clone", text=context.active_object.data.uv_texture_clone.name)
sub = col.column() sub = col.column()
sub.prop(ipaint, "seam_bleed") sub.prop(ipaint, "seam_bleed")
class VIEW3D_MT_tools_projectpaint_clone(bpy.types.Menu):
bl_label = "Clone Layer"
def draw(self, context):
layout = self.layout
for i, tex in enumerate(context.active_object.data.uv_textures):
prop = layout.operator("wm.context_set_int", text=tex.name)
prop.path = "active_object.data.uv_texture_clone_index"
prop.value = i
class VIEW3D_MT_tools_projectpaint_stencil(bpy.types.Menu):
bl_label = "Mask Layer"
def draw(self, context):
layout = self.layout
for i, tex in enumerate(context.active_object.data.uv_textures):
prop = layout.operator("wm.context_set_int", text=tex.name)
prop.path = "active_object.data.uv_texture_stencil_index"
prop.value = i
bpy.types.register(VIEW3D_MT_tools_projectpaint_clone)
bpy.types.register(VIEW3D_MT_tools_projectpaint_stencil)
class VIEW3D_PT_tools_particlemode(View3DPanel): class VIEW3D_PT_tools_particlemode(View3DPanel):
'''default tools for particle mode''' '''default tools for particle mode'''
@@ -922,6 +975,7 @@ bpy.types.register(VIEW3D_PT_tools_latticeedit)
bpy.types.register(VIEW3D_PT_tools_posemode) bpy.types.register(VIEW3D_PT_tools_posemode)
bpy.types.register(VIEW3D_PT_tools_posemode_options) bpy.types.register(VIEW3D_PT_tools_posemode_options)
bpy.types.register(VIEW3D_PT_tools_brush) bpy.types.register(VIEW3D_PT_tools_brush)
bpy.types.register(VIEW3D_PT_tools_brush_tool)
bpy.types.register(VIEW3D_PT_tools_brush_stroke) bpy.types.register(VIEW3D_PT_tools_brush_stroke)
bpy.types.register(VIEW3D_PT_tools_brush_curve) bpy.types.register(VIEW3D_PT_tools_brush_curve)
bpy.types.register(VIEW3D_PT_sculpt_options) bpy.types.register(VIEW3D_PT_sculpt_options)

View File

@@ -16,8 +16,6 @@
# #
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import unittest import unittest
import random import random

View File

@@ -137,6 +137,10 @@ ifeq ($(WITH_SNDFILE),true)
COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_sndfile.a COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_sndfile.a
endif endif
ifeq ($(WITH_FFTW3),true)
COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_fftw.a
endif
ifneq ($(NAN_NO_KETSJI),true) ifneq ($(NAN_NO_KETSJI),true)
COMLIB += $(OCGDIR)/gameengine/bloutines/$(DEBUG_DIR)libbloutines.a COMLIB += $(OCGDIR)/gameengine/bloutines/$(DEBUG_DIR)libbloutines.a
COMLIB += $(OCGDIR)/gameengine/blconverter/$(DEBUG_DIR)libblconverter.a COMLIB += $(OCGDIR)/gameengine/blconverter/$(DEBUG_DIR)libblconverter.a

View File

@@ -182,11 +182,11 @@ AviError AVI_print_error (AviError in_error) {
return in_error; return in_error;
} }
/*
void AVI_set_debug (int mode) { void AVI_set_debug (int mode) {
AVI_DEBUG= mode; AVI_DEBUG= mode;
} }
*/
/* /*
int AVI_is_avi (char *name) { int AVI_is_avi (char *name) {
FILE *fp; FILE *fp;

View File

@@ -198,11 +198,11 @@ int CustomData_get_named_layer_index(const struct CustomData *data, int type, ch
int CustomData_get_active_layer_index(const struct CustomData *data, int type); int CustomData_get_active_layer_index(const struct CustomData *data, int type);
int CustomData_get_render_layer_index(const struct CustomData *data, int type); int CustomData_get_render_layer_index(const struct CustomData *data, int type);
int CustomData_get_clone_layer_index(const struct CustomData *data, int type); int CustomData_get_clone_layer_index(const struct CustomData *data, int type);
int CustomData_get_mask_layer_index(const struct CustomData *data, int type); int CustomData_get_stencil_layer_index(const struct CustomData *data, int type);
int CustomData_get_active_layer(const struct CustomData *data, int type); int CustomData_get_active_layer(const struct CustomData *data, int type);
int CustomData_get_render_layer(const struct CustomData *data, int type); int CustomData_get_render_layer(const struct CustomData *data, int type);
int CustomData_get_clone_layer(const struct CustomData *data, int type); int CustomData_get_clone_layer(const struct CustomData *data, int type);
int CustomData_get_mask_layer(const struct CustomData *data, int type); int CustomData_get_stencil_layer(const struct CustomData *data, int type);
/* copies the data from source to the data element at index in the first /* copies the data from source to the data element at index in the first
* layer of type * layer of type
@@ -231,13 +231,13 @@ void *CustomData_set_layer_n(const struct CustomData *data, int type, int n, voi
void CustomData_set_layer_active(struct CustomData *data, int type, int n); void CustomData_set_layer_active(struct CustomData *data, int type, int n);
void CustomData_set_layer_render(struct CustomData *data, int type, int n); void CustomData_set_layer_render(struct CustomData *data, int type, int n);
void CustomData_set_layer_clone(struct CustomData *data, int type, int n); void CustomData_set_layer_clone(struct CustomData *data, int type, int n);
void CustomData_set_layer_mask(struct CustomData *data, int type, int n); void CustomData_set_layer_stencil(struct CustomData *data, int type, int n);
/* same as above but works with an index from CustomData_get_layer_index */ /* same as above but works with an index from CustomData_get_layer_index */
void CustomData_set_layer_active_index(struct CustomData *data, int type, int n); void CustomData_set_layer_active_index(struct CustomData *data, int type, int n);
void CustomData_set_layer_render_index(struct CustomData *data, int type, int n); void CustomData_set_layer_render_index(struct CustomData *data, int type, int n);
void CustomData_set_layer_clone_index(struct CustomData *data, int type, int n); void CustomData_set_layer_clone_index(struct CustomData *data, int type, int n);
void CustomData_set_layer_mask_index(struct CustomData *data, int type, int n); void CustomData_set_layer_stencil_index(struct CustomData *data, int type, int n);
/* adds flag to the layer flags */ /* adds flag to the layer flags */
void CustomData_set_layer_flag(struct CustomData *data, int type, int flag); void CustomData_set_layer_flag(struct CustomData *data, int type, int flag);

View File

@@ -160,6 +160,11 @@ struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int
/* high level function to get an fcurve from C without having the rna */ /* high level function to get an fcurve from C without having the rna */
struct FCurve *id_data_find_fcurve(ID *id, void *data, struct StructRNA *type, char *prop_name, int index); struct FCurve *id_data_find_fcurve(ID *id, void *data, struct StructRNA *type, char *prop_name, int index);
/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
* e.g. numMatches = list_find_data_fcurves(matches, &act->curves, "pose.bones[", "MyFancyBone");
*/
int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName);
/* Binary search algorithm for finding where to 'insert' BezTriple with given frame number. /* Binary search algorithm for finding where to 'insert' BezTriple with given frame number.
* Returns the index to insert at (data already at that index will be offset if replace is 0) * Returns the index to insert at (data already at that index will be offset if replace is 0)
*/ */

View File

@@ -59,7 +59,7 @@ void key_curve_normal_weights(float t, float *data, int type);
float *do_ob_key(struct Scene *scene, struct Object *ob); float *do_ob_key(struct Scene *scene, struct Object *ob);
struct Key *ob_get_key(struct Object *ob); struct Key *ob_get_key(struct Object *ob);
struct KeyBlock *add_keyblock(struct Scene *scene, struct Key *key); struct KeyBlock *add_keyblock(struct Key *key, char *name);
struct KeyBlock *ob_get_keyblock(struct Object *ob); struct KeyBlock *ob_get_keyblock(struct Object *ob);
struct KeyBlock *ob_get_reference_keyblock(struct Object *ob); struct KeyBlock *ob_get_reference_keyblock(struct Object *ob);
struct KeyBlock *key_get_keyblock(struct Key *key, int index); struct KeyBlock *key_get_keyblock(struct Key *key, int index);
@@ -68,6 +68,14 @@ char *key_get_curValue_rnaPath(struct Key *key, struct KeyBlock *kb);
// needed for the GE // needed for the GE
void do_rel_key(int start, int end, int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, int mode); void do_rel_key(int start, int end, int tot, char *basispoin, struct Key *key, struct KeyBlock *actkb, int mode);
/* conversion functions */
void key_to_mesh(struct KeyBlock *kb, struct Mesh *me);
void mesh_to_key(struct Mesh *me, struct KeyBlock *kb);
void key_to_latt(struct KeyBlock *kb, struct Lattice *lt);
void latt_to_key(struct Lattice *lt, struct KeyBlock *kb);
void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb);
void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb);
#ifdef __cplusplus #ifdef __cplusplus
}; };
#endif #endif

View File

@@ -120,6 +120,7 @@ int give_obdata_texspace(struct Object *ob, short **texflag, float **loc, float
int object_insert_ptcache(struct Object *ob); int object_insert_ptcache(struct Object *ob);
// void object_delete_ptcache(struct Object *ob, int index); // void object_delete_ptcache(struct Object *ob, int index);
struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, char *name, int from_mix);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -55,7 +55,7 @@ struct uiMenuItem;
ED_spacetypes_init() in editors/area/spacetypes.c */ ED_spacetypes_init() in editors/area/spacetypes.c */
/* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */ /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
#define BKE_ST_MAXNAME 32 #define BKE_ST_MAXNAME 64
typedef struct SpaceType { typedef struct SpaceType {
struct SpaceType *next, *prev; struct SpaceType *next, *prev;
@@ -220,8 +220,6 @@ const struct ListBase *BKE_spacetypes_list(void);
void BKE_spacetype_register(struct SpaceType *st); void BKE_spacetype_register(struct SpaceType *st);
void BKE_spacetypes_free(void); /* only for quitting blender */ void BKE_spacetypes_free(void); /* only for quitting blender */
// MenuType *BKE_spacemenu_find(const char *idname, int spacetype);
/* spacedata */ /* spacedata */
void BKE_spacedata_freelist(ListBase *lb); void BKE_spacedata_freelist(ListBase *lb);
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);

View File

@@ -195,7 +195,7 @@ void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_m
void seq_update_sound(struct Sequence *seq); void seq_update_sound(struct Sequence *seq);
void seq_update_muting(struct Editing *ed); void seq_update_muting(struct Editing *ed);
void seqbase_sound_reload(Scene *scene, ListBase *seqbase);
void clear_scene_in_allseqs(struct Scene *sce); void clear_scene_in_allseqs(struct Scene *sce);
struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive); struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive);

View File

@@ -37,17 +37,19 @@ extern "C" {
/* generic blender movie support, could move to own module */ /* generic blender movie support, could move to own module */
struct RenderData; struct RenderData;
struct ReportList;
struct Scene; struct Scene;
void start_avi(struct Scene *scene, struct RenderData *rd, int rectx, int recty);
int start_avi(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports);
void end_avi(void); void end_avi(void);
void append_avi(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); int append_avi(struct RenderData *rd, int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
void makeavistring (struct RenderData *rd, char *string); void makeavistring (struct RenderData *rd, char *string);
typedef struct bMovieHandle { typedef struct bMovieHandle {
void (*start_movie)(struct Scene *scene, struct RenderData *rd, int rectx, int recty); int (*start_movie)(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports);
void (*append_movie)(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); int (*append_movie)(struct RenderData *rd, int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
void (*end_movie)(void); void (*end_movie)(void);
int (*get_next_frame)(struct RenderData *rd); /* optional */ int (*get_next_frame)(struct RenderData *rd, struct ReportList *reports); /* optional */
} bMovieHandle; } bMovieHandle;
bMovieHandle *BKE_get_movie_handle(int imtype); bMovieHandle *BKE_get_movie_handle(int imtype);

View File

@@ -57,11 +57,12 @@ extern "C" {
struct IDProperty; struct IDProperty;
struct RenderData; struct RenderData;
struct ReportList;
struct Scene; struct Scene;
extern void start_ffmpeg(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern int start_ffmpeg(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports);
extern void end_ffmpeg(void); extern void end_ffmpeg(void);
extern void append_ffmpeg(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); extern int append_ffmpeg(struct RenderData *rd, int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
extern void ffmpeg_set_preset(struct RenderData *rd, int preset); extern void ffmpeg_set_preset(struct RenderData *rd, int preset);
extern void ffmpeg_verify_image_type(struct RenderData *rd); extern void ffmpeg_verify_image_type(struct RenderData *rd);

View File

@@ -33,12 +33,13 @@ extern "C" {
#endif #endif
struct RenderData; struct RenderData;
struct ReportList;
struct Scene; struct Scene;
extern void start_frameserver(struct Scene *scene, struct RenderData *rd, int rectx, int recty); extern int start_frameserver(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports);
extern void end_frameserver(void); extern void end_frameserver(void);
extern void append_frameserver(struct RenderData *rd, int frame, int *pixels, int rectx, int recty); extern int append_frameserver(struct RenderData *rd, int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
extern int frameserver_loop(struct RenderData *rd); extern int frameserver_loop(struct RenderData *rd, struct ReportList *reports);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -379,19 +379,10 @@ bActionGroup *action_groups_find_named (bAction *act, const char name[])
/* usually used within a loop, so we got a N^2 slowdown */ /* usually used within a loop, so we got a N^2 slowdown */
bPoseChannel *get_pose_channel(const bPose *pose, const char *name) bPoseChannel *get_pose_channel(const bPose *pose, const char *name)
{ {
bPoseChannel *chan;
if (ELEM(NULL, pose, name) || (name[0] == 0)) if (ELEM(NULL, pose, name) || (name[0] == 0))
return NULL; return NULL;
for (chan=pose->chanbase.first; chan; chan=chan->next) { return BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name));
if (chan->name[0] == name[0]) {
if (!strcmp (chan->name, name))
return chan;
}
}
return NULL;
} }
/* Use with care, not on Armature poses but for temporal ones */ /* Use with care, not on Armature poses but for temporal ones */

View File

@@ -72,7 +72,7 @@ static short id_has_animdata (ID *id)
switch (GS(id->name)) { switch (GS(id->name)) {
/* has AnimData */ /* has AnimData */
case ID_OB: case ID_OB:
case ID_MB: case ID_CU: case ID_AR: case ID_ME: case ID_MB: case ID_CU: case ID_AR:
case ID_KE: case ID_KE:
case ID_PA: case ID_PA:
case ID_MA: case ID_TE: case ID_NT: case ID_MA: case ID_TE: case ID_NT:
@@ -1774,7 +1774,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM); EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM);
/* meshes */ /* meshes */
// TODO... EVAL_ANIM_IDS(main->mesh.first, ADT_RECALC_ANIM);
/* particles */ /* particles */
EVAL_ANIM_IDS(main->particle.first, ADT_RECALC_ANIM); EVAL_ANIM_IDS(main->particle.first, ADT_RECALC_ANIM);

View File

@@ -40,6 +40,8 @@
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include "DNA_windowmanager_types.h" #include "DNA_windowmanager_types.h"
#include "WM_types.h"
#include "RNA_access.h" #include "RNA_access.h"
#include "BLI_math.h" #include "BLI_math.h"
@@ -56,6 +58,8 @@
#include "BKE_texture.h" #include "BKE_texture.h"
#include "BKE_utildefines.h" #include "BKE_utildefines.h"
#include "IMB_imbuf.h" #include "IMB_imbuf.h"
#include "IMB_imbuf_types.h" #include "IMB_imbuf_types.h"

View File

@@ -1006,7 +1006,7 @@ int CustomData_get_clone_layer_index(const CustomData *data, int type)
return -1; return -1;
} }
int CustomData_get_mask_layer_index(const CustomData *data, int type) int CustomData_get_stencil_layer_index(const CustomData *data, int type)
{ {
int i; int i;
@@ -1050,7 +1050,7 @@ int CustomData_get_clone_layer(const CustomData *data, int type)
return -1; return -1;
} }
int CustomData_get_mask_layer(const CustomData *data, int type) int CustomData_get_stencil_layer(const CustomData *data, int type)
{ {
int i; int i;
@@ -1088,7 +1088,7 @@ void CustomData_set_layer_clone(CustomData *data, int type, int n)
data->layers[i].active_clone = n; data->layers[i].active_clone = n;
} }
void CustomData_set_layer_mask(CustomData *data, int type, int n) void CustomData_set_layer_stencil(CustomData *data, int type, int n)
{ {
int i; int i;
@@ -1125,7 +1125,7 @@ void CustomData_set_layer_clone_index(CustomData *data, int type, int n)
data->layers[i].active_clone = n-i; data->layers[i].active_clone = n-i;
} }
void CustomData_set_layer_mask_index(CustomData *data, int type, int n) void CustomData_set_layer_stencil_index(CustomData *data, int type, int n)
{ {
int i; int i;

View File

@@ -352,7 +352,8 @@ int cdf_write_open(CDataFile *cdf, char *filename)
/* fill header */ /* fill header */
header= &cdf->header; header= &cdf->header;
strcpy(header->ID, "BCDF"); /* strcpy(, "BCDF"); // terminator out of range */
header->ID[0]= 'B'; header->ID[1]= 'C'; header->ID[2]= 'D'; header->ID[3]= 'F';
header->endian= cdf_endian(); header->endian= cdf_endian();
header->version= CDF_VERSION; header->version= CDF_VERSION;
header->subversion= CDF_SUBVERSION; header->subversion= CDF_SUBVERSION;

View File

@@ -65,6 +65,7 @@
#include "BLI_ghash.h" #include "BLI_ghash.h"
#include "BKE_animsys.h"
#include "BKE_action.h" #include "BKE_action.h"
#include "BKE_effect.h" #include "BKE_effect.h"
#include "BKE_global.h" #include "BKE_global.h"
@@ -490,22 +491,6 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
/* inverted relation, so addtoroot shouldn't be set to zero */ /* inverted relation, so addtoroot shouldn't be set to zero */
} }
if (ob->type==OB_CAMERA) {
Camera *cam = (Camera *)ob->data;
if (cam->adt)
dag_add_driver_relation(cam->adt, dag, node, 1);
if (cam->dof_ob) {
node2 = dag_get_node(dag, cam->dof_ob);
dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Camera DoF");
}
}
if (ob->type==OB_LAMP) {
Lamp *la = (Lamp *)ob->data;
if (la->adt)
dag_add_driver_relation(la->adt, dag, node, 1);
}
if (ob->transflag & OB_DUPLI) { if (ob->transflag & OB_DUPLI) {
if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
GroupObject *go; GroupObject *go;
@@ -520,19 +505,44 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
} }
/* softbody collision */ /* softbody collision */
if((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) if ((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) {
if(modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first) if(modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first)
dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */
}
if (ob->type==OB_MBALL) { /* object data drivers */
if (ob->data) {
AnimData *adt= BKE_animdata_from_id((ID *)ob->data);
if (adt)
dag_add_driver_relation(adt, dag, node, 1);
}
/* object type/data relationships */
switch (ob->type) {
case OB_CAMERA:
{
Camera *cam = (Camera *)ob->data;
if (cam->dof_ob) {
node2 = dag_get_node(dag, cam->dof_ob);
dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Camera DoF");
}
}
break;
case OB_MBALL:
{
Object *mom= find_basis_mball(scene, ob); Object *mom= find_basis_mball(scene, ob);
if(mom!=ob) { if(mom!=ob) {
node2 = dag_get_node(dag, mom); node2 = dag_get_node(dag, mom);
dag_add_relation(dag,node,node2,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children! dag_add_relation(dag,node,node2,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children!
} }
} }
else if (ob->type==OB_CURVE) { break;
case OB_CURVE:
{
Curve *cu= ob->data; Curve *cu= ob->data;
if(cu->bevobj) { if(cu->bevobj) {
node2 = dag_get_node(dag, cu->bevobj); node2 = dag_get_node(dag, cu->bevobj);
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel"); dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel");
@@ -541,17 +551,21 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
node2 = dag_get_node(dag, cu->taperobj); node2 = dag_get_node(dag, cu->taperobj);
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper"); dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper");
} }
if (cu->adt)
dag_add_driver_relation(cu->adt, dag, node, 1);
} }
else if(ob->type==OB_FONT) { break;
case OB_FONT:
{
Curve *cu= ob->data; Curve *cu= ob->data;
if(cu->textoncurve) { if(cu->textoncurve) {
node2 = dag_get_node(dag, cu->textoncurve); node2 = dag_get_node(dag, cu->textoncurve);
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve"); dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve");
} }
} }
break;
}
/* particles */
psys= ob->particlesystem.first; psys= ob->particlesystem.first;
if(psys) { if(psys) {
GroupObject *go; GroupObject *go;
@@ -623,6 +637,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
} }
} }
/* object constraints */
for (con = ob->constraints.first; con; con=con->next) { for (con = ob->constraints.first; con; con=con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con); bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL}; ListBase targets = {NULL, NULL};
@@ -2027,6 +2042,7 @@ static void dag_object_time_update_flags(Object *ob)
if((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA; if((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA;
{ {
AnimData *adt= BKE_animdata_from_id((ID *)ob->data);
Mesh *me; Mesh *me;
Curve *cu; Curve *cu;
Lattice *lt; Lattice *lt;
@@ -2069,6 +2085,11 @@ static void dag_object_time_update_flags(Object *ob)
break; break;
} }
if(animdata_use_time(adt)) {
ob->recalc |= OB_RECALC_DATA;
adt->recalc |= ADT_RECALC_ANIM;
}
if(ob->particlesystem.first) { if(ob->particlesystem.first) {
ParticleSystem *psys= ob->particlesystem.first; ParticleSystem *psys= ob->particlesystem.first;

View File

@@ -167,22 +167,13 @@ void copy_fcurves (ListBase *dst, ListBase *src)
} }
} }
/* ---------------------- Relink --------------------------- */
#if 0
/* uses id->newid to match pointers with other copied data
* - called after single-user or other such
*/
if (icu->driver)
ID_NEW(icu->driver->ob);
#endif
/* --------------------- Finding -------------------------- */ /* --------------------- Finding -------------------------- */
/* high level function to get an fcurve from C without having the rna */
FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index) FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index)
{ {
/* anim vars */ /* anim vars */
AnimData *adt; AnimData *adt= BKE_animdata_from_id(id);
FCurve *fcu= NULL; FCurve *fcu= NULL;
/* rna vars */ /* rna vars */
@@ -190,10 +181,8 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name
PropertyRNA *prop; PropertyRNA *prop;
char *path; char *path;
adt= BKE_animdata_from_id(id);
/* only use the current action ??? */ /* only use the current action ??? */
if(adt==NULL || adt->action==NULL) if (ELEM(NULL, adt, adt->action))
return NULL; return NULL;
RNA_pointer_create(id, type, data, &ptr); RNA_pointer_create(id, type, data, &ptr);
@@ -204,12 +193,12 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name
if (path) { if (path) {
/* animation takes priority over drivers */ /* animation takes priority over drivers */
if(adt->action && adt->action->curves.first) if ((adt->action) && (adt->action->curves.first))
fcu= list_find_fcurve(&adt->action->curves, path, index); fcu= list_find_fcurve(&adt->action->curves, path, index);
/* if not animated, check if driven */ /* if not animated, check if driven */
#if 0 #if 0
if(!fcu && (adt->drivers.first)) { if ((fcu == NULL) && (adt->drivers.first)) {
fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex); fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex);
} }
#endif #endif
@@ -245,6 +234,54 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array
return NULL; return NULL;
} }
/* Get list of LinkData's containing pointers to the F-Curves which control the types of data indicated
* Lists...
* - dst: list of LinkData's matching the criteria returned.
* List must be freed after use, and is assumed to be empty when passed.
* - src: list of F-Curves to search through
* Filters...
* - dataPrefix: i.e. 'pose.bones[' or 'nodes['
* - dataName: name of entity within "" immediately following the prefix
*/
int list_find_data_fcurves (ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName)
{
FCurve *fcu;
int matches = 0;
/* sanity checks */
if (ELEM4(NULL, dst, src, dataPrefix, dataName))
return 0;
else if ((dataPrefix[0] == 0) || (dataName[0] == 0))
return 0;
/* search each F-Curve one by one */
for (fcu= src->first; fcu; fcu= fcu->next) {
/* check if quoted string matches the path */
if ((fcu->rna_path) && strstr(fcu->rna_path, dataPrefix)) {
char *quotedName= BLI_getQuotedStr(fcu->rna_path, dataPrefix);
if (quotedName) {
/* check if the quoted name matches the required name */
if (strcmp(quotedName, dataName) == 0) {
LinkData *ld= MEM_callocN(sizeof(LinkData), "list_find_data_fcurves");
ld->data= fcu;
BLI_addtail(dst, ld);
matches++;
}
/* always free the quoted string, since it needs freeing */
MEM_freeN(quotedName);
}
}
}
/* return the number of matches */
return matches;
}
/* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */ /* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */
#define BEZT_BINARYSEARCH_THRESH 0.00001f #define BEZT_BINARYSEARCH_THRESH 0.00001f

View File

@@ -53,8 +53,6 @@
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_types.h" #include "RNA_types.h"
#include "AUD_C-API.h"
#ifndef DISABLE_PYTHON #ifndef DISABLE_PYTHON
#include "BPY_extern.h" /* for BPY_pydriver_eval() */ #include "BPY_extern.h" /* for BPY_pydriver_eval() */
#endif #endif
@@ -873,96 +871,6 @@ static FModifierTypeInfo FMI_LIMITS = {
fcm_limits_evaluate /* evaluate */ fcm_limits_evaluate /* evaluate */
}; };
/* Sound F-Curve Modifier --------------------------- */
static void fcm_sound_new_data (void *mdata)
{
FMod_Sound *data= (FMod_Sound *)mdata;
/* defaults */
data->strength= 1.0f;
data->delay = 0.0f;
data->modification = FCM_SOUND_MODIF_REPLACE;
data->sound = NULL;
}
static void fcm_sound_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
{
FMod_Sound *data= (FMod_Sound *)fcm->data;
float amplitude;
AUD_Device *device;
AUD_Sound *limiter;
AUD_SoundInfo info;
// XXX fixme - need to get in terms of time instead of frames to be really useful
// evaltime = FRA2TIME(evaltime);
evaltime -= data->delay;
/* sound-system cannot cope with negative times/frames */
if (evaltime < 0.0f)
return;
/* must have a sound with a cache so that this can be used */
if (ELEM(NULL, data->sound, data->sound->cache))
return;
/* examine this snippet of the wave, and extract the amplitude from it */
info = AUD_getInfo(data->sound->cache);
info.specs.channels = 1;
info.specs.format = AUD_FORMAT_FLOAT32;
device = AUD_openReadDevice(info.specs);
limiter = AUD_limitSound(data->sound->cache, evaltime, evaltime + 1);
AUD_playDevice(device, limiter);
AUD_unload(limiter);
AUD_readDevice(device, (sample_t*)&amplitude, 1);
AUD_closeReadDevice(device);
/* combine the amplitude with existing motion data */
switch (data->modification) {
case FCM_SOUND_MODIF_ADD:
*cvalue= *cvalue + amplitude * data->strength;
break;
case FCM_SOUND_MODIF_SUBTRACT:
*cvalue= *cvalue - amplitude * data->strength;
break;
case FCM_SOUND_MODIF_MULTIPLY:
*cvalue= *cvalue * amplitude * data->strength;
break;
case FCM_SOUND_MODIF_REPLACE:
default:
*cvalue= *cvalue + amplitude * data->strength;
break;
}
}
static float fcm_sound_time (FCurve *fcu, FModifier *fcm, float cvalue, float evaltime)
{
FMod_Sound *data= (FMod_Sound *)fcm->data;
/* check for the time delay */
// evaltime = FRA2TIME(evaltime);
if(evaltime < data->delay)
return data->delay;
/* modifier doesn't change time */
return evaltime;
}
static FModifierTypeInfo FMI_SOUND = {
FMODIFIER_TYPE_SOUND, /* type */
sizeof(FMod_Sound), /* size */
FMI_TYPE_REPLACE_VALUES, /* action type */
0, /* requirements */
"Sound", /* name */
"FMod_Sound", /* struct name */
NULL, /* free data */
NULL, /* copy data */
fcm_sound_new_data, /* new data */
NULL, /* verify */
fcm_sound_time, /* evaluate time */
fcm_sound_evaluate /* evaluate */
};
/* F-Curve Modifier API --------------------------- */ /* F-Curve Modifier API --------------------------- */
/* All of the F-Curve Modifier api functions use FModifierTypeInfo structs to carry out /* All of the F-Curve Modifier api functions use FModifierTypeInfo structs to carry out
* and operations that involve F-Curve modifier specific code. * and operations that involve F-Curve modifier specific code.
@@ -984,7 +892,6 @@ static void fmods_init_typeinfo ()
fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented
fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */ fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */
fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */ fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */
fmodifiersTypeInfo[9]= &FMI_SOUND; /* Sound F-Curve Modifier */
} }
/* This function should be used for getting the appropriate type-info when only /* This function should be used for getting the appropriate type-info when only

View File

@@ -32,6 +32,7 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <stddef.h>
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
@@ -1395,7 +1396,7 @@ Key *ob_get_key(Object *ob)
return NULL; return NULL;
} }
KeyBlock *add_keyblock(Scene *scene, Key *key) KeyBlock *add_keyblock(Key *key, char *name)
{ {
KeyBlock *kb; KeyBlock *kb;
float curpos= -0.1; float curpos= -0.1;
@@ -1409,8 +1410,14 @@ KeyBlock *add_keyblock(Scene *scene, Key *key)
kb->type= KEY_CARDINAL; kb->type= KEY_CARDINAL;
tot= BLI_countlist(&key->block); tot= BLI_countlist(&key->block);
if(name) {
strncpy(kb->name, name, sizeof(kb->name));
} else {
if(tot==1) strcpy(kb->name, "Basis"); if(tot==1) strcpy(kb->name, "Basis");
else sprintf(kb->name, "Key %d", tot-1); else sprintf(kb->name, "Key %d", tot-1);
}
BLI_uniquename(&key->block, kb, "Key", '.', offsetof(KeyBlock, name), sizeof(kb->name));
// XXX this is old anim system stuff? (i.e. the 'index' of the shapekey) // XXX this is old anim system stuff? (i.e. the 'index' of the shapekey)
kb->adrcode= tot-1; kb->adrcode= tot-1;
@@ -1516,3 +1523,185 @@ char *key_get_curValue_rnaPath(Key *key, KeyBlock *kb)
/* return the path */ /* return the path */
return RNA_path_from_ID_to_property(&ptr, prop); return RNA_path_from_ID_to_property(&ptr, prop);
} }
/* conversion functions */
/************************* Lattice ************************/
void latt_to_key(Lattice *lt, KeyBlock *kb)
{
BPoint *bp;
float *fp;
int a, tot;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
if(tot==0) return;
if(kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(lt->key->elemsize*tot, "kb->data");
kb->totelem= tot;
bp= lt->def;
fp= kb->data;
for(a=0; a<kb->totelem; a++, fp+=3, bp++) {
VECCOPY(fp, bp->vec);
}
}
void key_to_latt(KeyBlock *kb, Lattice *lt)
{
BPoint *bp;
float *fp;
int a, tot;
bp= lt->def;
fp= kb->data;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
tot= MIN2(kb->totelem, tot);
for(a=0; a<tot; a++, fp+=3, bp++) {
VECCOPY(bp->vec, fp);
}
}
/************************* Curve ************************/
void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
{
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
float *fp;
int a, tot;
/* count */
tot= count_curveverts(nurb);
if(tot==0) return;
if(kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(cu->key->elemsize*tot, "kb->data");
kb->totelem= tot;
nu= nurb->first;
fp= kb->data;
while(nu) {
if(nu->bezt) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
VECCOPY(fp, bezt->vec[0]);
fp+= 3;
VECCOPY(fp, bezt->vec[1]);
fp+= 3;
VECCOPY(fp, bezt->vec[2]);
fp+= 3;
fp[0]= bezt->alfa;
fp+= 3; /* alphas */
bezt++;
}
}
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
while(a--) {
VECCOPY(fp, bp->vec);
fp[3]= bp->alfa;
fp+= 4;
bp++;
}
}
nu= nu->next;
}
}
void key_to_curve(KeyBlock *kb, Curve *cu, ListBase *nurb)
{
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
float *fp;
int a, tot;
nu= nurb->first;
fp= kb->data;
tot= count_curveverts(nurb);
tot= MIN2(kb->totelem, tot);
while(nu && tot>0) {
if(nu->bezt) {
bezt= nu->bezt;
a= nu->pntsu;
while(a-- && tot>0) {
VECCOPY(bezt->vec[0], fp);
fp+= 3;
VECCOPY(bezt->vec[1], fp);
fp+= 3;
VECCOPY(bezt->vec[2], fp);
fp+= 3;
bezt->alfa= fp[0];
fp+= 3; /* alphas */
tot-= 3;
bezt++;
}
}
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
while(a-- && tot>0) {
VECCOPY(bp->vec, fp);
bp->alfa= fp[3];
fp+= 4;
tot--;
bp++;
}
}
nu= nu->next;
}
}
/************************* Mesh ************************/
void mesh_to_key(Mesh *me, KeyBlock *kb)
{
MVert *mvert;
float *fp;
int a;
if(me->totvert==0) return;
if(kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(me->key->elemsize*me->totvert, "kb->data");
kb->totelem= me->totvert;
mvert= me->mvert;
fp= kb->data;
for(a=0; a<kb->totelem; a++, fp+=3, mvert++) {
VECCOPY(fp, mvert->co);
}
}
void key_to_mesh(KeyBlock *kb, Mesh *me)
{
MVert *mvert;
float *fp;
int a, tot;
mvert= me->mvert;
fp= kb->data;
tot= MIN2(kb->totelem, me->totvert);
for(a=0; a<tot; a++, fp+=3, mvert++) {
VECCOPY(mvert->co, fp);
}
}

View File

@@ -38,6 +38,7 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@@ -844,18 +845,8 @@ void free_main(Main *mainvar)
ID *find_id(char *type, char *name) /* type: "OB" or "MA" etc */ ID *find_id(char *type, char *name) /* type: "OB" or "MA" etc */
{ {
ID *id; ListBase *lb= wich_libbase(G.main, GS(type));
ListBase *lb; return BLI_findstring(lb, name, offsetof(ID, name) + 2);
lb= wich_libbase(G.main, GS(type));
id= lb->first;
while(id) {
if(id->name[2]==name[0] && strcmp(id->name+2, name)==0 )
return id;
id= id->next;
}
return 0;
} }
static void get_flags_for_id(ID *id, char *buf) static void get_flags_for_id(ID *id, char *buf)
@@ -1033,6 +1024,28 @@ static void sort_alpha_id(ListBase *lb, ID *id)
} }
/*
* Check to see if there is an ID with the same name as 'name'.
* Returns the ID if so, if not, returns NULL
*/
static ID *is_dupid(ListBase *lb, ID *id, char *name)
{
ID *idtest=NULL;
for( idtest = lb->first; idtest; idtest = idtest->next ) {
/* if idtest is not a lib */
if( id != idtest && idtest->lib == NULL ) {
/* do not test alphabetic! */
/* optimized */
if( idtest->name[2] == name[0] ) {
if(strcmp(name, idtest->name+2)==0) break;
}
}
}
return idtest;
}
/* /*
* Check to see if an ID name is already used, and find a new one if so. * Check to see if an ID name is already used, and find a new one if so.
* Return 1 if created a new name (returned in name). * Return 1 if created a new name (returned in name).
@@ -1056,16 +1069,7 @@ int check_for_dupid(ListBase *lb, ID *id, char *name)
while (1) { while (1) {
/* phase 1: id already exists? */ /* phase 1: id already exists? */
for( idtest = lb->first; idtest; idtest = idtest->next ) { idtest = is_dupid(lb, id, name);
/* if idtest is not a lib */
if( id != idtest && idtest->lib == NULL ) {
/* do not test alphabetic! */
/* optimized */
if( idtest->name[2] == name[0] ) {
if(strcmp(name, idtest->name+2)==0) break;
}
}
}
/* if there is no double, done */ /* if there is no double, done */
if( idtest == NULL ) return 0; if( idtest == NULL ) return 0;
@@ -1104,9 +1108,21 @@ int check_for_dupid(ListBase *lb, ID *id, char *name)
} }
} }
/* if non-numbered name was not in use, reuse it */ /* If the original name has no numeric suffix,
if(nr==0) strcpy( name, left ); * rather than just chopping and adding numbers,
else { * shave off the end chars until we have a unique name */
if (nr==0) {
int len = strlen(name)-1;
idtest= is_dupid(lb, id, name);
while (idtest && len> 1) {
name[len--] = '\0';
idtest= is_dupid(lb, id, name);
}
if (idtest == NULL) return 1;
/* otherwise just continue and use a number suffix */
}
if(nr > 999 && strlen(left) > 16) { if(nr > 999 && strlen(left) > 16) {
/* this would overflow name buffer */ /* this would overflow name buffer */
left[16] = 0; left[16] = 0;
@@ -1115,7 +1131,7 @@ int check_for_dupid(ListBase *lb, ID *id, char *name)
} }
/* this format specifier is from hell... */ /* this format specifier is from hell... */
sprintf(name, "%s.%.3d", left, nr); sprintf(name, "%s.%.3d", left, nr);
}
return 1; return 1;
} }
} }
@@ -1311,11 +1327,7 @@ void test_idbutton(char *name)
if(lb==0) return; if(lb==0) return;
/* search for id */ /* search for id */
idtest= lb->first; idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2);
while(idtest) {
if( strcmp(idtest->name+2, name)==0) break;
idtest= idtest->next;
}
if(idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest); if(idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest);
} }

View File

@@ -41,6 +41,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "DNA_ID.h" #include "DNA_ID.h"
#include "DNA_anim_types.h"
#include "DNA_curve_types.h" #include "DNA_curve_types.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include "DNA_material_types.h" #include "DNA_material_types.h"
@@ -51,6 +52,7 @@
#include "DNA_meshdata_types.h" #include "DNA_meshdata_types.h"
#include "DNA_ipo_types.h" #include "DNA_ipo_types.h"
#include "BKE_animsys.h"
#include "BKE_customdata.h" #include "BKE_customdata.h"
#include "BKE_depsgraph.h" #include "BKE_depsgraph.h"
#include "BKE_main.h" #include "BKE_main.h"
@@ -144,6 +146,11 @@ void free_mesh(Mesh *me)
CustomData_free(&me->edata, me->totedge); CustomData_free(&me->edata, me->totedge);
CustomData_free(&me->fdata, me->totface); CustomData_free(&me->fdata, me->totface);
if(me->adt) {
BKE_free_animdata(&me->id);
me->adt= NULL;
}
if(me->mat) MEM_freeN(me->mat); if(me->mat) MEM_freeN(me->mat);
if(me->bb) MEM_freeN(me->bb); if(me->bb) MEM_freeN(me->bb);

View File

@@ -47,6 +47,7 @@
#include "DNA_constraint_types.h" #include "DNA_constraint_types.h"
#include "DNA_curve_types.h" #include "DNA_curve_types.h"
#include "DNA_group_types.h" #include "DNA_group_types.h"
#include "DNA_key_types.h"
#include "DNA_lamp_types.h" #include "DNA_lamp_types.h"
#include "DNA_lattice_types.h" #include "DNA_lattice_types.h"
#include "DNA_material_types.h" #include "DNA_material_types.h"
@@ -2397,6 +2398,10 @@ void object_handle_update(Scene *scene, Object *ob)
if(ob->type==OB_MESH) { if(ob->type==OB_MESH) {
EditMesh *em = BKE_mesh_get_editmesh(ob->data); EditMesh *em = BKE_mesh_get_editmesh(ob->data);
/* evaluate drivers */
// XXX: should we push this to derivedmesh instead?
BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS);
// here was vieweditdatamask? XXX // here was vieweditdatamask? XXX
if(ob->mode & OB_MODE_EDIT) { if(ob->mode & OB_MODE_EDIT) {
makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH); makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH);
@@ -2625,3 +2630,100 @@ void object_delete_ptcache(Object *ob, int index)
BLI_freelinkN(&ob->pc_ids, link); BLI_freelinkN(&ob->pc_ids, link);
} }
#endif #endif
/* shape key utility function */
/************************* Mesh ************************/
static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_mix)
{
Mesh *me= ob->data;
Key *key= me->key;
KeyBlock *kb;
int newkey= 0;
if(key == NULL) {
key= me->key= add_key((ID *)me);
key->type= KEY_RELATIVE;
newkey= 1;
}
kb= add_keyblock(key, name);
if(newkey || from_mix==FALSE) {
/* create from mesh */
mesh_to_key(me, kb);
}
else {
/* copy from current values */
kb->data= do_ob_key(scene, ob);
kb->totelem= me->totvert;
}
return kb;
}
/************************* Lattice ************************/
static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_mix)
{
Lattice *lt= ob->data;
Key *key= lt->key;
KeyBlock *kb;
int newkey= 0;
if(key==NULL) {
key= lt->key= add_key( (ID *)lt);
key->type= KEY_RELATIVE;
newkey= 1;
}
kb= add_keyblock(key, name);
if(newkey || from_mix==FALSE) {
/* create from lattice */
latt_to_key(lt, kb);
}
else {
/* copy from current values */
kb->totelem= lt->pntsu*lt->pntsv*lt->pntsw;
kb->data= do_ob_key(scene, ob);
}
return kb;
}
/************************* Curve ************************/
static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_mix)
{
Curve *cu= ob->data;
Key *key= cu->key;
KeyBlock *kb;
ListBase *lb= (cu->editnurb)? cu->editnurb: &cu->nurb;
int newkey= 0;
if(key==NULL) {
key= cu->key= add_key( (ID *)cu);
key->type = KEY_RELATIVE;
newkey= 1;
}
kb= add_keyblock(key, name);
if(newkey || from_mix==FALSE) {
/* create from curve */
curve_to_key(cu, kb, lb);
}
else {
/* copy from current values */
kb->totelem= count_curveverts(lb);
kb->data= do_ob_key(scene, ob);
}
return kb;
}
KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, char *name, int from_mix)
{
if(ob->type==OB_MESH) return insert_meshkey(scene, ob, name, from_mix);
else if ELEM(ob->type, OB_CURVE, OB_SURF)return insert_curvekey(scene, ob, name, from_mix);
else if(ob->type==OB_LATTICE) return insert_lattkey(scene, ob, name, from_mix);
else return NULL;
}

View File

@@ -2444,7 +2444,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
mul_m4_v3(ob->obmat,cpa_1st); mul_m4_v3(ob->obmat,cpa_1st);
} }
pa = psys->particles + cpa->parent; pa = psys->particles + cpa->pa[0];
psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat);
@@ -4069,7 +4069,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
else{ else{
if(cpa){ if(cpa){
ParticleKey *key1; ParticleKey *key1;
float t = (cfra - pa->time + pa->loop * pa->lifetime) / pa->lifetime; float t = (cfra - pa->time) / pa->lifetime;
key1=&pa->state; key1=&pa->state;
offset_child(cpa, key1, state, part->childflat, part->childrad); offset_child(cpa, key1, state, part->childflat, part->childrad);

View File

@@ -37,6 +37,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_boid_types.h" #include "DNA_boid_types.h"
#include "DNA_particle_types.h" #include "DNA_particle_types.h"
#include "DNA_mesh_types.h" #include "DNA_mesh_types.h"
@@ -62,6 +63,7 @@
#include "BLI_threads.h" #include "BLI_threads.h"
#include "BKE_anim.h" #include "BKE_anim.h"
#include "BKE_animsys.h"
#include "BKE_boids.h" #include "BKE_boids.h"
#include "BKE_cdderivedmesh.h" #include "BKE_cdderivedmesh.h"
#include "BKE_collision.h" #include "BKE_collision.h"
@@ -170,6 +172,12 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
PARTICLE_P; PARTICLE_P;
int totpart, totsaved = 0; int totpart, totsaved = 0;
if(psys->edit && psys->free_edit) {
psys->free_edit(psys->edit);
psys->edit = NULL;
psys->free_edit = NULL;
}
if(new_totpart<0) { if(new_totpart<0) {
if(part->distr==PART_DISTR_GRID && part->from != PART_FROM_VERT) { if(part->distr==PART_DISTR_GRID && part->from != PART_FROM_VERT) {
totpart= part->grid_res; totpart= part->grid_res;
@@ -389,7 +397,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
pa->fuv[1]=min[1]+(float)j*d; pa->fuv[1]=min[1]+(float)j*d;
pa->fuv[2]=min[2]+(float)k*d; pa->fuv[2]=min[2]+(float)k*d;
pa->flag |= PARS_UNEXIST; pa->flag |= PARS_UNEXIST;
pa->loop=0; /* abused in volume calculation */ pa->hair_index=0; /* abused in volume calculation */
} }
} }
} }
@@ -451,7 +459,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
if(from==PART_FROM_FACE) if(from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else /* store number of intersections */ else /* store number of intersections */
(pa+(int)(lambda*size[a])*a0mul)->loop++; (pa+(int)(lambda*size[a])*a0mul)->hair_index++;
} }
if(mface->v4){ if(mface->v4){
@@ -461,20 +469,20 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
if(from==PART_FROM_FACE) if(from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else else
(pa+(int)(lambda*size[a])*a0mul)->loop++; (pa+(int)(lambda*size[a])*a0mul)->hair_index++;
} }
} }
} }
if(from==PART_FROM_VOLUME){ if(from==PART_FROM_VOLUME){
int in=pa->loop%2; int in=pa->hair_index%2;
if(in) pa->loop++; if(in) pa->hair_index++;
for(i=0; i<size[0]; i++){ for(i=0; i<size[0]; i++){
if(in || (pa+i*a0mul)->loop%2) if(in || (pa+i*a0mul)->hair_index%2)
(pa+i*a0mul)->flag &= ~PARS_UNEXIST; (pa+i*a0mul)->flag &= ~PARS_UNEXIST;
/* odd intersections == in->out / out->in */ /* odd intersections == in->out / out->in */
/* even intersections -> in stays same */ /* even intersections -> in stays same */
in=(in + (pa+i*a0mul)->loop) % 2; in=(in + (pa+i*a0mul)->hair_index) % 2;
} }
} }
} }
@@ -1584,7 +1592,7 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p)
pa->flag &= ~PARS_UNEXIST; pa->flag &= ~PARS_UNEXIST;
} }
pa->loop=0; pa->hair_index=0;
/* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */ /* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */
/* usage other than straight after distribute has to handle this index by itself - jahka*/ /* usage other than straight after distribute has to handle this index by itself - jahka*/
//pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we dont have a derived mesh face */ //pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we dont have a derived mesh face */
@@ -1714,8 +1722,11 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
} }
else{ else{
/* get precise emitter matrix if particle is born */ /* get precise emitter matrix if particle is born */
if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= sim->psys->cfra) if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= sim->psys->cfra) {
/* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
BKE_animsys_evaluate_animdata(&sim->ob->id, sim->ob->adt, pa->time, ADT_RECALC_ANIM);
where_is_object_time(sim->scene, sim->ob, pa->time); where_is_object_time(sim->scene, sim->ob, pa->time);
}
/* get birth location from object */ /* get birth location from object */
if(part->tanfac!=0.0) if(part->tanfac!=0.0)
@@ -3215,14 +3226,6 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
reset_particle(sim, pa, dtime, cfra); reset_particle(sim, pa, dtime, cfra);
if(cfra > pa->time && part->flag & PART_LOOP && part->type!=PART_HAIR){
pa->loop = (short)((cfra-pa->time)/pa->lifetime);
pa->alive = PARS_UNBORN;
}
else{
pa->loop = 0;
}
} }
if(vg_size) if(vg_size)
@@ -3276,7 +3279,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
//if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0) //if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0)
// react_to_events(psys,p); // react_to_events(psys,p);
birthtime = pa->time + pa->loop * pa->lifetime; birthtime = pa->time;
dietime = birthtime + pa->lifetime; dietime = birthtime + pa->lifetime;
pa_dfra = dfra; pa_dfra = dfra;
@@ -3300,8 +3303,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* nothing to be done when particle is dead */ /* nothing to be done when particle is dead */
} }
/* only reset unborn particles if they're shown */ /* only reset unborn particles if they're shown or if the particle is born soon*/
if(pa->alive==PARS_UNBORN && part->flag & PART_UNBORN) if(pa->alive==PARS_UNBORN
&& (part->flag & PART_UNBORN || cfra + psys->pointcache->step > pa->time))
reset_particle(sim, pa, dtime, cfra); reset_particle(sim, pa, dtime, cfra);
if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){
@@ -3335,16 +3339,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
if(pa->alive == PARS_DYING){ if(pa->alive == PARS_DYING){
//push_reaction(ob,psys,p,PART_EVENT_DEATH,&pa->state); //push_reaction(ob,psys,p,PART_EVENT_DEATH,&pa->state);
if(part->flag & PART_LOOP && part->type!=PART_HAIR){
pa->loop++;
reset_particle(sim, pa, 0.0, cfra);
pa->alive=PARS_ALIVE;
}
else{
pa->alive=PARS_DEAD; pa->alive=PARS_DEAD;
pa->state.time=pa->dietime; pa->state.time=pa->dietime;
} }
}
else else
pa->state.time=cfra; pa->state.time=cfra;
@@ -3394,13 +3391,8 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
psys->lattice= psys_get_lattice(sim); psys->lattice= psys_get_lattice(sim);
if(part->flag & PART_LOOP && part->type!=PART_HAIR) birthtime = pa->time;
pa->loop = (short)((cfra - pa->time) / pa->lifetime); dietime = pa->dietime;
else
pa->loop = 0;
birthtime = pa->time + pa->loop * pa->lifetime;
dietime = birthtime + (1 + pa->loop) * (pa->dietime - pa->time);
/* update alive status and push events */ /* update alive status and push events */
if(pa->time > cfra) { if(pa->time > cfra) {

View File

@@ -252,7 +252,12 @@ void free_scene(Scene *sce)
/* do not free objects! */ /* do not free objects! */
if(sce->gpd) { if(sce->gpd) {
#if 0 // removed since this can be invalid memory when freeing everything
// since the grease pencil data is free'd before the scene.
// since grease pencil data is not (yet?), shared between objects
// its probably safe not to do this, some save and reload will free this.
sce->gpd->id.us--; sce->gpd->id.us--;
#endif
sce->gpd= NULL; sce->gpd= NULL;
} }
@@ -452,6 +457,8 @@ Scene *add_scene(char *name)
/* game data */ /* game data */
sce->gm.stereoflag = STEREO_NOSTEREO; sce->gm.stereoflag = STEREO_NOSTEREO;
sce->gm.stereomode = STEREO_ANAGLYPH; sce->gm.stereomode = STEREO_ANAGLYPH;
sce->gm.eyeseparation = 0.10;
sce->gm.dome.angle = 180; sce->gm.dome.angle = 180;
sce->gm.dome.mode = DOME_FISHEYE; sce->gm.dome.mode = DOME_FISHEYE;
sce->gm.dome.res = 4; sce->gm.dome.res = 4;

View File

@@ -52,13 +52,3 @@
* since we have to force clearing all Python related data before freeing * since we have to force clearing all Python related data before freeing
* Blender's library. Still testing, will decide later (Willian). */ * Blender's library. Still testing, will decide later (Willian). */
//XXX
#if 0
void free_script (Script *script)
{
if (!script) return;
#ifndef DISABLE_PYTHON
BPY_clear_script(script);
#endif
}
#endif

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