This commit is contained in:
2009-11-11 10:44:46 +00:00
460 changed files with 24614 additions and 25956 deletions

View File

@@ -91,18 +91,6 @@ IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
IF (WITH_OPENCOLLADA AND NOT APPLE)
SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA})
SET(OPENCOLLADA_LIB OpenCollada)
SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
SET(PCRE_LIBPATH ${PCRE}/lib)
SET(PCRE_LIB pcre)
SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
SET(EXPAT_LIBPATH ${EXPAT}/lib)
SET(EXPAT_LIB expat)
ENDIF (WITH_OPENCOLLADA AND NOT APPLE)
# For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
# On Unix:
# cmake -D PYTHON_LIB=/usr/local/lib/python2.3/config/libpython2.3.so -D PYTHON_INC=/usr/local/include/python2.3 -D PYTHON_BINARY=/usr/local/bin/python2.3 -G "Unix Makefiles" ../blender
@@ -119,6 +107,8 @@ INCLUDE(CMake/macros.cmake)
#Platform specifics
IF(UNIX AND NOT APPLE)
IF(WITH_OPENAL)
FIND_PACKAGE(OpenAL)
IF(OPENAL_FOUND)
@@ -217,6 +207,20 @@ IF(UNIX AND NOT APPLE)
FIND_PACKAGE(ZLIB REQUIRED)
IF (WITH_OPENCOLLADA)
SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA})
SET(OPENCOLLADA_LIB OpenCollada)
SET(OPENCOLLADA_INC ${OPENCOLLADA})
SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
SET(PCRE_LIBPATH ${PCRE}/lib)
SET(PCRE_LIB pcre)
SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
SET(EXPAT_LIBPATH ${EXPAT}/lib)
SET(EXPAT_LIB expat)
ENDIF (WITH_OPENCOLLADA)
# Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
@@ -400,6 +404,16 @@ IF(WIN32)
SET(WINTAB_INC ${LIBDIR}/wintab/include)
SET(OPENCOLLADA ${LIBDIR}/opencollada)
SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 )
#pcre is bundled with openCollada
#SET(PCRE ${LIBDIR}/pcre)
#SET(PCRE_LIBPATH ${PCRE}/lib)
SET(PCRE_LIB pcre)
IF(CMAKE_CL_64)
SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
ELSE(CMAKE_CL_64)
@@ -532,10 +546,10 @@ IF(APPLE)
#SET(PCRE ${LIBDIR}/pcre)
#SET(PCRE_LIBPATH ${PCRE}/lib)
SET(PCRE_LIB pcre)
#native OSX libxml2 is used
#libxml2 is used
#SET(EXPAT ${LIBDIR}/expat)
#SET(EXPAT_LIBPATH ${EXPAT}/lib)
#SET(EXPAT_LIB expat)
SET(EXPAT_LIB)
ENDIF (WITH_OPENCOLLADA)
SET(SDL ${LIBDIR}/sdl)

View File

@@ -31,7 +31,7 @@ elif cmd_res[0]=='9':
elif cmd_res[0]=='10':
MAC_CUR_VER='10.6'
if MAC_PROC == 'powerpc':
if MACOSX_ARCHITECTURE == 'ppc':
LCGDIR = '#../lib/darwin-6.1-powerpc'
else :
LCGDIR = '#../lib/darwin-9.x.universal'
@@ -39,7 +39,7 @@ LIBDIR = '${LCGDIR}'
BF_PYTHON_VERSION = '3.1'
if MAC_PROC == 'powerpc' and BF_PYTHON_VERSION == '2.3':
if MACOSX_ARCHITECTURE == 'ppc' and BF_PYTHON_VERSION == '2.3':
MAC_MIN_VERS = '10.3'
MACOSX_SDK='/Developer/SDKs/MacOSX10.3.9.sdk'
CC = 'gcc'
@@ -247,7 +247,20 @@ BF_OPENGL_LIBPATH = '/System/Library/Frameworks/OpenGL.framework/Libraries'
BF_OPENGL_LINKFLAGS = ['-framework', 'OpenGL']
#OpenCollada flags
WITH_BF_COLLADA = False
WITH_BF_COLLADA = True
BF_COLLADA = '#source/blender/collada'
BF_COLLADA_INC = '${BF_COLLADA}'
BF_COLLADA_LIB = 'bf_collada'
BF_OPENCOLLADA = LIBDIR + '/opencollada'
BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
BF_OPENCOLLADA_LIB = 'OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2'
BF_OPENCOLLADA_LIBPATH = LIBDIR + '/opencollada'
BF_PCRE = LIBDIR + '/opencollada'
BF_PCRE_LIB = 'pcre'
BF_PCRE_LIBPATH = '${BF_PCRE}/lib'
#BF_EXPAT = '/usr'
#BF_EXPAT_LIB = 'expat'
#BF_EXPAT_LIBPATH = '/usr/lib'
#############################################################################
################### various compile settings and flags ##################

6
extern/Makefile vendored
View File

@@ -34,7 +34,7 @@ DIRS = glew/src
# Cloth requires it
ifeq ($(NAN_USE_BULLET), true)
DIRS += bullet2
DIRS += bullet2
endif
ifeq ($(WITH_BINRELOC), true)
@@ -42,7 +42,9 @@ ifeq ($(WITH_BINRELOC), true)
endif
ifeq ($(WITH_OPENJPEG), true)
DIRS += libopenjpeg
ifndef BF_OPENJPEG
DIRS += libopenjpeg
endif
endif
ifeq ($(WITH_LZO), true)

View File

@@ -202,7 +202,6 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
}
input.m_stackAlloc = dispatchInfo.m_stackAllocator;
input.m_transformA = body0->getWorldTransform();
input.m_transformB = body1->getWorldTransform();

View File

@@ -33,7 +33,7 @@ public:
const btConvexShape* convexA,const btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
class btIDebugDraw* debugDraw
) = 0;

View File

@@ -41,15 +41,13 @@ struct btDiscreteCollisionDetectorInterface
struct ClosestPointInput
{
ClosestPointInput()
:m_maximumDistanceSquared(btScalar(1e30)),
m_stackAlloc(0)
:m_maximumDistanceSquared(btScalar(1e30))
{
}
btTransform m_transformA;
btTransform m_transformB;
btScalar m_maximumDistanceSquared;
btStackAlloc* m_stackAlloc;
};
virtual ~btDiscreteCollisionDetectorInterface() {};

View File

@@ -25,7 +25,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB,
btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc )
class btIDebugDraw* debugDraw )
{
(void)debugDraw;

View File

@@ -29,7 +29,7 @@ class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB,
btVector3& v, btVector3& wWitnessOnA, btVector3& wWitnessOnB,
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
class btIDebugDraw* debugDraw );
private :

View File

@@ -293,7 +293,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
m_minkowskiA,m_minkowskiB,
localTransA,localTransB,
m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB,
debugDraw,input.m_stackAlloc
debugDraw
);
if (isValid2)

View File

@@ -71,11 +71,10 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
const btConvexShape* convexA,const btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
class btIDebugDraw* debugDraw
)
{
(void)stackAlloc;
(void)v;

View File

@@ -28,7 +28,7 @@ public:
const btConvexShape* convexA,const btConvexShape* convexB,
const btTransform& transA,const btTransform& transB,
btVector3& v, btVector3& pa, btVector3& pb,
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
class btIDebugDraw* debugDraw
);
};

View File

@@ -365,10 +365,6 @@ double plNearestPoints(float p1[3], float p2[3], float p3[3], float q1[3], float
btPointCollector gjkOutput;
btGjkPairDetector::ClosestPointInput input;
btStackAlloc gStackAlloc(1024*1024*2);
input.m_stackAlloc = &gStackAlloc;
btTransform tr;
tr.setIdentity();

View File

@@ -5,8 +5,5 @@ sources = env.Glob('intern/*.cpp')
incs = 'intern ../container ../moto/include ../memutil'
if (env['OURPLATFORM'] == 'win32-mingw'):
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=26 )
else:
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=20 )
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=200 )

View File

@@ -5,4 +5,4 @@ sources = env.Glob('intern/*.cpp')
incs = '. ../moto/include ../container ../memutil'
env.BlenderLib ('bf_decimation', sources, Split(incs) , [], libtype=['core'], priority = [10] )
env.BlenderLib ('bf_decimation', sources, Split(incs) , [], libtype=['core'], priority = [200] )

View File

@@ -406,6 +406,17 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
GHOST_TButtonMask mask,
int* isDown);
/***************************************************************************************
** Drag'n'drop operations
***************************************************************************************/
/**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
extern void GHOST_setAcceptDragOperation(GHOST_SystemHandle systemhandle, GHOST_TInt8 canAccept);
/**
* Returns the event type.
* @param eventhandle The handle to the event

View File

@@ -351,6 +351,11 @@ public:
*/
virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const = 0;
/***************************************************************************************
** Access to clipboard.
***************************************************************************************/
/**
* Returns the selection buffer
* @return Returns "unsinged char" from X11 XA_CUT_BUFFER0 buffer
@@ -363,6 +368,22 @@ public:
*/
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
/***************************************************************************************
** Drag'n'drop operations
***************************************************************************************/
/**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
virtual void setAcceptDragOperation(bool canAccept) = 0;
/**
* Returns acceptance of the dropped object
* Usually called by the "object dropped" event handling function
*/
virtual bool canAcceptDragOperation() const = 0;
protected:
/**
* Initialize the system.

View File

@@ -167,6 +167,12 @@ typedef enum {
GHOST_kEventWindowUpdate,
GHOST_kEventWindowSize,
GHOST_kEventWindowMove,
GHOST_kEventDraggingEntered,
GHOST_kEventDraggingUpdated,
GHOST_kEventDraggingExited,
GHOST_kEventDraggingDropDone,
GHOST_kEventDraggingDropOnIcon,
GHOST_kEventTimer,
@@ -368,6 +374,30 @@ typedef struct {
} GHOST_TEventWheelData;
typedef enum {
GHOST_kDragnDropTypeUnknown =0,
GHOST_kDragnDropTypeFilenames, /*Array of strings representing file names (full path) */
GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string */
GHOST_kDragnDropTypeBitmap /*Bitmap image data */
} GHOST_TDragnDropTypes;
typedef struct {
/** The x-coordinate of the cursor position. */
GHOST_TInt32 x;
/** The y-coordinate of the cursor position. */
GHOST_TInt32 y;
/** The dropped item type */
GHOST_TDragnDropTypes dataType;
/** The "dropped content" */
GHOST_TEventDataPtr data;
} GHOST_TEventDragnDropData;
typedef struct {
int count;
GHOST_TUns8 **strings;
} GHOST_TStringArray;
/* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
/* as all USB device controls are likely to use ints, this is also more future proof */
//typedef struct {

View File

@@ -404,6 +404,13 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
}
void GHOST_setAcceptDragOperation(GHOST_SystemHandle systemhandle, GHOST_TInt8 canAccept)
{
GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
system->setAcceptDragOperation(canAccept);
}
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
{

View File

@@ -0,0 +1,91 @@
/**
* $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): Damien Plisson 11/2009
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef _GHOST_EVENT_DRAGNDROP_H_
#define _GHOST_EVENT_DRAGNDROP_H_
#include "GHOST_Event.h"
/**
* Drag & drop event
*
* The dragging sequence is performed in four phases:
*
* <li> Start sequence (GHOST_kEventDraggingEntered) that tells a drag'n'drop operation has started. Already gives the object data type,
* and the entering mouse location
*
* <li> Update mouse position (GHOST_kEventDraggingUpdated) sent upon each mouse move until the drag'n'drop operation stops, to give the updated mouse position.
* Useful to highlight a potential destination, and update the status (through GHOST_setAcceptDragOperation) telling if the object can be dropped at
* the current cursor position.
*
* <li> Abort drag'n'drop sequence (GHOST_kEventDraggingExited) sent when the user moved the mouse outside the window.
*
* <li> Send the dropped data (GHOST_kEventDraggingDropDone)
*
* <li> Outside of the normal sequence, dropped data can be sent (GHOST_kEventDraggingDropOnIcon). This can happen when the user drops an object
* on the application icon. (Also used in OSX to pass the filename of the document the user doubled-clicked in the finder)
*
* <br><br>Note that the event handler is responsible for freeing the received data.
* <br>And the mouse positions are given in Blender coordinates (y=0 at bottom)
*
* <br>Currently supported object types :
* <li>UTF-8 string
* <li>array of strings representing filenames (GHOST_TStringArray)
* <li>bitmap image
*/
class GHOST_EventDragnDrop : public GHOST_Event
{
public:
/**
* Constructor.
* @param time The time this event was generated.
* @param type The type of this event.
* @param dataType The type of the drop candidate object
* @param window The window where the event occured
* @param x The x-coordinate of the location the cursor was at at the time of the event.
* @param y The y-coordinate of the location the cursor was at at the time of the event.
* @param data The "content" dropped in the window
*/
GHOST_EventDragnDrop(GHOST_TUns64 time, GHOST_TEventType type, GHOST_TDragnDropTypes dataType, GHOST_IWindow* window,
int x, int y, GHOST_TEventDataPtr data)
: GHOST_Event(time, type, window)
{
m_dragnDropEventData.x = x;
m_dragnDropEventData.y = y;
m_dragnDropEventData.dataType = dataType;
m_dragnDropEventData.data = data;
m_data = &m_dragnDropEventData;
}
protected:
/** The x,y-coordinates of the cursor position. */
GHOST_TEventDragnDropData m_dragnDropEventData;
};
#endif // _GHOST_EVENT_DRAGNDROP_H_

View File

@@ -54,6 +54,7 @@
GHOST_System::GHOST_System()
: m_displayManager(0), m_timerManager(0), m_windowManager(0), m_eventManager(0), m_ndofManager(0)
{
m_canAcceptDragOperation = false;
}
@@ -275,6 +276,15 @@ GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool& isDown
return success;
}
void GHOST_System::setAcceptDragOperation(bool canAccept)
{
m_canAcceptDragOperation = canAccept;
}
bool GHOST_System::canAcceptDragOperation() const
{
return m_canAcceptDragOperation;
}
GHOST_TSuccess GHOST_System::init()
{

View File

@@ -231,6 +231,21 @@ public:
* @return Indication of success.
*/
virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const;
/***************************************************************************************
** Drag'n'drop operations
***************************************************************************************/
/**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
virtual void setAcceptDragOperation(bool canAccept);
/**
* Returns acceptance of the dropped object
* Usually called by the "object dropped" event handling function
*/
virtual bool canAcceptDragOperation() const;
/***************************************************************************************
** Other (internal) functionality.
@@ -332,6 +347,9 @@ protected:
/** The N-degree of freedom device manager */
GHOST_NDOFManager* m_ndofManager;
/** The acceptance of the "drop candidate" of the current drag'n'drop operation */
bool m_canAcceptDragOperation;
/** Prints all the events. */
#ifdef GHOST_DEBUG

View File

@@ -194,11 +194,25 @@ public:
/**
* Handles a window event. Called by GHOST_WindowCocoa window delegate
* @param eventPtr An NSEvent pointer (casted to void* to enable compilation in standard C++)
* @param eventType The type of window event
* @param window The window on which the event occured
* @return Indication whether the event was handled.
*/
GHOST_TSuccess handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa* window);
/**
* Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass
* @param eventType The type of drag'n'drop event
* @param draggedObjectType The type object concerned (currently array of file names, string, TIFF image)
* @param mouseX x mouse coordinate (in cocoa base window coordinates)
* @param mouseY y mouse coordinate
* @param window The window on which the event occured
* @return Indication whether the event was handled.
*/
GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
GHOST_WindowCocoa* window, int mouseX, int mouseY, void* data);
protected:
/**
* Initializes the system.

View File

@@ -41,6 +41,7 @@
#include "GHOST_EventCursor.h"
#include "GHOST_EventWheel.h"
#include "GHOST_EventNDOF.h"
#include "GHOST_EventDragnDrop.h"
#include "GHOST_TimerManager.h"
#include "GHOST_TimerTask.h"
@@ -413,6 +414,7 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) {
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
NSLog(@"\nGet open file event from cocoa : %@",filename);
systemCocoa->handleDraggingEvent(GHOST_kEventDraggingDropOnIcon, GHOST_kDragnDropTypeFilenames, nil, 0, 0, [NSArray arrayWithObject:filename]);
return YES;
}
@@ -880,6 +882,102 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
return GHOST_kSuccess;
}
//Note: called from NSWindow subclass
GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
GHOST_WindowCocoa* window, int mouseX, int mouseY, void* data)
{
if (!validWindow(window)) {
return GHOST_kFailure;
}
switch(eventType)
{
case GHOST_kEventDraggingEntered:
setAcceptDragOperation(FALSE); //Drag operation needs to be accepted explicitely by the event manager
case GHOST_kEventDraggingUpdated:
case GHOST_kEventDraggingExited:
pushEvent(new GHOST_EventDragnDrop(getMilliSeconds(),GHOST_kEventDraggingEntered,draggedObjectType,window,mouseX,mouseY,NULL));
break;
case GHOST_kEventDraggingDropDone:
case GHOST_kEventDraggingDropOnIcon:
{
GHOST_TUns8 * temp_buff;
GHOST_TStringArray *strArray;
NSArray *droppedArray;
size_t pastedTextSize;
NSString *droppedStr;
GHOST_TEventDataPtr eventData;
int i;
if (!data) return GHOST_kFailure;
switch (draggedObjectType) {
case GHOST_kDragnDropTypeBitmap:
//TODO: implement bitmap conversion to a blender friendly format
break;
case GHOST_kDragnDropTypeFilenames:
droppedArray = (NSArray*)data;
strArray = (GHOST_TStringArray*)malloc(sizeof(GHOST_TStringArray));
if (!strArray) return GHOST_kFailure;
strArray->count = [droppedArray count];
if (strArray->count == 0) return GHOST_kFailure;
strArray->strings = (GHOST_TUns8**) malloc(strArray->count*sizeof(GHOST_TUns8*));
for (i=0;i<strArray->count;i++)
{
droppedStr = [droppedArray objectAtIndex:i];
pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
if (!temp_buff) {
strArray->count = i;
break;
}
strncpy((char*)temp_buff, [droppedStr UTF8String], pastedTextSize);
temp_buff[pastedTextSize] = '\0';
strArray->strings[i] = temp_buff;
}
eventData = (GHOST_TEventDataPtr) strArray;
break;
case GHOST_kDragnDropTypeString:
droppedStr = (NSString*)data;
pastedTextSize = [droppedStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
if (temp_buff == NULL) {
return GHOST_kFailure;
}
strncpy((char*)temp_buff, [droppedStr UTF8String], pastedTextSize);
temp_buff[pastedTextSize] = '\0';
eventData = (GHOST_TEventDataPtr) temp_buff;
break;
default:
return GHOST_kFailure;
break;
}
pushEvent(new GHOST_EventDragnDrop(getMilliSeconds(),GHOST_kEventDraggingEntered,draggedObjectType,window,mouseX,mouseY,eventData));
}
break;
default:
return GHOST_kFailure;
}
return GHOST_kSuccess;
}
GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
{
GHOST_Window* window = (GHOST_Window*)m_windowManager->getActiveWindow();

View File

@@ -40,6 +40,8 @@
#include "GHOST_Window.h"
#include "STR_String.h"
@class CocoaWindow;
class GHOST_SystemCocoa;
/**
@@ -264,7 +266,7 @@ protected:
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], GHOST_TUns8 mask[16][2], int hotX, int hotY);
/** The window containing the OpenGL view */
NSWindow *m_window;
CocoaWindow *m_window;
/** The openGL view */
NSOpenGLView *m_openGLView;

View File

@@ -124,16 +124,86 @@ extern "C" {
//We need to subclass it to tell that even borderless (fullscreen), it can become key (receive user events)
@interface CocoaWindow: NSWindow
{
GHOST_SystemCocoa *systemCocoa;
GHOST_WindowCocoa *associatedWindow;
GHOST_TDragnDropTypes m_draggedObjectType;
}
- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
@end
@implementation CocoaWindow
- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa
{
systemCocoa = sysCocoa;
associatedWindow = winCocoa;
}
-(BOOL)canBecomeKeyWindow
{
return YES;
}
//The drag'n'drop dragging destination methods
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender
{
NSPoint mouseLocation = [sender draggingLocation];
NSPasteboard *draggingPBoard = [sender draggingPasteboard];
if ([[draggingPBoard types] containsObject:NSTIFFPboardType]) m_draggedObjectType = GHOST_kDragnDropTypeBitmap;
else if ([[draggingPBoard types] containsObject:NSFilenamesPboardType]) m_draggedObjectType = GHOST_kDragnDropTypeFilenames;
else if ([[draggingPBoard types] containsObject:NSStringPboardType]) m_draggedObjectType = GHOST_kDragnDropTypeString;
else return NSDragOperationNone;
systemCocoa->handleDraggingEvent(GHOST_kEventDraggingEntered, m_draggedObjectType, associatedWindow, mouseLocation.x, mouseLocation.y, nil);
return NSDragOperationCopy;
}
- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
{
NSPoint mouseLocation = [sender draggingLocation];
systemCocoa->handleDraggingEvent(GHOST_kEventDraggingUpdated, m_draggedObjectType, associatedWindow, mouseLocation.x, mouseLocation.y, nil);
return NSDragOperationCopy;
}
- (void)draggingExited:(id < NSDraggingInfo >)sender
{
systemCocoa->handleDraggingEvent(GHOST_kEventDraggingExited, m_draggedObjectType, associatedWindow, 0, 0, nil);
m_draggedObjectType = GHOST_kDragnDropTypeUnknown;
}
- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender
{
if (systemCocoa->canAcceptDragOperation())
return YES;
else
return NO;
}
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender
{
NSPoint mouseLocation = [sender draggingLocation];
NSPasteboard *draggingPBoard = [sender draggingPasteboard];
id data;
switch (m_draggedObjectType) {
case GHOST_kDragnDropTypeBitmap:
data = [draggingPBoard dataForType:NSTIFFPboardType];
break;
case GHOST_kDragnDropTypeFilenames:
data = [draggingPBoard propertyListForType:NSFilenamesPboardType];
break;
case GHOST_kDragnDropTypeString:
data = [draggingPBoard stringForType:@"public.utf8-plain-text"];
break;
default:
return NO;
break;
}
systemCocoa->handleDraggingEvent(GHOST_kEventDraggingDropDone, m_draggedObjectType, associatedWindow, mouseLocation.x, mouseLocation.y, (void*)data);
return YES;
}
@end
@@ -207,6 +277,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
return;
}
[m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
//Forbid to resize the window below the blender defined minimum one
minSize.width = 320;
minSize.height = 240;
@@ -259,6 +331,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
[m_window setAcceptsMouseMovedEvents:YES];
[m_window registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
NSStringPboardType, NSTIFFPboardType, nil]];
if (state == GHOST_kWindowStateFullScreen)
setState(GHOST_kWindowStateFullScreen);
@@ -684,10 +759,18 @@ GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
{
GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setOrder(): window invalid")
if (order == GHOST_kWindowOrderTop) {
[m_window orderFront:nil];
[m_window makeKeyAndOrderFront:nil];
}
else {
NSArray *windowsList;
[m_window orderBack:nil];
//Check for other blender opened windows and make the frontmost key
windowsList = [NSApp orderedWindows];
if ([windowsList count]) {
[[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
}
}
return GHOST_kSuccess;
}

View File

@@ -73,6 +73,12 @@ extern "C" {
*/
short MEM_freeN(void *vmemh);
/**
* Return zero if memory is not in allocated list
*/
short MEM_testN(void *vmemh);
/**
* Duplicates a block of memory, and returns a pointer to the
* newly allocated block. */
@@ -102,6 +108,9 @@ extern "C" {
* blocks. */
void MEM_printmemlist(void);
/** calls the function on all allocated memory blocks. */
void MEM_callbackmemlist(void (*func)(void*));
/** Print statistics about memory usage */
void MEM_printmemlist_stats(void);

View File

@@ -492,6 +492,47 @@ static void MEM_printmemlist_internal( int pydict )
mem_unlock_thread();
}
void MEM_callbackmemlist(void (*func)(void*)) {
MemHead *membl;
mem_lock_thread();
membl = membase->first;
if (membl) membl = MEMNEXT(membl);
while(membl) {
func(membl+1);
if(membl->next)
membl= MEMNEXT(membl->next);
else break;
}
mem_unlock_thread();
}
short MEM_testN(void *vmemh) {
MemHead *membl;
mem_lock_thread();
membl = membase->first;
if (membl) membl = MEMNEXT(membl);
while(membl) {
if (vmemh == membl+1)
return 1;
if(membl->next)
membl= MEMNEXT(membl->next);
else break;
}
mem_unlock_thread();
print_error("Memoryblock %p: pointer not in memlist\n", vmemh);
return 0;
}
void MEM_printmemlist( void ) {
MEM_printmemlist_internal(0);
}
@@ -532,7 +573,6 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
}
mem_lock_thread();
if ((memh->tag1 == MEMTAG1) && (memh->tag2 == MEMTAG2) && ((memh->len & 0x3) == 0)) {
memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + memh->len);
if (memt->tag3 == MEMTAG3){

View File

@@ -41,6 +41,11 @@ ifeq ($(WITH_BF_OPENMP),true)
CPPFLAGS += -DPARALLEL
endif
ifeq ($(WITH_FFTW3),true)
CPPFLAGS += -DFFTW3=1
CPPFLAGS += $(BF_FFTW3_INC)
endif
CPPFLAGS += -I.
CPPFLAGS += -I../extern
CPPFLAGS += -I$(NAN_PNG)/include

View File

@@ -74,7 +74,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half.lib Iex.lib IlmImf.lib Imath.lib IlmThread.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib libsndfile-1.lib opencollada.lib"
AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half.lib Iex.lib IlmImf.lib Imath.lib IlmThread.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib libsndfile-1.lib OpenCOLLADABaseUtils.lib OpenCOLLADAFramework.lib OpenCOLLADAStreamWriter.lib OpenCOLLADASaxFrameworkLoader.lib pcre.lib UTF.lib GeneratedSaxParser.lib MathMLSolver.lib xml2.lib"
ShowProgress="0"
OutputFile="..\..\..\install\msvc_9\blender.exe"
LinkIncremental="1"
@@ -169,7 +169,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386&#x0D;&#x0A;"
AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31_d.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half_d.lib Iex_d.lib Imath_d.lib IlmImf_d.lib IlmThread_d.lib avcodec-52.lib avformat-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib libsndfile-1.lib opencollada.lib"
AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31_d.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half_d.lib Iex_d.lib Imath_d.lib IlmImf_d.lib IlmThread_d.lib avcodec-52.lib avformat-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib libsndfile-1.lib OpenCOLLADABaseUtils.lib OpenCOLLADAFramework.lib OpenCOLLADAStreamWriter.lib OpenCOLLADASaxFrameworkLoader.lib pcre.lib UTF.lib GeneratedSaxParser.lib MathMLSolver.lib xml2.lib"
ShowProgress="0"
OutputFile="..\..\..\install\msvc_9d\blender.exe"
LinkIncremental="2"

View File

@@ -661,6 +661,10 @@
RelativePath="..\..\..\source\blender\makesrna\intern\rna_fcurve.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\makesrna\intern\rna_fcurve_api.c"
>
</File>
<File
RelativePath="..\..\..\source\blender\makesrna\intern\rna_fluidsim.c"
>

View File

@@ -48,6 +48,7 @@ if filename[0] == ".":
cname = filename + ".c"
sys.stdout.write("Making C file <%s>\n" % cname)
filename = filename.split("/")[-1].split("\\")[-1]
filename = filename.replace(".", "_")
sys.stdout.write(str(size))
sys.stdout.write("\n")

View File

@@ -34,7 +34,9 @@ def addFluidFiles(job, path):
match = pattern.match(fluid_file)
if match:
current_frame = int(match.groups()[1])
# fluid frames starts at 0, which explains the +1
# This is stupid
current_frame = int(match.groups()[1]) + 1
job.addFile(path + fluid_file, current_frame, current_frame)
def addPointCache(job, ob, point_cache, default_path):

View File

View File

@@ -1,22 +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 #####
import bpy
class_obj = bpy.types.Object
class_obj.getChildren = lambda ob: [child for child in bpy.data.objects if child.parent == ob]

View File

@@ -1,19 +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 #####
import bpy_ext.Object

View File

@@ -4,12 +4,12 @@
# 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.
@@ -128,6 +128,12 @@ class bpy_ops_submodule_op(object):
__keys__ = ('module', 'func')
def _get_doc(self):
return op_as_string(self.idname())
__doc__ = property(_get_doc)
def __init__(self, module, func):
self.module = module
self.func = func

View File

@@ -0,0 +1,94 @@
# ##### 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 #####
import bpy
StructRNA = bpy.types.Struct.__bases__[0]
# StructRNA = bpy.types.Struct
class Context(StructRNA):
def copy(self):
new_context = {}
generic_keys = StructRNA.__dict__.keys()
for item in dir(self):
if item not in generic_keys:
new_context[item] = getattr(self, item)
return new_context
class Object(bpy.types.ID):
def _get_children(self):
return [child for child in bpy.data.objects if child.parent == self]
children = property(_get_children)
def ord_ind(i1,i2):
if i1<i2: return i1,i2
return i2,i1
class Mesh(bpy.types.ID):
def _get_edge_keys(self):
return [edge_key for face in self.faces for edge_key in face.edge_keys]
edge_keys = property(_get_edge_keys)
def _get_edge_face_count_dict(self):
face_edge_keys = [face.edge_keys for face in self.faces]
face_edge_count = {}
for face_keys in face_edge_keys:
for key in face_keys:
try:
face_edge_count[key] += 1
except:
face_edge_count[key] = 1
return face_edge_count
edge_face_count_dict = property(_get_edge_face_count_dict)
def _get_edge_face_count(self):
edge_face_count_dict = self.edge_face_count_dict
return [edge_face_count_dict.get(ed.key, 0) for ed in mesh.edges]
edge_face_count = property(_get_edge_face_count)
class MeshEdge(StructRNA):
def _get_key(self):
return ord_ind(*tuple(self.verts))
key = property(_get_key)
class MeshFace(StructRNA):
def _get_edge_keys(self):
verts = tuple(self.verts)
if len(verts)==3:
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[0])
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[3]), ord_ind(verts[3], verts[0])
edge_keys = property(_get_edge_keys)

View File

@@ -4,12 +4,12 @@
# 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.

View File

@@ -0,0 +1,190 @@
# Copyright (c) 2009 www.stani.be (GPL license)
# This program 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.
#
# 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import inspect
import re
# regular expression constants
DEF_DOC = '%s\s*(\(.*?\))'
DEF_SOURCE = 'def\s+%s\s*(\(.*?\)):'
RE_EMPTY_LINE = re.compile('^\s*\n')
RE_FLAG = re.MULTILINE | re.DOTALL
RE_NEWLINE = re.compile('\n+')
RE_SPACE = re.compile('\s+')
RE_DEF_COMPLETE = re.compile(
# don't start with a quote
'''(?:^|[^"'a-zA-Z0-9_])'''
# start with a \w = [a-zA-Z0-9_]
'''((\w+'''
# allow also dots and closed bracket pairs []
'''(?:\w|[.]|\[.+?\])*'''
# allow empty string
'''|)'''
# allow opening bracket(s)
'''(?:\(|\s)*)$''')
def reduce_newlines(text):
"""Reduces multiple newlines to a single newline.
:param text: text with multiple newlines
:type text: str
:returns: text with single newlines
:rtype: str
>>> reduce_newlines('hello\\n\\nworld')
'hello\\nworld'
"""
return RE_NEWLINE.sub('\n', text)
def reduce_spaces(text):
"""Reduces multiple whitespaces to a single space.
:param text: text with multiple spaces
:type text: str
:returns: text with single spaces
:rtype: str
>>> reduce_spaces('hello \\nworld')
'hello world'
"""
return RE_SPACE.sub(' ', text)
def get_doc(object):
"""Get the doc string or comments for an object.
:param object: object
:returns: doc string
:rtype: str
>>> get_doc(abs)
'abs(number) -> number\\n\\nReturn the absolute value of the argument.'
"""
result = inspect.getdoc(object) or inspect.getcomments(object)
return result and RE_EMPTY_LINE.sub('', result.rstrip()) or ''
def get_argspec(func, strip_self=True, doc=None, source=None):
"""Get argument specifications.
:param strip_self: strip `self` from argspec
:type strip_self: bool
:param doc: doc string of func (optional)
:type doc: str
:param source: source code of func (optional)
:type source: str
:returns: argument specification
:rtype: str
>>> get_argspec(inspect.getclasstree)
'(classes, unique=0)'
>>> get_argspec(abs)
'(number)'
"""
# get the function object of the class
try:
func = func.__func__
except AttributeError:
try:
# py 2.X
func = func.im_func
except AttributeError:
pass
# is callable?
if not hasattr(func, '__call__'):
return ''
# func should have a name
try:
func_name = func.__name__
except AttributeError:
return ''
# from docstring
if doc is None:
doc = get_doc(func)
match = re.search(DEF_DOC % func_name, doc, RE_FLAG)
# from source code
if not match:
if source is None:
try:
source = inspect.getsource(func)
except TypeError:
source = ''
if source:
match = re.search(DEF_SOURCE % func_name, source, RE_FLAG)
if match:
argspec = reduce_spaces(match.group(1))
else:
# try with the inspect.getarg* functions
try:
argspec = inspect.formatargspec(*inspect.getfullargspec(func))
except:
try:
# py 2.X
argspec = inspect.formatargspec(*inspect.getargspec(func))
except:
try:
argspec = inspect.formatargvalues(
*inspect.getargvalues(func))
except:
argspec = ''
if strip_self:
argspec = argspec.replace('self, ', '')
return argspec
def complete(line, cursor, namespace):
"""Complete callable with calltip.
:param line: incomplete text line
:type line: str
:param cursor: current character position
:type cursor: int
:param namespace: namespace
:type namespace: dict
:returns: (matches, world, scrollback)
:rtype: (list of str, str, str)
>>> import os
>>> complete('os.path.isdir(', 14, {'os': os})[-1]
'isdir(s)\\nReturn true if the pathname refers to an existing directory.'
>>> complete('abs(', 4, {})[-1]
'abs(number) -> number\\nReturn the absolute value of the argument.'
"""
matches = []
match = RE_DEF_COMPLETE.search(line[:cursor])
if match:
word = match.group(1)
func_word = match.group(2)
try:
func = eval(func_word, namespace)
except Exception:
func = None
scrollback = ''
if func:
doc = get_doc(func)
argspec = get_argspec(func, doc=doc)
scrollback = func_word.split('.')[-1] + (argspec or '()')
if doc.startswith(scrollback):
scrollback = doc
elif doc:
scrollback += '\n' + doc
scrollback = reduce_newlines(scrollback)
else:
word = ''
scrollback = ''
return matches, word, scrollback

View File

@@ -16,10 +16,11 @@
"""This module provides intellisense features such as:
* autocompletion
* calltips (not yet implemented)
* calltips
It unifies all completion plugins and only loads them on demand.
"""
# TODO: file complete if startswith quotes
import os
import re
@@ -63,6 +64,9 @@ def complete(line, cursor, namespace, private=True):
:type private: bool
:returns: list of completions, word
:rtype: list, str
>>> complete('re.sr', 5, {'re': re})
(['re.sre_compile', 're.sre_parse'], 're.sr')
"""
re_unquoted_word = RE_UNQUOTED_WORD.search(line[:cursor])
if re_unquoted_word:
@@ -99,14 +103,28 @@ def expand(line, cursor, namespace, private=True):
current expanded line, updated cursor position and scrollback
:rtype: str, int, str
>>> expand('os.path.isdir(', 14, {'os': os})[-1]
'isdir(s)\\nReturn true if the pathname refers to an existing directory.'
>>> expand('abs(', 4, {})[-1]
'abs(number) -> number\\nReturn the absolute value of the argument.'
"""
matches, word = complete(line, cursor, namespace, private)
if line[:cursor].strip().endswith('('):
import complete_calltip
matches, word, scrollback = complete_calltip.complete(line,
cursor, namespace)
no_calltip = False
else:
matches, word = complete(line, cursor, namespace, private)
if len(matches) == 1:
scrollback = ''
else:
scrollback = ' '.join([m.split('.')[-1] for m in matches])
no_calltip = True
prefix = os.path.commonprefix(matches)[len(word):]
if prefix:
line = line[:cursor] + prefix + line[cursor:]
cursor += len(prefix)
if len(matches) == 1:
scrollback = ''
else:
scrollback = ' '.join([m.split('.')[-1] for m in matches])
if no_calltip and prefix.endswith('('):
return expand(line, cursor, namespace, private)
return line, cursor, scrollback

View File

@@ -4,12 +4,12 @@
# 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.

View File

@@ -0,0 +1,225 @@
# ##### 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 sys
import bpy
language_id = 'python'
def add_scrollback(text, text_type):
for l in text.split('\n'):
bpy.ops.console.scrollback_append(text=l.replace('\t', ' '),
type=text_type)
def get_console(console_id):
'''
helper function for console operators
currently each text datablock gets its own
console - bpython_code.InteractiveConsole()
...which is stored in this function.
console_id can be any hashable type
'''
from code import InteractiveConsole
try:
consoles = get_console.consoles
except:
consoles = get_console.consoles = {}
# clear all dead consoles, use text names as IDs
# TODO, find a way to clear IDs
'''
for console_id in list(consoles.keys()):
if console_id not in bpy.data.texts:
del consoles[id]
'''
try:
console, stdout, stderr = consoles[console_id]
except:
namespace = {'__builtins__': __builtins__, 'bpy': bpy}
console = InteractiveConsole(namespace)
import io
stdout = io.StringIO()
stderr = io.StringIO()
consoles[console_id] = console, stdout, stderr
return console, stdout, stderr
class PyConsoleExec(bpy.types.Operator):
'''Execute the current console line as a python expression.'''
bl_idname = "console.execute_" + language_id
bl_label = "Console Execute"
bl_register = False
# Both prompts must be the same length
PROMPT = '>>> '
PROMPT_MULTI = '... '
# is this working???
'''
def poll(self, context):
return (context.space_data.type == 'PYTHON')
'''
# its not :|
def execute(self, context):
sc = context.space_data
try:
line = sc.history[-1].line
except:
return ('CANCELLED',)
if sc.console_type != 'PYTHON':
return ('CANCELLED',)
console, stdout, stderr = get_console(hash(context.region))
# Hack, useful but must add some other way to access
#if "C" not in console.locals:
console.locals["C"] = context
# redirect output
sys.stdout = stdout
sys.stderr = stderr
# run the console
if not line.strip():
line_exec = '\n' # executes a multiline statement
else:
line_exec = line
is_multiline = console.push(line_exec)
stdout.seek(0)
stderr.seek(0)
output = stdout.read()
output_err = stderr.read()
# cleanup
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
sys.last_traceback = None
# So we can reuse, clear all data
stdout.truncate(0)
stderr.truncate(0)
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
if is_multiline:
sc.prompt = self.PROMPT_MULTI
else:
sc.prompt = self.PROMPT
# insert a new blank line
bpy.ops.console.history_append(text="", current_character=0,
remove_duplicates=True)
# Insert the output into the editor
# not quite correct because the order might have changed,
# but ok 99% of the time.
if output:
add_scrollback(output, 'OUTPUT')
if output_err:
add_scrollback(output_err, 'ERROR')
return ('FINISHED',)
class PyConsoleAutocomplete(bpy.types.Operator):
'''Evaluate the namespace up until the cursor and give a list of
options or complete the name if there is only one.'''
bl_idname = "console.autocomplete_" + language_id
bl_label = "Python Console Autocomplete"
bl_register = False
def poll(self, context):
return context.space_data.console_type == 'PYTHON'
def execute(self, context):
from console import intellisense
sc = context.space_data
console = get_console(hash(context.region))[0]
current_line = sc.history[-1]
line = current_line.line
if not console:
return ('CANCELLED',)
if sc.console_type != 'PYTHON':
return ('CANCELLED',)
# This function isnt aware of the text editor or being an operator
# just does the autocomp then copy its results back
current_line.line, current_line.current_character, scrollback = \
intellisense.expand(
line=current_line.line,
cursor=current_line.current_character,
namespace=console.locals,
private='-d' in sys.argv)
# Now we need to copy back the line from blender back into the
# text editor. This will change when we dont use the text editor
# anymore
if scrollback:
add_scrollback(scrollback, 'INFO')
context.area.tag_redraw()
return ('FINISHED',)
class PyConsoleBanner(bpy.types.Operator):
bl_idname = "console.banner_" + language_id
def execute(self, context):
sc = context.space_data
version_string = sys.version.strip().replace('\n', ' ')
add_scrollback(" * Python Interactive Console %s *" % version_string, 'OUTPUT')
add_scrollback("Command History: Up/Down Arrow", 'OUTPUT')
add_scrollback("Cursor: Left/Right Home/End", 'OUTPUT')
add_scrollback("Remove: Backspace/Delete", 'OUTPUT')
add_scrollback("Execute: Enter", 'OUTPUT')
add_scrollback("Autocomplete: Ctrl+Space", 'OUTPUT')
add_scrollback("Ctrl +/- Wheel: Zoom", 'OUTPUT')
add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, Mathutils, Geometry, BGL", 'OUTPUT')
add_scrollback("", 'OUTPUT')
add_scrollback("", 'OUTPUT')
sc.prompt = PyConsoleExec.PROMPT
# Add context into the namespace for quick access
console = get_console(hash(context.region))[0]
console.locals["C"] = bpy.context
return ('FINISHED',)
bpy.ops.add(PyConsoleExec)
bpy.ops.add(PyConsoleAutocomplete)
bpy.ops.add(PyConsoleBanner)

View File

@@ -0,0 +1,113 @@
# ##### 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 sys
import os
import bpy
language_id = 'shell'
def add_scrollback(text, text_type):
for l in text.split('\n'):
bpy.ops.console.scrollback_append(text=l.replace('\t', ' '),
type=text_type)
def shell_run(text):
import subprocess
val, output= subprocess.getstatusoutput(text)
if not val:
style= 'OUTPUT'
else:
style= 'ERROR'
add_scrollback(output, style)
class ShellConsoleExec(bpy.types.Operator):
'''Execute the current console line as a python expression.'''
bl_idname = "console.execute_" + language_id
bl_label = "Console Execute"
bl_register = False
# Both prompts must be the same length
PROMPT = '$ '
# is this working???
'''
def poll(self, context):
return (context.space_data.type == 'PYTHON')
'''
# its not :|
def execute(self, context):
sc = context.space_data
try:
line = sc.history[-1].line
except:
return ('CANCELLED',)
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
shell_run(line)
# insert a new blank line
bpy.ops.console.history_append(text="", current_character=0,
remove_duplicates=True)
sc.prompt = os.getcwd()+ShellConsoleExec.PROMPT
return ('FINISHED',)
class ShellConsoleAutocomplete(bpy.types.Operator):
'''Evaluate the namespace up until the cursor and give a list of
options or complete the name if there is only one.'''
bl_idname = "console.autocomplete_" + language_id
bl_label = "Python Console Autocomplete"
bl_register = False
def poll(self, context):
return context.space_data.console_type == 'PYTHON'
def execute(self, context):
from console import intellisense
sc = context.space_data
# TODO
return ('CANCELLED',)
class ShellConsoleBanner(bpy.types.Operator):
bl_idname = "console.banner_" + language_id
def execute(self, context):
sc = context.space_data
shell_run("bash --version")
sc.prompt = os.getcwd()+ShellConsoleExec.PROMPT
return ('FINISHED',)
bpy.ops.add(ShellConsoleExec)
bpy.ops.add(ShellConsoleAutocomplete)
bpy.ops.add(ShellConsoleBanner)

View File

@@ -0,0 +1,71 @@
# ##### 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 #####
import bpy
def main(context):
ob = context.active_object
bpy.ops.mesh.selection_type(type='FACE')
is_editmode = (ob.mode=='EDIT')
if is_editmode:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
mesh = ob.data
face_list = [face for face in mesh.faces]
face_edge_keys = [face.edge_keys for face in face_list]
edge_face_count = mesh.edge_face_count_dict
def test_interior(index):
for key in face_edge_keys[index]:
if edge_face_count[key] < 3:
return False
return True
for index, face in enumerate(face_list):
if(test_interior(index)):
face.selected = True
else:
face.selected = False
if is_editmode:
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
class MeshSelectInteriorFaces(bpy.types.Operator):
'''Select faces where all edges have more then 2 face users.'''
bl_idname = "mesh.faces_select_interior"
bl_label = "Select Interior Faces"
bl_register = True
bl_undo = True
def poll(self, context):
ob = context.active_object
return (ob and ob.type == 'MESH')
def execute(self, context):
main(context)
return ('FINISHED',)
# Register the operator
bpy.ops.add(MeshSelectInteriorFaces)
if __name__ == "__main__":
bpy.ops.mesh.faces_select_interior()

View File

@@ -222,22 +222,6 @@ class edgeLoop(object):
# Returns face edges.
# face must have edge data.
# Utility funcs for 2.5, make into a module??
def ord_ind(i1,i2):
if i1<i2: return i1,i2
return i2,i1
def edge_key(ed):
v1,v2 = tuple(ed.verts)
return ord_ind(v1, v2)
def face_edge_keys(f):
verts = tuple(f.verts)
if len(verts)==3:
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[0])
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[3]), ord_ind(verts[3], verts[0])
def mesh_faces_extend(me, faces, mat_idx = 0):
orig_facetot = len(me.faces)
@@ -272,15 +256,15 @@ def getSelectedEdges(context, me, ob):
if MESH_MODE == 'FACE':
context.scene.tool_settings.mesh_selection_mode = 'EDGE'
# value is [edge, face_sel_user_in]
edge_dict= dict((edge_key(ed), [ed, 0]) for ed in me.edges)
edge_dict= dict((ed.key, [ed, 0]) for ed in me.edges)
for f in me.faces:
if f.sel:
for edkey in face_edge_keys(f):
if f.selected:
for edkey in f.edge_keys:
edge_dict[edkey][1] += 1
context.scene.tool_settings.mesh_selection_mode = MESH_MODE
return [ ed_data[0] for ed_data in edge_dict.itervalues() if ed_data[1] == 1 ]
return [ ed_data[0] for ed_data in edge_dict.values() if ed_data[1] == 1 ]
@@ -296,7 +280,7 @@ def getVertLoops(selEdges, me):
vert_used = [False] * tot
for ed in selEdges:
i1, i2 = edge_key(ed)
i1, i2 = ed.key
vert_siblings[i1].append(i2)
vert_siblings[i2].append(i1)

View File

@@ -789,23 +789,6 @@ def VectoMat(vec):
return Matrix([a1[0], a1[1], a1[2]], [a2[0], a2[1], a2[2]], [a3[0], a3[1], a3[2]])
# Utility funcs for 2.5, make into a module??
def ord_ind(i1,i2):
if i1<i2: return i1,i2
return i2,i1
def edge_key(ed):
v1,v2 = tuple(ed.verts)
return ord_ind(v1, v2)
def face_edge_keys(f):
verts = tuple(f.verts)
if len(verts)==3:
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[0])
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[3]), ord_ind(verts[3], verts[0])
class thickface(object):
__slost__= 'v', 'uv', 'no', 'area', 'edge_keys'
def __init__(self, face, uvface, mesh_verts):
@@ -817,7 +800,7 @@ class thickface(object):
self.no = face.normal
self.area = face.area
self.edge_keys = face_edge_keys(face)
self.edge_keys = face.edge_keys
global ob
ob = None

View File

@@ -117,7 +117,7 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean,
active_col_layer = me.vertex_colors[0].data
if not active_col_layer:
return("CANCELLED", )
return('CANCELLED', )
for i, f in enumerate(me.faces):
if not me.use_paint_mask or f.selected:

View File

@@ -277,13 +277,12 @@ class WM_OT_doc_view(bpy.types.Operator):
elif len(id_split) == 2: # rna, class.prop
class_name, class_prop = id_split
# It so happens that epydoc nests these
class_name_full = self._nested_class_string(class_name)
if hasattr(bpy.types, class_name.upper() + '_OT_' + class_prop):
url = '%s/bpy.ops.%s-module.html#%s' % \
(self._prefix, class_name_full, class_prop)
(self._prefix, class_name, class_prop)
else:
# It so happens that epydoc nests these
class_name_full = self._nested_class_string(class_name)
url = '%s/bpy.types.%s-class.html#%s' % \
(self._prefix, class_name_full, class_prop)
@@ -321,7 +320,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
class_name, class_prop = self.doc_id.split('.')
if not self.doc_new:
return 'OPERATOR_CANCELLED'
return ('RUNNING_MODAL',)
# check if this is an operator
op_name = class_name.upper() + '_OT_' + class_prop
@@ -334,7 +333,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
rna = op_class.bl_rna
doc_orig = rna.description
if doc_orig == self.doc_new:
return 'OPERATOR_CANCELLED'
return ('RUNNING_MODAL',)
print("op - old:'%s' -> new:'%s'" % (doc_orig, self.doc_new))
upload["title"] = 'OPERATOR %s:%s' % (self.doc_id, doc_orig)
@@ -346,10 +345,10 @@ class WM_OT_doc_edit(bpy.types.Operator):
rna = getattr(bpy.types, class_name).bl_rna
doc_orig = rna.properties[class_prop].description
if doc_orig == self.doc_new:
return 'OPERATOR_CANCELLED'
return ('RUNNING_MODAL',)
print("rna - old:'%s' -> new:'%s'" % (doc_orig, self.doc_new))
upload["title"] = 'RNA %s:%s' % s(self.doc_id, doc_orig)
upload["title"] = 'RNA %s:%s' % (self.doc_id, doc_orig)
upload["description"] = self.doc_new

View File

@@ -4,12 +4,12 @@
# 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.

View File

@@ -4,12 +4,12 @@
# 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.

View File

@@ -4,12 +4,12 @@
# 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.

View File

@@ -4,12 +4,12 @@
# 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.

View File

@@ -4,12 +4,12 @@
# 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.

View File

@@ -159,41 +159,43 @@ class DATA_PT_shape_keys(DataButtonsPanel):
col = row.column()
subcol = col.column(align=True)
subcol.itemO("object.shape_key_add", icon='ICON_ZOOMIN', text="")
subcol.itemO("object.shape_key_remove", icon='ICON_ZOOMOUT', text="")
sub = col.column(align=True)
sub.itemO("object.shape_key_add", icon='ICON_ZOOMIN', text="")
sub.itemO("object.shape_key_remove", icon='ICON_ZOOMOUT', text="")
if kb:
col.itemS()
subcol = col.column(align=True)
subcol.item_enumO("object.shape_key_move", "type", 'UP', icon='ICON_TRIA_UP', text="")
subcol.item_enumO("object.shape_key_move", "type", 'DOWN', icon='ICON_TRIA_DOWN', text="")
sub = col.column(align=True)
sub.item_enumO("object.shape_key_move", "type", 'UP', icon='ICON_TRIA_UP', text="")
sub.item_enumO("object.shape_key_move", "type", 'DOWN', icon='ICON_TRIA_DOWN', text="")
split = layout.split(percentage=0.4)
sub = split.row()
sub.enabled = enable_edit
sub.itemR(key, "relative")
row = split.row()
row.enabled = enable_edit
row.itemR(key, "relative")
sub = split.row()
sub.alignment = 'RIGHT'
row = split.row()
row.alignment = 'RIGHT'
subrow = sub.row(align=True)
subrow.active = enable_edit_value
sub = row.row(align=True)
subsub = sub.row(align=True)
subsub.active = enable_edit_value
if ob.shape_key_lock:
subrow.itemR(ob, "shape_key_lock", icon='ICON_PINNED', text="")
subsub.itemR(ob, "shape_key_lock", icon='ICON_PINNED', text="")
else:
subrow.itemR(ob, "shape_key_lock", icon='ICON_UNPINNED', text="")
subsub.itemR(ob, "shape_key_lock", icon='ICON_UNPINNED', text="")
if kb.mute:
subrow.itemR(kb, "mute", icon='ICON_MUTE_IPO_ON', text="")
subsub.itemR(kb, "mute", icon='ICON_MUTE_IPO_ON', text="")
else:
subrow.itemR(kb, "mute", icon='ICON_MUTE_IPO_OFF', text="")
subrow.itemO("object.shape_key_clear", icon='ICON_X', text="")
sub.itemO("object.shape_key_mirror", icon='ICON_MOD_MIRROR', text="")
subsub.itemR(kb, "mute", icon='ICON_MUTE_IPO_OFF', text="")
sub.itemR(ob, "shape_key_edit_mode", text="")
sub = row.row(align=True)
sub.itemO("object.shape_key_mirror", icon='ICON_ARROW_LEFTRIGHT', text="")
sub.itemO("object.shape_key_clear", icon='ICON_X', text="")
row = layout.row()
row.itemR(kb, "name")
@@ -204,17 +206,18 @@ class DATA_PT_shape_keys(DataButtonsPanel):
row.itemR(kb, "value")
split = layout.split()
sub = split.column(align=True)
sub.active = enable_edit_value
sub.itemL(text="Range:")
sub.itemR(kb, "slider_min", text="Min")
sub.itemR(kb, "slider_max", text="Max")
sub = split.column(align=True)
sub.active = enable_edit_value
sub.itemL(text="Blend:")
sub.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
sub.item_pointerR(kb, "relative_key", key, "keys", text="")
col = split.column(align=True)
col.active = enable_edit_value
col.itemL(text="Range:")
col.itemR(kb, "slider_min", text="Min")
col.itemR(kb, "slider_max", text="Max")
col = split.column(align=True)
col.active = enable_edit_value
col.itemL(text="Blend:")
col.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
col.item_pointerR(kb, "relative_key", key, "keys", text="")
else:
row = layout.row()

View File

@@ -78,18 +78,18 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel):
row = layout.row()
col = row.column()
col.itemR(ob, "lock_location")
col.itemR(ob, "lock_location", text="Location")
col = row.column()
if ob.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
col.itemR(ob, "lock_rotations_4d", text="Lock Rotation")
col.itemR(ob, "lock_rotations_4d", text="Rotation")
if ob.lock_rotations_4d:
col.itemR(ob, "lock_rotation_w", text="W")
col.itemR(ob, "lock_rotation", text="")
else:
col.itemR(ob, "lock_rotation", text="Rotation")
row.column().itemR(ob, "lock_scale")
row.column().itemR(ob, "lock_scale", text="Scale")
class OBJECT_PT_relations(ObjectButtonsPanel):

View File

@@ -88,7 +88,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col = split.column()
col.itemR(con, "chain_length")
col.itemR(con, "targetless")
def CHILD_OF(self, context, layout, con):
self.target_template(layout, con)
@@ -129,11 +129,11 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row.itemR(con, "target_z")
self.space_template(layout, con)
def IK(self, context, layout, con):
if context.object.pose.ik_solver == "ITASC":
layout.itemR(con, "ik_type")
getattr(self, "IK_" + con.ik_type)(context, layout, con)
getattr(self, 'IK_' + con.ik_type)(context, layout, con)
else:
# Legacy IK constraint
self.target_template(layout, con)
@@ -168,7 +168,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
sub = col.column()
sub.active = con.rotation
sub.itemR(con, "orient_weight", text="Rotation", slider=True)
def IK_COPY_POSE(self, context, layout, con):
self.target_template(layout, con)
self.ik_template(layout, con)
@@ -212,7 +212,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row = layout.row()
row.itemR(con, "weight", text="Weight", slider=True)
row.itemR(con, "distance", text="Distance", slider=True)
def FOLLOW_PATH(self, context, layout, con):
self.target_template(layout, con)
@@ -310,7 +310,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row = layout.row()
row.itemL(text="Convert:")
row.itemR(con, "owner_space", text="")
def LIMIT_SCALE(self, context, layout, con):
split = layout.split()
@@ -351,7 +351,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
row = layout.row()
row.itemL(text="Convert:")
row.itemR(con, "owner_space", text="")
def COPY_ROTATION(self, context, layout, con):
self.target_template(layout, con)
@@ -378,7 +378,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
layout.itemR(con, "offset")
self.space_template(layout, con)
def COPY_LOCATION(self, context, layout, con):
self.target_template(layout, con)
@@ -607,7 +607,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
col = layout.column()
col.itemL(text="Chain Scaling:")
col.itemR(con, "keep_max_length")
col.itemR(con, "radius_to_thickness")
col.itemR(con, "xz_scaling_mode")
class OBJECT_PT_constraints(ConstraintButtonsPanel):
@@ -702,7 +702,7 @@ class BONE_PT_inverse_kinematics(ConstraintButtonsPanel):
split.itemR(pchan, "ik_stretch", text="Stretch", slider=True)
split.itemL()
if ob.pose.ik_solver == "ITASC":
if ob.pose.ik_solver == 'ITASC':
row = layout.row()
row.itemR(pchan, "ik_rot_control", text="Control Rotation")
row.itemR(pchan, "ik_rot_weight", text="Weight", slider=True)
@@ -723,7 +723,7 @@ class BONE_PT_iksolver_itasc(ConstraintButtonsPanel):
if ob and bone:
pchan = ob.pose.pose_channels[bone.name]
return pchan.has_ik and ob.pose.ik_solver == "ITASC" and ob.pose.ik_param
return pchan.has_ik and ob.pose.ik_solver == 'ITASC' and ob.pose.ik_param
return False
@@ -734,7 +734,7 @@ class BONE_PT_iksolver_itasc(ConstraintButtonsPanel):
itasc = ob.pose.ik_param
layout.itemR(itasc, "mode", expand=True)
simulation = itasc.mode == "SIMULATION"
simulation = itasc.mode == 'SIMULATION'
if simulation:
layout.itemL(text="Reiteration:")
layout.itemR(itasc, "reiteration", expand=True)
@@ -742,7 +742,7 @@ class BONE_PT_iksolver_itasc(ConstraintButtonsPanel):
flow = layout.column_flow()
flow.itemR(itasc, "precision", text="Prec")
flow.itemR(itasc, "num_iter", text="Iter")
flow.active = not simulation or itasc.reiteration != "NEVER"
flow.active = not simulation or itasc.reiteration != 'NEVER'
if simulation:
layout.itemR(itasc, "auto_step")
@@ -757,7 +757,7 @@ class BONE_PT_iksolver_itasc(ConstraintButtonsPanel):
if simulation:
layout.itemR(itasc, "feedback")
layout.itemR(itasc, "max_velocity")
if itasc.solver == "DLS":
if itasc.solver == 'DLS':
row = layout.row()
row.itemR(itasc, "dampmax", text="Damp", slider=True)
row.itemR(itasc, "dampeps", text="Eps", slider=True)

View File

@@ -77,7 +77,7 @@ class PHYSICS_PT_field(PhysicButtonsPanel):
layout.itemS()
layout.itemR(field, "guide_kink_type")
if (field.guide_kink_type != "NONE"):
if (field.guide_kink_type != 'NONE'):
layout.itemR(field, "guide_kink_axis")
flow = layout.column_flow()

View File

@@ -73,8 +73,9 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
col = split.column()
col.itemL(text="Object:")
col.itemR(softbody, "mass")
col.itemR(softbody, "friction")
col.itemR(softbody, "mass")
col.item_pointerR(softbody, "mass_vertex_group", ob, "vertex_groups", text="Mass:")
col = split.column()
col.itemL(text="Simulation:")
@@ -167,6 +168,7 @@ class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
col.itemR(softbody, "plastic")
col.itemR(softbody, "bending")
col.itemR(softbody, "spring_length", text="Length")
col.item_pointerR(softbody, "spring_vertex_group", ob, "vertex_groups", text="Springs:")
col = split.column()
col.itemR(softbody, "stiff_quads")

View File

@@ -199,7 +199,7 @@ class RENDER_PT_performance(RenderButtonsPanel):
sub.active = rd.render_raytracing
sub.itemL(text="Acceleration structure:")
sub.itemR(rd, "raytrace_structure", text="")
if rd.raytrace_structure == "OCTREE":
if rd.raytrace_structure == 'OCTREE':
sub.itemR(rd, "octree_resolution", text="Resolution")
else:
sub.itemR(rd, "use_instances", text="Instances")

View File

@@ -19,6 +19,7 @@
# <pep8 compliant>
import sys
import bpy
from bpy.props import *
class CONSOLE_HT_header(bpy.types.Header):
@@ -68,6 +69,7 @@ class CONSOLE_MT_console(bpy.types.Menu):
layout.itemO("console.clear")
layout.itemO("console.copy")
layout.itemO("console.paste")
layout.itemM("CONSOLE_MT_language")
class CONSOLE_MT_report(bpy.types.Menu):
@@ -81,6 +83,24 @@ class CONSOLE_MT_report(bpy.types.Menu):
layout.itemO("console.report_delete")
layout.itemO("console.report_copy")
class CONSOLE_MT_language(bpy.types.Menu):
bl_label = "Languages..."
def draw(self, context):
layout = self.layout
layout.column()
mod = bpy.ops.console
languages = []
for opname in dir(mod):
# execute_python, execute_shell etc.
if opname.startswith("execute_"):
languages.append(opname.split('_', 1)[-1])
languages.sort()
for language in languages:
layout.item_stringO("console.language", "language", language, text=language[0].upper() + language[1:])
def add_scrollback(text, text_type):
for l in text.split('\n'):
@@ -88,129 +108,26 @@ def add_scrollback(text, text_type):
type=text_type)
def get_console(console_id):
'''
helper function for console operators
currently each text datablock gets its own
console - bpython_code.InteractiveConsole()
...which is stored in this function.
console_id can be any hashable type
'''
from code import InteractiveConsole
try:
consoles = get_console.consoles
except:
consoles = get_console.consoles = {}
# clear all dead consoles, use text names as IDs
# TODO, find a way to clear IDs
'''
for console_id in list(consoles.keys()):
if console_id not in bpy.data.texts:
del consoles[id]
'''
try:
console, stdout, stderr = consoles[console_id]
except:
namespace = {'__builtins__': __builtins__, 'bpy': bpy}
console = InteractiveConsole(namespace)
import io
stdout = io.StringIO()
stderr = io.StringIO()
consoles[console_id] = console, stdout, stderr
return console, stdout, stderr
class CONSOLE_OT_exec(bpy.types.Operator):
class ConsoleExec(bpy.types.Operator):
'''Execute the current console line as a python expression.'''
bl_idname = "console.execute"
bl_label = "Console Execute"
bl_register = False
# Both prompts must be the same length
PROMPT = '>>> '
PROMPT_MULTI = '... '
# is this working???
'''
def poll(self, context):
return (context.space_data.type == 'PYTHON')
'''
# its not :|
def execute(self, context):
sc = context.space_data
try:
line = sc.history[-1].line
except:
return ('CANCELLED',)
execute = getattr(bpy.ops.console, "execute_" + sc.language, None)
if sc.console_type != 'PYTHON':
return ('CANCELLED',)
console, stdout, stderr = get_console(hash(context.region))
# Hack, useful but must add some other way to access
#if "C" not in console.locals:
console.locals["C"] = context
# redirect output
sys.stdout = stdout
sys.stderr = stderr
# run the console
if not line.strip():
line_exec = '\n' # executes a multiline statement
if execute:
execute()
else:
line_exec = line
is_multiline = console.push(line_exec)
stdout.seek(0)
stderr.seek(0)
output = stdout.read()
output_err = stderr.read()
# cleanup
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
sys.last_traceback = None
# So we can reuse, clear all data
stdout.truncate(0)
stderr.truncate(0)
bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
if is_multiline:
sc.prompt = self.PROMPT_MULTI
else:
sc.prompt = self.PROMPT
# insert a new blank line
bpy.ops.console.history_append(text="", current_character=0,
remove_duplicates=True)
# Insert the output into the editor
# not quite correct because the order might have changed,
# but ok 99% of the time.
if output:
add_scrollback(output, 'OUTPUT')
if output_err:
add_scrollback(output_err, 'ERROR')
print("Error: bpy.ops.console.execute_" + sc.language + " - not found")
return ('FINISHED',)
class CONSOLE_OT_autocomplete(bpy.types.Operator):
class ConsoleAutocomplete(bpy.types.Operator):
'''Evaluate the namespace up until the cursor and give a list of
options or complete the name if there is only one.'''
bl_idname = "console.autocomplete"
@@ -218,40 +135,58 @@ class CONSOLE_OT_autocomplete(bpy.types.Operator):
bl_register = False
def poll(self, context):
return context.space_data.console_type == 'PYTHON'
return context.space_data.console_type != 'REPORT'
def execute(self, context):
from console import intellisense
sc = context.space_data
console = get_console(hash(context.region))[0]
current_line = sc.history[-1]
line = current_line.line
autocomplete = getattr(bpy.ops.console, "autocomplete_" + sc.language, None)
if not console:
return ('CANCELLED',)
if autocomplete:
autocomplete()
else:
print("Error: bpy.ops.console.autocomplete_" + sc.language + " - not found")
if sc.console_type != 'PYTHON':
return ('CANCELLED',)
return ('FINISHED',)
# This function isnt aware of the text editor or being an operator
# just does the autocomp then copy its results back
current_line.line, current_line.current_character, scrollback = \
intellisense.expand(
line=current_line.line,
cursor=current_line.current_character,
namespace=console.locals,
private='-d' in sys.argv)
# Now we need to copy back the line from blender back into the
# text editor. This will change when we dont use the text editor
# anymore
if scrollback:
add_scrollback(scrollback, 'INFO')
class ConsoleBanner(bpy.types.Operator):
bl_idname = "console.banner"
context.area.tag_redraw()
def execute(self, context):
sc = context.space_data
# default to python
if not sc.language:
sc.language = 'python'
banner = getattr(bpy.ops.console, "banner_" + sc.language, None)
if banner:
banner()
else:
print("Error: bpy.ops.console.banner_" + sc.language + " - not found")
return ('FINISHED',)
class ConsoleLanguage(bpy.types.Operator):
'''Set the current language for this console'''
bl_idname = "console.language"
language = StringProperty(name="Language", maxlen= 32, default= "")
def execute(self, context):
sc = context.space_data
# defailt to python
sc.language = self.language
bpy.ops.console.banner()
# insert a new blank line
bpy.ops.console.history_append(text="", current_character=0,
remove_duplicates=True)
return ('FINISHED',)
@@ -259,6 +194,12 @@ class CONSOLE_OT_autocomplete(bpy.types.Operator):
bpy.types.register(CONSOLE_HT_header)
bpy.types.register(CONSOLE_MT_console)
bpy.types.register(CONSOLE_MT_report)
bpy.types.register(CONSOLE_MT_language)
bpy.ops.add(CONSOLE_OT_exec)
bpy.ops.add(CONSOLE_OT_autocomplete)
# Stubs that call the language operators
bpy.ops.add(ConsoleExec)
bpy.ops.add(ConsoleAutocomplete)
bpy.ops.add(ConsoleBanner)
# Set the language and call the banner
bpy.ops.add(ConsoleLanguage)

View File

@@ -208,7 +208,7 @@ class IMAGE_MT_uvs(bpy.types.Menu):
layout.itemS()
layout.itemR(settings, "proportional_editing")
layout.item_menu_enumR(settings, "proportional_editing")
layout.item_menu_enumR(settings, "proportional_editing_falloff")
layout.itemS()

View File

@@ -187,9 +187,9 @@ class INFO_MT_add(bpy.types.Menu):
layout.itemO("object.text_add", text="Text", icon='ICON_OUTLINER_OB_FONT')
layout.itemS()
layout.operator_context = "INVOKE_SCREEN"
layout.itemO("object.armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE')
layout.item_enumO("object.add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE')
layout.item_enumO("object.add", "type", 'EMPTY', icon='ICON_OUTLINER_OB_EMPTY')
@@ -197,9 +197,9 @@ class INFO_MT_add(bpy.types.Menu):
layout.itemS()
layout.item_enumO("object.add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
layout.operator_context = "EXEC_SCREEN"
layout.item_menu_enumO("object.lamp_add", "type", 'LAMP', text="Lamp", icon='ICON_OUTLINER_OB_LAMP')
layout.itemS()

View File

@@ -245,12 +245,14 @@ class SEQUENCER_MT_strip(bpy.types.Menu):
elif stype == 'IMAGE':
layout.itemS()
layout.itemO("sequencer.image_change")
layout.itemO("sequencer.rendersize")
elif stype == 'SCENE':
layout.itemS()
layout.itemO("sequencer.scene_change", text="Change Scene")
elif stype == 'MOVIE':
layout.itemS()
layout.itemO("sequencer.movie_change")
layout.itemO("sequencer.rendersize")
layout.itemS()

View File

@@ -1224,16 +1224,16 @@ class USERPREF_PT_input(bpy.types.Panel):
row = subcol.row()
if kmi.expanded:
row.itemR(kmi, "expanded", text="", icon="ICON_TRIA_DOWN")
row.itemR(kmi, "expanded", text="", icon='ICON_TRIA_DOWN')
else:
row.itemR(kmi, "expanded", text="", icon="ICON_TRIA_RIGHT")
row.itemR(kmi, "expanded", text="", icon='ICON_TRIA_RIGHT')
itemrow = row.row()
itemrow.enabled = km.user_defined
if kmi.active:
itemrow.itemR(kmi, "active", text="", icon="ICON_CHECKBOX_HLT")
itemrow.itemR(kmi, "active", text="", icon='ICON_CHECKBOX_HLT')
else:
itemrow.itemR(kmi, "active", text="", icon="ICON_CHECKBOX_DEHLT")
itemrow.itemR(kmi, "active", text="", icon='ICON_CHECKBOX_DEHLT')
itemcol = itemrow.column()
itemcol.active = kmi.active
@@ -1290,11 +1290,11 @@ class USERPREF_PT_input(bpy.types.Panel):
itemcol.itemS()
itemrow.itemO("wm.keyitem_remove", text="", icon="ICON_ZOOMOUT")
itemrow.itemO("wm.keyitem_remove", text="", icon='ICON_ZOOMOUT')
itemrow = col.row()
itemrow.itemL()
itemrow.itemO("wm.keyitem_add", text="", icon="ICON_ZOOMIN")
itemrow.itemO("wm.keyitem_add", text="", icon='ICON_ZOOMIN')
itemrow.enabled = km.user_defined
bpy.types.register(USERPREF_HT_header)
@@ -1439,7 +1439,7 @@ class WM_OT_keyitem_add(bpy.types.Operator):
def execute(self, context):
wm = context.manager
km = wm.active_keymap
kmi = km.add_item("", "A", "PRESS")
kmi = km.add_item("", 'A', 'PRESS')
return ('FINISHED',)

View File

@@ -191,11 +191,41 @@ class VIEW3D_MT_view_align(bpy.types.Menu):
def draw(self, context):
layout = self.layout
layout.itemM("VIEW3D_MT_view_align_selected")
layout.itemS()
layout.item_booleanO("view3d.view_all", "center", True, text="Center Cursor and View All")
layout.itemO("view3d.camera_to_view", text="Align Active Camera to View")
layout.itemO("view3d.view_center")
class VIEW3D_MT_view_align_selected(bpy.types.Menu):
bl_label = "Align View to Selected"
def draw(self, context):
layout = self.layout
props = layout.itemO("view3d.viewnumpad", properties=True, text="Top")
props.align_active = True
props.type = 'TOP'
props = layout.itemO("view3d.viewnumpad", properties=True, text="Bottom")
props.align_active = True
props.type = 'BOTTOM'
props = layout.itemO("view3d.viewnumpad", properties=True, text="Front")
props.align_active = True
props.type = 'FRONT'
props = layout.itemO("view3d.viewnumpad", properties=True, text="Back")
props.align_active = True
props.type = 'BACK'
props = layout.itemO("view3d.viewnumpad", properties=True, text="Right")
props.align_active = True
props.type = 'RIGHT'
props = layout.itemO("view3d.viewnumpad", properties=True, text="Left")
props.align_active = True
props.type = 'LEFT'
class VIEW3D_MT_view_cameras(bpy.types.Menu):
bl_label = "Cameras"
@@ -276,12 +306,18 @@ class VIEW3D_MT_select_particle(bpy.types.Menu):
layout.itemO("particle.select_all_toggle", text="Select/Deselect All")
layout.itemO("particle.select_linked")
layout.itemO("particle.select_inverse")
layout.itemS()
layout.itemO("particle.select_more")
layout.itemO("particle.select_less")
layout.itemS()
layout.itemO("particle.select_first", text="Roots")
layout.itemO("particle.select_last", text="Tips")
class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
bl_label = "Select"
@@ -302,6 +338,8 @@ class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
layout.itemO("mesh.select_random", text="Random...")
layout.itemO("mesh.edges_select_sharp", text="Sharp Edges")
layout.itemO("mesh.faces_select_linked_flat", text="Linked Flat Faces")
layout.itemO("mesh.faces_select_interior", text="Interior Faces")
layout.itemO("mesh.select_axis", text="Side of Active")
layout.itemS()
@@ -612,7 +650,7 @@ class VIEW3D_MT_make_links(bpy.types.Menu):
def draw(self, context):
layout = self.layout
layout.item_menu_enumO("object.make_links_scene", "type", text="Objects to Scene...")
layout.items_enumO("object.make_links_data", property="type") # inline
@@ -1338,6 +1376,29 @@ class VIEW3D_PT_3dview_properties(bpy.types.Panel):
layout.column().itemR(scene, "cursor_location", text="3D Cursor:")
class VIEW3D_PT_3dview_item(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Item"
def poll(self, context):
return (context.active_object or context.active_bone or context.active_pchan)
def draw(self, context):
layout = self.layout
ob = context.active_object
row = layout.row()
row.itemL(text="", icon='ICON_OBJECT_DATA')
row.itemR(ob, "name", text="")
if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
bone = context.active_bone
if bone:
row = layout.row()
row.itemL(text="", icon='ICON_BONE_DATA')
row.itemR(bone, "name", text="")
class VIEW3D_PT_3dview_display(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
@@ -1534,13 +1595,13 @@ class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
col.itemR(toolsettings, "etch_convert_mode")
if toolsettings.etch_convert_mode == "LENGTH":
if toolsettings.etch_convert_mode == 'LENGTH':
col.itemR(toolsettings, "etch_length_limit")
elif toolsettings.etch_convert_mode == "ADAPTIVE":
elif toolsettings.etch_convert_mode == 'ADAPTIVE':
col.itemR(toolsettings, "etch_adaptive_limit")
elif toolsettings.etch_convert_mode == "FIXED":
elif toolsettings.etch_convert_mode == 'FIXED':
col.itemR(toolsettings, "etch_subdivision_number")
elif toolsettings.etch_convert_mode == "RETARGET":
elif toolsettings.etch_convert_mode == 'RETARGET':
col.itemR(toolsettings, "etch_template")
col.itemR(toolsettings, "etch_roll_mode")
col.itemR(toolsettings, "etch_autoname")
@@ -1593,6 +1654,7 @@ bpy.types.register(VIEW3D_HT_header) # Header
bpy.types.register(VIEW3D_MT_view) #View Menus
bpy.types.register(VIEW3D_MT_view_navigation)
bpy.types.register(VIEW3D_MT_view_align)
bpy.types.register(VIEW3D_MT_view_align_selected)
bpy.types.register(VIEW3D_MT_view_cameras)
bpy.types.register(VIEW3D_MT_select_object) # Select Menus
@@ -1664,7 +1726,8 @@ bpy.types.register(VIEW3D_MT_edit_armature)
bpy.types.register(VIEW3D_MT_edit_armature_parent)
bpy.types.register(VIEW3D_MT_edit_armature_roll)
bpy.types.register(VIEW3D_PT_3dview_properties) # Panels
bpy.types.register(VIEW3D_PT_3dview_item) # Panels
bpy.types.register(VIEW3D_PT_3dview_properties)
bpy.types.register(VIEW3D_PT_3dview_display)
bpy.types.register(VIEW3D_PT_3dview_meshdisplay)
bpy.types.register(VIEW3D_PT_3dview_curvedisplay)

View File

@@ -101,6 +101,7 @@ class VIEW3D_PT_tools_meshedit(View3DPanel):
col.itemO("mesh.screw")
col.itemO("mesh.merge")
col.itemO("mesh.rip_move")
col.itemO("mesh.flip_normals")
col = layout.column(align=True)
col.itemL(text="Shading:")
@@ -110,7 +111,7 @@ class VIEW3D_PT_tools_meshedit(View3DPanel):
col = layout.column(align=True)
col.itemL(text="UV Mapping:")
col.item_stringO("wm.call_menu", "name", "VIEW3D_MT_uv_map", text="Unwrap")
col.itemO("mesh.uvs_rotate")
col.itemO("mesh.uvs_mirror")
@@ -831,6 +832,8 @@ class VIEW3D_PT_tools_particlemode(View3DPanel):
layout.itemR(pe, "type", text="")
ptcache = None
if pe.type == 'PARTICLES':
if ob.particle_systems:
if len(ob.particle_systems) > 1:

View File

@@ -78,8 +78,6 @@ endif
GRPLIB = $(OCGDIR)/creator/$(DEBUG_DIR)libcreator.a
GRPLIB += $(OCGDIR)/blender/windowmanager/$(DEBUG_DIR)libwindowmanager.a
GRPLIB += $(NAN_BSP)/lib/$(DEBUG_DIR)libbsp.a
GRPLIB += $(NAN_BOOLOP)/lib/$(DEBUG_DIR)libboolop.a
GRPLIB += $(NAN_GHOST)/lib/$(DEBUG_DIR)libghost.a
GRPLIB += $(NAN_STRING)/lib/$(DEBUG_DIR)libstring.a
GRPLIB += $(OCGDIR)/blender/render/$(DEBUG_DIR)librender.a
@@ -118,6 +116,9 @@ COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_sdl.a
COMLIB += $(NAN_SAMPLERATE)/lib/$(DEBUG_DIR)libsamplerate.a
COMLIB += $(NAN_LZO)/lib/$(DEBUG_DIR)libminilzo.a
COMLIB += $(NAN_LZMA)/lib/$(DEBUG_DIR)liblzma.a
COMLIB += $(NAN_BSP)/lib/$(DEBUG_DIR)libbsp.a
COMLIB += $(NAN_BOOLOP)/lib/$(DEBUG_DIR)libboolop.a
COMLIB += $(NAN_DECIMATION)/lib/$(DEBUG_DIR)libdecimation.a
ifeq ($(WITH_FFMPEG),true)
COMLIB += $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_ffmpeg.a
@@ -187,7 +188,11 @@ ifeq ($(WITH_OPENEXR), true)
endif
ifeq ($(WITH_OPENJPEG), true)
COMLIB += $(OCGDIR)/extern/openjpeg/$(DEBUG_DIR)libopenjpeg.a
ifndef BF_OPENJPEG_LIBS
COMLIB += $(OCGDIR)/extern/openjpeg/$(DEBUG_DIR)libopenjpeg.a
else
COMLIB += $(BF_OPENJPEG_LIBS)
endif
endif
COMLIB += $(OCGDIR)/blender/imbuf/cineon/$(DEBUG_DIR)libcineon.a
@@ -233,7 +238,6 @@ endif
# note: space_api.a in begin of editors, screen.a in end
PULIB = $(NAN_MOTO)/lib/libmoto.a
PULIB += $(NAN_DECIMATION)/lib/$(DEBUG_DIR)libdecimation.a
PULIB += $(OCGDIR)/blender/readblenfile/$(DEBUG_DIR)libreadblenfile.a
PULIB += $(OCGDIR)/blender/ed_space/$(DEBUG_DIR)libed_space.a
PULIB += $(OCGDIR)/blender/ed_sound/$(DEBUG_DIR)libed_sound.a

View File

@@ -46,7 +46,7 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h" /* linknode */
#include "BLI_string.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BIF_gl.h"
#include "BLF_api.h"
@@ -459,7 +459,7 @@ static void blf_font_fill(FontBLF *font)
font->pos[0]= 0.0f;
font->pos[1]= 0.0f;
font->angle= 0.0f;
Mat4One(font->mat);
unit_m4(font->mat);
font->clip_rec.xmin= 0.0f;
font->clip_rec.xmax= 0.0f;
font->clip_rec.ymin= 0.0f;

View File

@@ -131,7 +131,8 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc)
}
}
glDeleteTextures(gc->cur_tex+1, gc->textures);
if (gc->cur_tex+1 > 0)
glDeleteTextures(gc->cur_tex+1, gc->textures);
free((void *)gc->textures);
MEM_freeN(gc);
}

View File

@@ -38,7 +38,7 @@
#include "BKE_DerivedMesh.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "DNA_cloth_types.h"

View File

@@ -52,7 +52,7 @@ typedef struct bConstraintOb {
float startmat[4][4]; /* original matrix (before constraint solving) */
short type; /* type of owner */
short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_arithb.h) */
short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_math.h) */
} bConstraintOb;
/* ---------------------------------------------------------------------------- */

View File

@@ -174,7 +174,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member);
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type);
ListBase CTX_data_collection_get(const bContext *C, const char *member);
ListBase CTX_data_dir_get(const bContext *C);
void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb);
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb);
void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id);
void CTX_data_pointer_set(bContextDataResult *result, struct ID *id, StructRNA *type, void *data);

View File

@@ -53,6 +53,7 @@ struct GPUMaterial;
struct GPUNode;
struct GPUNodeStack;
struct PointerRNA;
struct bContext;
/* ************** NODE TYPE DEFINITIONS ***** */
@@ -83,7 +84,7 @@ typedef struct bNodeType {
void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **);
/* this line is set on startup of blender */
void (*uifunc)(struct uiLayout *, struct PointerRNA *ptr);
void (*uifunc)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
void (*initfunc)(struct bNode *);
void (*freestoragefunc)(struct bNode *);
@@ -161,6 +162,7 @@ void nodeVerifyType(struct bNodeTree *ntree, struct bNode *node);
void nodeAddToPreview(struct bNode *, float *, int, int);
void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
void nodeAddSockets(struct bNode *node, struct bNodeType *ntype);
struct bNode *nodeAddNodeType(struct bNodeTree *ntree, int type, struct bNodeTree *ngroup, struct ID *id);
void nodeRegisterType(struct ListBase *typelist, const struct bNodeType *ntype) ;

View File

@@ -42,7 +42,7 @@
#include "BKE_utildefines.h"
#include "BKE_bmesh.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
/*split this all into a seperate bevel.c file in src*/
@@ -88,7 +88,7 @@ BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Ve
else if (org != NULL) VECCOPY(vtd->org,org);
if (vec != NULL) {
VECCOPY(vtd->vec,vec);
Normalize(vtd->vec);
normalize_v3(vtd->vec);
}
vtd->loc = loc;
@@ -261,7 +261,7 @@ static BME_Vert *BME_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Edge *e, BME_Edge
nv = BME_SEMV(bm,v,e,ne);
if (nv == NULL) return NULL;
VECSUB(nv->co,v2->co,v->co);
len = VecLength(nv->co);
len = len_v3(nv->co);
VECADDFAC(nv->co,v->co,nv->co,len*percent);
nv->flag = v->flag;
nv->bweight = v->bweight;
@@ -335,17 +335,17 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa
/* compare the transform origins to see if we can use the vert co's;
* if they belong to different origins, then we will use the origins to determine
* the vector */
if (VecCompare(vtd1->org,vtd2->org,0.000001f)) {
if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) {
VECSUB(vec,v2->co,v1->co);
if (VecLength(vec) < 0.000001f) {
VecMulf(vec,0);
if (len_v3(vec) < 0.000001f) {
mul_v3_fl(vec,0);
}
return 0;
}
else {
VECSUB(vec,vtd2->org,vtd1->org);
if (VecLength(vec) < 0.000001f) {
VecMulf(vec,0);
if (len_v3(vec) < 0.000001f) {
mul_v3_fl(vec,0);
}
return 1;
}
@@ -363,18 +363,18 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa
static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *td) {
float factor, vec3[3], tmp[3],c1,c2;
Crossf(tmp,vec1,vec2);
Normalize(tmp);
factor = Inpf(up_vec,tmp);
cross_v3_v3v3(tmp,vec1,vec2);
normalize_v3(tmp);
factor = dot_v3v3(up_vec,tmp);
if ((factor > 0 && is_forward) || (factor < 0 && !is_forward)) {
Crossf(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */
cross_v3_v3v3(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */
}
else {
Crossf(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */
cross_v3_v3v3(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */
}
Normalize(vec3);
c1 = Inpf(vec3,vec1);
c2 = Inpf(vec1,vec1);
normalize_v3(vec3);
c1 = dot_v3v3(vec3,vec1);
c2 = dot_v3v3(vec1,vec1);
if (fabs(c1) < 0.000001f || fabs(c2) < 0.000001f) {
factor = 0.0f;
}
@@ -435,8 +435,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
BME_bevel_get_vec(vec1,v1,v,td);
BME_bevel_get_vec(vec2,v2,v,td);
Crossf(t_up_vec,vec1,vec2);
Normalize(t_up_vec);
cross_v3_v3v3(t_up_vec,vec1,vec2);
normalize_v3(t_up_vec);
up_vec = t_up_vec;
}
else {
@@ -486,8 +486,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
is_edge = BME_bevel_get_vec(vec1,v,v1,td); /* get the vector we will be projecting onto */
BME_bevel_get_vec(vec2,v,v2,td); /* get the vector we will be projecting parallel to */
len = VecLength(vec1);
Normalize(vec1);
len = len_v3(vec1);
normalize_v3(vec1);
vtd = BME_get_transdata(td, sv);
vtd1 = BME_get_transdata(td, v);
@@ -525,8 +525,8 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
}
VECADDFAC(sv->co,v->co,vec1,dis);
VECSUB(vec1,sv->co,vtd1->org);
dis = VecLength(vec1);
Normalize(vec1);
dis = len_v3(vec1);
normalize_v3(vec1);
BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, maxfactor, vtd->max);
return sv;
@@ -545,10 +545,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
}
else {
VECCOPY(vec2,vtd1->vec);
VecMulf(vec2,vtd1->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec2,vec1);
fac1 = VecLength(vec2)/value;
mul_v3_fl(vec2,vtd1->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec2,vec1);
fac1 = len_v3(vec2)/value;
}
else {
fac1 = 0;
@@ -560,10 +560,10 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
}
else {
VECCOPY(vec3,vtd2->vec);
VecMulf(vec3,vtd2->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec3,vec1);
fac2 = VecLength(vec2)/value;
mul_v3_fl(vec3,vtd2->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec3,vec1);
fac2 = len_v3(vec2)/value;
}
else {
fac2 = 0;
@@ -571,7 +571,7 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran
}
if (fac1 || fac2) {
max = VecLength(vec1)/(fac1 + fac2);
max = len_v3(vec1)/(fac1 + fac2);
if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
*vtd1->max = max;
}
@@ -760,12 +760,12 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
for (i=0,ol=f->loopbase,l=ol->next; l->next!=ol; l=l->next) {
BME_bevel_get_vec(vec1,l->next->v,ol->v,td);
BME_bevel_get_vec(vec2,l->v,ol->v,td);
Crossf(vec3,vec2,vec1);
cross_v3_v3v3(vec3,vec2,vec1);
VECADD(up_vec,up_vec,vec3);
i++;
}
VecMulf(up_vec,1.0f/i);
Normalize(up_vec);
mul_v3_fl(up_vec,1.0f/i);
normalize_v3(up_vec);
for (i=0,len=f->len; i<len; i++,l=l->next) {
if ((l->e->tflag1 & BME_BEVEL_BEVEL) && (l->e->tflag1 & BME_BEVEL_ORIG)) {
@@ -791,10 +791,10 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
}
else {
VECCOPY(vec2,vtd1->vec);
VecMulf(vec2,vtd1->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec2,vec1);
fac1 = VecLength(vec2)/value;
mul_v3_fl(vec2,vtd1->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec2,vec1);
fac1 = len_v3(vec2)/value;
}
else {
fac1 = 0;
@@ -805,17 +805,17 @@ static BME_Poly *BME_bevel_poly(BME_Mesh *bm, BME_Poly *f, float value, int opti
}
else {
VECCOPY(vec3,vtd2->vec);
VecMulf(vec3,vtd2->factor);
if (Inpf(vec1, vec1)) {
Projf(vec2,vec3,vec1);
fac2 = VecLength(vec2)/value;
mul_v3_fl(vec3,vtd2->factor);
if (dot_v3v3(vec1, vec1)) {
project_v3_v3v3(vec2,vec3,vec1);
fac2 = len_v3(vec2)/value;
}
else {
fac2 = 0;
}
}
if (fac1 || fac2) {
max = VecLength(vec1)/(fac1 + fac2);
max = len_v3(vec1)/(fac1 + fac2);
if (vtd1->max && (*vtd1->max < 0 || max < *vtd1->max)) {
*vtd1->max = max;
}
@@ -880,7 +880,7 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) {
}
VECSUB(vec1,v1->co,v->co);
VECSUB(vec2,v2->co,v->co);
Crossf(vec3,vec1,vec2);
cross_v3_v3v3(vec3,vec1,vec2);
l1 = l2;
if (l1->v == v) {
@@ -893,12 +893,12 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) {
}
VECSUB(vec1,v1->co,v->co);
VECSUB(vec2,v2->co,v->co);
Crossf(vec4,vec2,vec1);
cross_v3_v3v3(vec4,vec2,vec1);
Normalize(vec3);
Normalize(vec4);
normalize_v3(vec3);
normalize_v3(vec4);
return Inpf(vec3,vec4);
return dot_v3v3(vec3,vec4);
}
static int BME_face_sharededges(BME_Poly *f1, BME_Poly *f2){
BME_Loop *l;

View File

@@ -52,7 +52,7 @@
#include "DNA_space_types.h"
#include "DNA_particle_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_editVert.h"
@@ -619,20 +619,20 @@ static void emDM__calcFaceCent(EditFace *efa, float cent[3], float (*vertexCos)[
{
if (vertexCos) {
VECCOPY(cent, vertexCos[(int) efa->v1->tmp.l]);
VecAddf(cent, cent, vertexCos[(int) efa->v2->tmp.l]);
VecAddf(cent, cent, vertexCos[(int) efa->v3->tmp.l]);
if (efa->v4) VecAddf(cent, cent, vertexCos[(int) efa->v4->tmp.l]);
add_v3_v3v3(cent, cent, vertexCos[(int) efa->v2->tmp.l]);
add_v3_v3v3(cent, cent, vertexCos[(int) efa->v3->tmp.l]);
if (efa->v4) add_v3_v3v3(cent, cent, vertexCos[(int) efa->v4->tmp.l]);
} else {
VECCOPY(cent, efa->v1->co);
VecAddf(cent, cent, efa->v2->co);
VecAddf(cent, cent, efa->v3->co);
if (efa->v4) VecAddf(cent, cent, efa->v4->co);
add_v3_v3v3(cent, cent, efa->v2->co);
add_v3_v3v3(cent, cent, efa->v3->co);
if (efa->v4) add_v3_v3v3(cent, cent, efa->v4->co);
}
if (efa->v4) {
VecMulf(cent, 0.25f);
mul_v3_fl(cent, 0.25f);
} else {
VecMulf(cent, 0.33333333333f);
mul_v3_fl(cent, 0.33333333333f);
}
}
static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *userData, int index, float *co, float *no), void *userData)
@@ -1498,25 +1498,25 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob,
if(efa->v4) {
float *v4 = vertexCos[(int) efa->v4->tmp.l];
CalcNormFloat4(v1, v2, v3, v4, no);
VecAddf(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no);
normal_quad_v3( no,v1, v2, v3, v4);
add_v3_v3v3(emdm->vertexNos[(int) efa->v4->tmp.l], emdm->vertexNos[(int) efa->v4->tmp.l], no);
}
else {
CalcNormFloat(v1, v2, v3, no);
normal_tri_v3( no,v1, v2, v3);
}
VecAddf(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no);
VecAddf(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no);
VecAddf(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no);
add_v3_v3v3(emdm->vertexNos[(int) efa->v1->tmp.l], emdm->vertexNos[(int) efa->v1->tmp.l], no);
add_v3_v3v3(emdm->vertexNos[(int) efa->v2->tmp.l], emdm->vertexNos[(int) efa->v2->tmp.l], no);
add_v3_v3v3(emdm->vertexNos[(int) efa->v3->tmp.l], emdm->vertexNos[(int) efa->v3->tmp.l], no);
}
for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) {
float *no = emdm->vertexNos[i];
/* following Mesh convention; we use vertex coordinate itself
* for normal in this case */
if (Normalize(no)==0.0) {
if (normalize_v3(no)==0.0) {
VECCOPY(no, vertexCos[i]);
Normalize(no);
normalize_v3(no);
}
}
}
@@ -2482,7 +2482,7 @@ int editmesh_get_first_deform_matrices(Object *ob, EditMesh *em, float (**deform
defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats");
for(a=0; a<numVerts; a++)
Mat3One(defmats[a]);
unit_m3(defmats[a]);
}
mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats,
@@ -2554,11 +2554,11 @@ void DM_add_tangent_layer(DerivedMesh *dm)
if (mf->v4) {
v4= &mvert[mf->v4];
CalcNormFloat4(v4->co, v3->co, v2->co, v1->co, fno);
normal_quad_v3( fno,v4->co, v3->co, v2->co, v1->co);
}
else {
v4= NULL;
CalcNormFloat(v3->co, v2->co, v1->co, fno);
normal_tri_v3( fno,v3->co, v2->co, v1->co);
}
if(mtface) {
@@ -2569,11 +2569,11 @@ void DM_add_tangent_layer(DerivedMesh *dm)
}
else {
uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3];
spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]);
spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]);
spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]);
map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
if(v4)
spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]);
map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
}
tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang);
@@ -2603,11 +2603,11 @@ void DM_add_tangent_layer(DerivedMesh *dm)
}
else {
uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3];
spheremap(orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2], &uv[0][0], &uv[0][1]);
spheremap(orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2], &uv[1][0], &uv[1][1]);
spheremap(orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2], &uv[2][0], &uv[2][1]);
map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]);
map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]);
map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]);
if(len==4)
spheremap(orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2], &uv[3][0], &uv[3][1]);
map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]);
}
mf_vi[0]= mf->v1;
@@ -2619,7 +2619,7 @@ void DM_add_tangent_layer(DerivedMesh *dm)
vtang= find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]);
VECCOPY(tangent[j], vtang);
Normalize(tangent[j]);
normalize_v3(tangent[j]);
}
}

View File

@@ -64,7 +64,7 @@
#include "BKE_utildefines.h"
#include "BIK_api.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
@@ -453,7 +453,7 @@ bPoseChannel *verify_pose_channel(bPose* pose, const char* name)
chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f;
chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f;
chan->ikrotweight = chan->iklinweight = 0.0f;
Mat4One(chan->constinv);
unit_m4(chan->constinv);
BLI_addtail(&pose->chanbase, chan);
@@ -471,7 +471,7 @@ bPoseChannel *get_active_posechannel (Object *ob)
/* find active */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if ((pchan->bone) && (pchan->bone->flag & BONE_ACTIVE) && (pchan->bone->layer & arm->layer))
if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer))
return pchan;
}
@@ -611,8 +611,8 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
pchan->rotAngle= chan->rotAngle;
QUATCOPY(pchan->quat, chan->quat);
pchan->rotmode= chan->rotmode;
Mat4CpyMat4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
Mat4CpyMat4(pchan->pose_mat, (float(*)[4])chan->pose_mat);
copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat);
copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat);
pchan->flag= chan->flag;
con= chan->constraints.first;
@@ -1013,8 +1013,8 @@ void copy_pose_result(bPose *to, bPose *from)
for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
pchanto= get_pose_channel(to, pchanfrom->name);
if(pchanto) {
Mat4CpyMat4(pchanto->pose_mat, pchanfrom->pose_mat);
Mat4CpyMat4(pchanto->chan_mat, pchanfrom->chan_mat);
copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
/* used for local constraints */
VECCOPY(pchanto->loc, pchanfrom->loc);
@@ -1040,9 +1040,9 @@ void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose,
clear_workob(workob);
/* init workob */
Mat4CpyMat4(workob->obmat, ob->obmat);
Mat4CpyMat4(workob->parentinv, ob->parentinv);
Mat4CpyMat4(workob->constinv, ob->constinv);
copy_m4_m4(workob->obmat, ob->obmat);
copy_m4_m4(workob->parentinv, ob->parentinv);
copy_m4_m4(workob->constinv, ob->constinv);
workob->parent= ob->parent;
workob->track= ob->track;
@@ -1109,7 +1109,7 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo
dstweight = 1.0F;
}
VecLerpf(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight);
interp_v3_v3v3(dst->stride_offset, dst->stride_offset, src->stride_offset, srcweight);
}
@@ -1169,27 +1169,27 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src,
execute_action_ipo(achan, &pchan);
/* store offset that moves src to location of pchan */
VecSubf(vec, dpchan->loc, pchan.loc);
sub_v3_v3v3(vec, dpchan->loc, pchan.loc);
Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec);
mul_mat3_m4_v3(dpchan->bone->arm_mat, vec);
}
}
else {
/* store offset that moves src to location of dst */
VecSubf(vec, dpchan->loc, spchan->loc);
Mat4Mul3Vecfl(dpchan->bone->arm_mat, vec);
sub_v3_v3v3(vec, dpchan->loc, spchan->loc);
mul_mat3_m4_v3(dpchan->bone->arm_mat, vec);
}
/* if blending, we only add with factor scrweight */
VecMulf(vec, srcweight);
mul_v3_fl(vec, srcweight);
VecAddf(dst->cyclic_offset, dst->cyclic_offset, vec);
add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, vec);
}
}
}
VecAddf(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset);
add_v3_v3v3(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset);
}
/* added "sizecorr" here, to allow armatures to be scaled and still have striding.
@@ -1249,14 +1249,14 @@ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip
if (pdistNewNormalized <= 1) {
// search for correction in positive path-direction
where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */
VecSubf(stride_offset, vec2, vec1);
sub_v3_v3v3(stride_offset, vec2, vec1);
}
else {
// we reached the end of the path, search backwards instead
where_on_path(ob, (pathdist-pdist)/path->totdist, vec2, dir); /* vec needs size 4 */
VecSubf(stride_offset, vec1, vec2);
sub_v3_v3v3(stride_offset, vec1, vec2);
}
Mat4Mul3Vecfl(ob->obmat, stride_offset);
mul_mat3_m4_v3(ob->obmat, stride_offset);
return striptime;
}
}
@@ -1295,10 +1295,10 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float
}
if(foundvert) {
/* bring it into armature space */
VecSubf(min, max, min);
sub_v3_v3v3(min, max, min);
bone= get_named_bone(ob->data, strip->offs_bone); /* weak */
if(bone) {
Mat4Mul3Vecfl(bone->arm_mat, min);
mul_mat3_m4_v3(bone->arm_mat, min);
/* dominant motion, cyclic_offset was cleared in rest_pose */
if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) {
@@ -1549,7 +1549,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype)
}
else if(blocktype==ID_AR) {
/* apply stride offset to object */
VecAddf(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset);
add_v3_v3v3(ob->obmat[3], ob->obmat[3], ob->pose->stride_offset);
}
/* free */

View File

@@ -35,7 +35,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "DNA_listBase.h"
@@ -134,11 +134,11 @@ void calc_curvepath(Object *ob)
for(a=0; a<tot; a++) {
fp++;
if(cycl && a==tot-1)
VecSubf(xyz, bevpfirst->vec, bevp->vec);
sub_v3_v3v3(xyz, bevpfirst->vec, bevp->vec);
else
VecSubf(xyz, (bevp+1)->vec, bevp->vec);
sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec);
*fp= *(fp-1)+VecLength(xyz);
*fp= *(fp-1)+len_v3(xyz);
bevp++;
}
@@ -176,11 +176,11 @@ void calc_curvepath(Object *ob)
fac1= fac2/fac1;
fac2= 1.0f-fac1;
VecLerpf(pp->vec, bevp->vec, bevpn->vec, fac2);
interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2);
pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa;
pp->radius= fac1*bevp->radius + fac2*bevpn->radius;
QuatInterpol(pp->quat, bevp->quat, bevpn->quat, fac2);
NormalQuat(pp->quat);
interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2);
normalize_qt(pp->quat);
pp++;
}
@@ -284,20 +284,20 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat,
* to more then one index in data which can give divide by zero error */
/*
totfac= data[0]+data[1];
if(totfac>0.000001) QuatInterpol(q1, p0->quat, p1->quat, data[0] / totfac);
if(totfac>0.000001) interp_qt_qtqt(q1, p0->quat, p1->quat, data[0] / totfac);
else QUATCOPY(q1, p1->quat);
NormalQuat(q1);
normalize_qt(q1);
totfac= data[2]+data[3];
if(totfac>0.000001) QuatInterpol(q2, p2->quat, p3->quat, data[2] / totfac);
if(totfac>0.000001) interp_qt_qtqt(q2, p2->quat, p3->quat, data[2] / totfac);
else QUATCOPY(q1, p3->quat);
NormalQuat(q2);
normalize_qt(q2);
totfac = data[0]+data[1]+data[2]+data[3];
if(totfac>0.000001) QuatInterpol(quat, q1, q2, (data[0]+data[1]) / totfac);
if(totfac>0.000001) interp_qt_qtqt(quat, q1, q2, (data[0]+data[1]) / totfac);
else QUATCOPY(quat, q2);
NormalQuat(quat);
normalize_qt(quat);
*/
// XXX - find some way to make quat interpolation work correctly, above code fails in rare but nasty cases.
QUATCOPY(quat, p1->quat);
@@ -317,8 +317,8 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i
BLI_addtail(lb, dob);
dob->ob= ob;
Mat4CpyMat4(dob->mat, mat);
Mat4CpyMat4(dob->omat, ob->obmat);
copy_m4_m4(dob->mat, mat);
copy_m4_m4(dob->omat, ob->obmat);
dob->origlay= ob->lay;
dob->index= index;
dob->type= type;
@@ -352,20 +352,20 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
/* Group Dupli Offset, should apply after everything else */
if (group->dupli_ofs[0] || group->dupli_ofs[1] || group->dupli_ofs[2]) {
Mat4CpyMat4(tmat, go->ob->obmat);
VecSubf(tmat[3], tmat[3], group->dupli_ofs);
Mat4MulMat4(mat, tmat, ob->obmat);
copy_m4_m4(tmat, go->ob->obmat);
sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
mul_m4_m4m4(mat, tmat, ob->obmat);
} else {
Mat4MulMat4(mat, go->ob->obmat, ob->obmat);
mul_m4_m4m4(mat, go->ob->obmat, ob->obmat);
}
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated);
dob->no_draw= (dob->origlay & group->layer)==0;
if(go->ob->transflag & OB_DUPLI) {
Mat4CpyMat4(dob->ob->obmat, dob->mat);
copy_m4_m4(dob->ob->obmat, dob->mat);
object_duplilist_recursive((ID *)group, scene, go->ob, lb, ob->obmat, level+1, animated);
Mat4CpyMat4(dob->ob->obmat, dob->omat);
copy_m4_m4(dob->ob->obmat, dob->omat);
}
}
}
@@ -402,7 +402,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level,
#endif // XXX old animation system
where_is_object_time(scene, ob, (float)scene->r.cfra);
dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated);
Mat4CpyMat4(dob->omat, copyob.obmat);
copy_m4_m4(dob->omat, copyob.obmat);
}
}
@@ -430,11 +430,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4];
VECCOPY(vec, co);
Mat4MulVecfl(vdd->pmat, vec);
VecSubf(vec, vec, vdd->pmat[3]);
VecAddf(vec, vec, vdd->obmat[3]);
mul_m4_v3(vdd->pmat, vec);
sub_v3_v3v3(vec, vec, vdd->pmat[3]);
add_v3_v3v3(vec, vec, vdd->obmat[3]);
Mat4CpyMat4(obmat, vdd->obmat);
copy_m4_m4(obmat, vdd->obmat);
VECCOPY(obmat[3], vec);
if(vdd->par->transflag & OB_DUPLIROT) {
@@ -445,11 +445,11 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2];
}
vectoquat(vec, vdd->ob->trackflag, vdd->ob->upflag, q2);
vec_to_quat( q2,vec, vdd->ob->trackflag, vdd->ob->upflag);
QuatToMat3(q2, mat);
Mat4CpyMat4(tmat, obmat);
Mat4MulMat43(obmat, tmat, mat);
quat_to_mat3( mat,q2);
copy_m4_m4(tmat, obmat);
mul_m4_m4m3(obmat, tmat, mat);
}
dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated);
if(vdd->orco)
@@ -457,10 +457,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
if(vdd->ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
Mat4CpyMat4(tmpmat, vdd->ob->obmat);
Mat4CpyMat4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
copy_m4_m4(tmpmat, vdd->ob->obmat);
copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */
object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated);
Mat4CpyMat4(vdd->ob->obmat, tmpmat);
copy_m4_m4(vdd->ob->obmat, tmpmat);
}
}
@@ -478,7 +478,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
float vec[3], no[3], pmat[4][4];
int lay, totvert, a, oblay;
Mat4CpyMat4(pmat, par->obmat);
copy_m4_m4(pmat, par->obmat);
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
@@ -533,9 +533,9 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
if(par_space_mat)
Mat4MulMat4(vdd.obmat, ob->obmat, par_space_mat);
mul_m4_m4m4(vdd.obmat, ob->obmat, par_space_mat);
else
Mat4CpyMat4(vdd.obmat, ob->obmat);
copy_m4_m4(vdd.obmat, ob->obmat);
vdd.id= id;
vdd.level= level;
@@ -544,7 +544,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
vdd.ob= ob;
vdd.scene= scene;
vdd.par= par;
Mat4CpyMat4(vdd.pmat, pmat);
copy_m4_m4(vdd.pmat, pmat);
/* mballs have a different dupli handling */
if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
@@ -596,7 +596,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
Mat4CpyMat4(pmat, par->obmat);
copy_m4_m4(pmat, par->obmat);
em = BKE_mesh_get_editmesh(me);
if(em) {
@@ -664,11 +664,11 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
when par_space_mat is NULL ob->obmat can be used instead of ob__obmat
*/
if(par_space_mat)
Mat4MulMat4(ob__obmat, ob->obmat, par_space_mat);
mul_m4_m4m4(ob__obmat, ob->obmat, par_space_mat);
else
Mat4CpyMat4(ob__obmat, ob->obmat);
copy_m4_m4(ob__obmat, ob->obmat);
Mat3CpyMat4(imat, ob->parentinv);
copy_m3_m4(imat, ob->parentinv);
/* mballs have a different dupli handling */
if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
@@ -686,34 +686,34 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
/* translation */
if(v4)
CalcCent4f(cent, v1, v2, v3, v4);
cent_quad_v3(cent, v1, v2, v3, v4);
else
CalcCent3f(cent, v1, v2, v3);
Mat4MulVecfl(pmat, cent);
cent_tri_v3(cent, v1, v2, v3);
mul_m4_v3(pmat, cent);
VecSubf(cent, cent, pmat[3]);
VecAddf(cent, cent, ob__obmat[3]);
sub_v3_v3v3(cent, cent, pmat[3]);
add_v3_v3v3(cent, cent, ob__obmat[3]);
Mat4CpyMat4(obmat, ob__obmat);
copy_m4_m4(obmat, ob__obmat);
VECCOPY(obmat[3], cent);
/* rotation */
triatoquat(v1, v2, v3, quat);
QuatToMat3(quat, mat);
tri_to_quat( quat,v1, v2, v3);
quat_to_mat3( mat,quat);
/* scale */
if(par->transflag & OB_DUPLIFACES_SCALE) {
float size= v4?AreaQ3Dfl(v1, v2, v3, v4):AreaT3Dfl(v1, v2, v3);
float size= v4? area_quad_v3(v1, v2, v3, v4): area_tri_v3(v1, v2, v3);
size= sqrt(size) * par->dupfacesca;
Mat3MulFloat(mat[0], size);
mul_m3_fl(mat, size);
}
Mat3CpyMat3(mat3, mat);
Mat3MulMat3(mat, imat, mat3);
copy_m3_m3(mat3, mat);
mul_m3_m3m3(mat, imat, mat3);
Mat4CpyMat4(tmat, obmat);
Mat4MulMat43(obmat, tmat, mat);
copy_m4_m4(tmat, obmat);
mul_m4_m4m3(obmat, tmat, mat);
dob= new_dupli_object(lb, ob, obmat, lay, a, OB_DUPLIFACES, animated);
if(G.rendering) {
@@ -744,10 +744,10 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
if(ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
Mat4CpyMat4(tmpmat, ob->obmat);
Mat4CpyMat4(ob->obmat, obmat); /* pretend we are really this mat */
copy_m4_m4(tmpmat, ob->obmat);
copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */
object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated);
Mat4CpyMat4(ob->obmat, tmpmat);
copy_m4_m4(ob->obmat, tmpmat);
}
}
@@ -935,22 +935,22 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if(psys_get_particle_state(&sim, a, &state, 0) == 0)
continue;
QuatToMat4(state.rot, pamat);
quat_to_mat4( pamat,state.rot);
VECCOPY(pamat[3], state.co);
pamat[3][3]= 1.0f;
}
if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
Mat4MulMat4(tmat, oblist[b]->obmat, pamat);
Mat4MulFloat3((float *)tmat, size*scale);
mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
mul_mat3_m4_fl(tmat, size*scale);
if(par_space_mat)
Mat4MulMat4(mat, tmat, par_space_mat);
mul_m4_m4m4(mat, tmat, par_space_mat);
else
Mat4CpyMat4(mat, tmat);
copy_m4_m4(mat, tmat);
dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated);
Mat4CpyMat4(dob->omat, obcopylist[b].obmat);
copy_m4_m4(dob->omat, obcopylist[b].obmat);
if(G.rendering)
psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
@@ -962,21 +962,21 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
VECCOPY(vec, obmat[3]);
obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f;
Mat4CpyMat4(mat, pamat);
copy_m4_m4(mat, pamat);
Mat4MulMat4(tmat, obmat, mat);
Mat4MulFloat3((float *)tmat, size*scale);
mul_m4_m4m4(tmat, obmat, mat);
mul_mat3_m4_fl(tmat, size*scale);
if(part->draw & PART_DRAW_GLOBAL_OB)
VECADD(tmat[3], tmat[3], vec);
if(par_space_mat)
Mat4MulMat4(mat, tmat, par_space_mat);
mul_m4_m4m4(mat, tmat, par_space_mat);
else
Mat4CpyMat4(mat, tmat);
copy_m4_m4(mat, tmat);
dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated);
Mat4CpyMat4(dob->omat, oldobmat);
copy_m4_m4(dob->omat, oldobmat);
if(G.rendering)
psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
}
@@ -1037,7 +1037,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
Mat4CpyMat4(pmat, par->obmat);
copy_m4_m4(pmat, par->obmat);
/* in par the family name is stored, use this to find the other objects */
@@ -1062,9 +1062,9 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
vec[1]= fsize*(ct->yof - yof);
vec[2]= 0.0;
Mat4MulVecfl(pmat, vec);
mul_m4_v3(pmat, vec);
Mat4CpyMat4(obmat, par->obmat);
copy_m4_m4(obmat, par->obmat);
VECCOPY(obmat[3], vec);
new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIVERTS, animated);
@@ -1122,7 +1122,7 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
if (level==0) {
for(dob= duplilist->first; dob; dob= dob->next)
if(dob->type == OB_DUPLIGROUP)
Mat4CpyMat4(dob->ob->obmat, dob->mat);
copy_m4_m4(dob->ob->obmat, dob->mat);
}
}
}
@@ -1143,7 +1143,7 @@ void free_object_duplilist(ListBase *lb)
for(dob= lb->first; dob; dob= dob->next) {
dob->ob->lay= dob->origlay;
Mat4CpyMat4(dob->ob->obmat, dob->omat);
copy_m4_m4(dob->ob->obmat, dob->omat);
}
BLI_freelistN(lb);

View File

@@ -36,7 +36,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_dynstr.h"
#include "DNA_anim_types.h"

View File

@@ -34,7 +34,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "DNA_armature_types.h"
@@ -169,10 +169,13 @@ void make_local_armature(bArmature *arm)
}
}
static void copy_bonechildren (Bone* newBone, Bone* oldBone)
static void copy_bonechildren (Bone* newBone, Bone* oldBone, Bone* actBone, Bone **newActBone)
{
Bone *curBone, *newChildBone;
if(oldBone == actBone)
*newActBone= newBone;
/* Copy this bone's list*/
BLI_duplicatelist(&newBone->childbase, &oldBone->childbase);
@@ -180,7 +183,7 @@ static void copy_bonechildren (Bone* newBone, Bone* oldBone)
newChildBone=newBone->childbase.first;
for (curBone=oldBone->childbase.first;curBone;curBone=curBone->next){
newChildBone->parent=newBone;
copy_bonechildren(newChildBone,curBone);
copy_bonechildren(newChildBone, curBone, actBone, newActBone);
newChildBone=newChildBone->next;
}
}
@@ -189,6 +192,7 @@ bArmature *copy_armature(bArmature *arm)
{
bArmature *newArm;
Bone *oldBone, *newBone;
Bone *newActBone= NULL;
newArm= copy_libblock (arm);
BLI_duplicatelist(&newArm->bonebase, &arm->bonebase);
@@ -197,10 +201,11 @@ bArmature *copy_armature(bArmature *arm)
newBone=newArm->bonebase.first;
for (oldBone=arm->bonebase.first;oldBone;oldBone=oldBone->next){
newBone->parent=NULL;
copy_bonechildren (newBone, oldBone);
copy_bonechildren (newBone, oldBone, arm->act_bone, &newActBone);
newBone=newBone->next;
};
newArm->act_bone= newActBone;
return newArm;
}
@@ -477,7 +482,7 @@ static void equalize_bezier(float *data, int desired)
pdist[0]= 0.0f;
for(a=0, fp= data; a<MAX_BBONE_SUBDIV; a++, fp+=4) {
QUATCOPY(temp[a], fp);
pdist[a+1]= pdist[a]+VecLenf(fp, fp+4);
pdist[a+1]= pdist[a]+len_v3v3(fp, fp+4);
}
/* do last point */
QUATCOPY(temp[a], fp);
@@ -527,16 +532,16 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
if(!rest) {
/* check if we need to take non-uniform bone scaling into account */
scale[0]= VecLength(pchan->pose_mat[0]);
scale[1]= VecLength(pchan->pose_mat[1]);
scale[2]= VecLength(pchan->pose_mat[2]);
scale[0]= len_v3(pchan->pose_mat[0]);
scale[1]= len_v3(pchan->pose_mat[1]);
scale[2]= len_v3(pchan->pose_mat[2]);
if(fabs(scale[0] - scale[1]) > 1e-6f || fabs(scale[1] - scale[2]) > 1e-6f) {
Mat4One(scalemat);
unit_m4(scalemat);
scalemat[0][0]= scale[0];
scalemat[1][1]= scale[1];
scalemat[2][2]= scale[2];
Mat4Invert(iscalemat, scalemat);
invert_m4_m4(iscalemat, scalemat);
length *= scale[1];
doscale = 1;
@@ -559,15 +564,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
last point = (0, length, 0) */
if(rest) {
Mat4Invert(imat, pchan->bone->arm_mat);
invert_m4_m4(imat, pchan->bone->arm_mat);
}
else if(doscale) {
Mat4CpyMat4(posemat, pchan->pose_mat);
Mat4Ortho(posemat);
Mat4Invert(imat, posemat);
copy_m4_m4(posemat, pchan->pose_mat);
normalize_m4(posemat);
invert_m4_m4(imat, posemat);
}
else
Mat4Invert(imat, pchan->pose_mat);
invert_m4_m4(imat, pchan->pose_mat);
if(prev) {
float difmat[4][4], result[3][3], imat3[3][3];
@@ -577,7 +582,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
VECCOPY(h1, prev->bone->arm_head)
else
VECCOPY(h1, prev->pose_head)
Mat4MulVecfl(imat, h1);
mul_m4_v3(imat, h1);
if(prev->bone->segments>1) {
/* if previous bone is B-bone too, use average handle direction */
@@ -585,21 +590,21 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
roll1= 0.0f;
}
Normalize(h1);
VecMulf(h1, -hlength1);
normalize_v3(h1);
mul_v3_fl(h1, -hlength1);
if(prev->bone->segments==1) {
/* find the previous roll to interpolate */
if(rest)
Mat4MulMat4(difmat, prev->bone->arm_mat, imat);
mul_m4_m4m4(difmat, prev->bone->arm_mat, imat);
else
Mat4MulMat4(difmat, prev->pose_mat, imat);
Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone
mul_m4_m4m4(difmat, prev->pose_mat, imat);
copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone
vec_roll_to_mat3(h1, 0.0f, mat3); // the result of vec_roll without roll
Mat3Inv(imat3, mat3);
Mat3MulMat3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll
invert_m3_m3(imat3, mat3);
mul_m3_m3m3(mat3, result, imat3); // the matrix transforming vec_roll to desired roll
roll1= (float)atan2(mat3[2][0], mat3[2][2]);
}
@@ -616,28 +621,28 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
VECCOPY(h2, next->bone->arm_tail)
else
VECCOPY(h2, next->pose_tail)
Mat4MulVecfl(imat, h2);
mul_m4_v3(imat, h2);
/* if next bone is B-bone too, use average handle direction */
if(next->bone->segments>1);
else h2[1]-= length;
Normalize(h2);
normalize_v3(h2);
/* find the next roll to interpolate as well */
if(rest)
Mat4MulMat4(difmat, next->bone->arm_mat, imat);
mul_m4_m4m4(difmat, next->bone->arm_mat, imat);
else
Mat4MulMat4(difmat, next->pose_mat, imat);
Mat3CpyMat4(result, difmat); // the desired rotation at beginning of next bone
mul_m4_m4m4(difmat, next->pose_mat, imat);
copy_m3_m4(result, difmat); // the desired rotation at beginning of next bone
vec_roll_to_mat3(h2, 0.0f, mat3); // the result of vec_roll without roll
Mat3Inv(imat3, mat3);
Mat3MulMat3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll
invert_m3_m3(imat3, mat3);
mul_m3_m3m3(mat3, imat3, result); // the matrix transforming vec_roll to desired roll
roll2= (float)atan2(mat3[2][0], mat3[2][2]);
/* and only now negate handle */
VecMulf(h2, -hlength2);
mul_v3_fl(h2, -hlength2);
}
else {
h2[0]= 0.0f; h2[1]= -hlength2; h2[2]= 0.0f;
@@ -657,15 +662,15 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
/* make transformation matrices for the segments for drawing */
for(a=0, fp= data[0]; a<bone->segments; a++, fp+=4) {
VecSubf(h1, fp+4, fp);
sub_v3_v3v3(h1, fp+4, fp);
vec_roll_to_mat3(h1, fp[3], mat3); // fp[3] is roll
Mat4CpyMat3(result_array[a].mat, mat3);
copy_m4_m3(result_array[a].mat, mat3);
VECCOPY(result_array[a].mat[3], fp);
if(doscale) {
/* correct for scaling when this matrix is used in scaled space */
Mat4MulSerie(result_array[a].mat, iscalemat, result_array[a].mat,
mul_serie_m4(result_array[a].mat, iscalemat, result_array[a].mat,
scalemat, NULL, NULL, NULL, NULL, NULL);
}
}
@@ -696,26 +701,26 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion, int re
/* first matrix is the inverse arm_mat, to bring points in local bone space
for finding out which segment it belongs to */
Mat4Invert(b_bone_mats[0].mat, bone->arm_mat);
invert_m4_m4(b_bone_mats[0].mat, bone->arm_mat);
/* then we make the b_bone_mats:
- first transform to local bone space
- translate over the curve to the bbone mat space
- transform with b_bone matrix
- transform back into global space */
Mat4One(tmat);
unit_m4(tmat);
for(a=0; a<bone->segments; a++) {
if(b_bone_rest)
Mat4Invert(tmat, b_bone_rest[a].mat);
invert_m4_m4(tmat, b_bone_rest[a].mat);
else
tmat[3][1] = -a*(bone->length/(float)bone->segments);
Mat4MulSerie(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat,
mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat,
b_bone[a].mat, tmat, b_bone_mats[0].mat, NULL, NULL, NULL);
if(use_quaternion)
Mat4ToDQuat(bone->arm_mat, b_bone_mats[a+1].mat, &b_bone_dual_quats[a]);
mat4_to_dquat( &b_bone_dual_quats[a],bone->arm_mat, b_bone_mats[a+1].mat);
}
}
@@ -738,13 +743,13 @@ static void b_bone_deform(bPoseChannel *pchan, Bone *bone, float *co, DualQuat *
CLAMP(a, 0, bone->segments-1);
if(dq) {
DQuatCpyDQuat(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]);
copy_dq_dq(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]);
}
else {
Mat4MulVecfl(b_bone[a+1].mat, co);
mul_m4_v3(b_bone[a+1].mat, co);
if(defmat)
Mat3CpyMat4(defmat, b_bone[a+1].mat);
copy_m3_m4(defmat, b_bone[a+1].mat);
}
}
@@ -756,10 +761,10 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl
float pdelta[3];
float hsqr, a, l, rad;
VecSubf (bdelta, b2, b1);
l = Normalize (bdelta);
sub_v3_v3v3(bdelta, b2, b1);
l = normalize_v3(bdelta);
VecSubf (pdelta, vec, b1);
sub_v3_v3v3(pdelta, vec, b1);
a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2];
hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2]));
@@ -804,12 +809,12 @@ static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonem
float wmat[3][3];
if(pchan->bone->segments>1)
Mat3CpyMat3(wmat, bbonemat);
copy_m3_m3(wmat, bbonemat);
else
Mat3CpyMat4(wmat, pchan->chan_mat);
copy_m3_m4(wmat, pchan->chan_mat);
Mat3MulFloat((float*)wmat, weight);
Mat3AddMat3(mat, mat, wmat);
mul_m3_fl(wmat, weight);
add_m3_m3m3(mat, mat, wmat);
}
static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, float mat[][3], float *co)
@@ -835,12 +840,12 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo
// applies on cop and bbonemat
b_bone_deform(pchan, bone, cop, NULL, (mat)?bbonemat:NULL);
else
Mat4MulVecfl(pchan->chan_mat, cop);
mul_m4_v3(pchan->chan_mat, cop);
// Make this a delta from the base position
VecSubf (cop, cop, co);
sub_v3_v3v3(cop, cop, co);
cop[0]*=fac; cop[1]*=fac; cop[2]*=fac;
VecAddf (vec, vec, cop);
add_v3_v3v3(vec, vec, cop);
if(mat)
pchan_deform_mat_add(pchan, fac, bbonemat, mat);
@@ -848,10 +853,10 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo
else {
if(bone->segments>1) {
b_bone_deform(pchan, bone, cop, &bbonedq, NULL);
DQuatAddWeighted(dq, &bbonedq, fac);
add_weighted_dq_dq(dq, &bbonedq, fac);
}
else
DQuatAddWeighted(dq, pchan->dual_quat, fac);
add_weighted_dq_dq(dq, pchan->dual_quat, fac);
}
}
}
@@ -874,7 +879,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua
// applies on cop and bbonemat
b_bone_deform(pchan, pchan->bone, cop, NULL, (mat)?bbonemat:NULL);
else
Mat4MulVecfl(pchan->chan_mat, cop);
mul_m4_v3(pchan->chan_mat, cop);
vec[0]+=(cop[0]-co[0])*weight;
vec[1]+=(cop[1]-co[1])*weight;
@@ -886,10 +891,10 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua
else {
if(pchan->bone->segments>1) {
b_bone_deform(pchan, pchan->bone, cop, &bbonedq, NULL);
DQuatAddWeighted(dq, &bbonedq, weight);
add_weighted_dq_dq(dq, &bbonedq, weight);
}
else
DQuatAddWeighted(dq, pchan->dual_quat, weight);
add_weighted_dq_dq(dq, pchan->dual_quat, weight);
}
(*contrib)+=weight;
@@ -918,10 +923,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
if(arm->edbo) return;
Mat4Invert(obinv, target->obmat);
Mat4CpyMat4(premat, target->obmat);
Mat4MulMat4(postmat, armOb->obmat, obinv);
Mat4Invert(premat, postmat);
invert_m4_m4(obinv, target->obmat);
copy_m4_m4(premat, target->obmat);
mul_m4_m4m4(postmat, armOb->obmat, obinv);
invert_m4_m4(premat, postmat);
/* bone defmats are already in the channels, chan_mat */
@@ -939,7 +944,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
if(use_quaternion) {
pchan->dual_quat= &dualquats[totchan++];
Mat4ToDQuat(pchan->bone->arm_mat, pchan->chan_mat, pchan->dual_quat);
mat4_to_dquat( pchan->dual_quat,pchan->bone->arm_mat, pchan->chan_mat);
}
}
}
@@ -1008,7 +1013,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
vec= sumvec;
if(defMats) {
Mat3Clr((float*)summat);
zero_m3(summat);
smat = summat;
}
}
@@ -1045,7 +1050,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
co= prevCos?prevCos[i]:vertexCos[i];
/* Apply the object's matrix */
Mat4MulVecfl(premat, co);
mul_m4_v3(premat, co);
if(use_dverts && dvert && dvert->totweight) { // use weight groups ?
int deformed = 0;
@@ -1091,42 +1096,42 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
/* actually should be EPSILON? weight values and contrib can be like 10e-39 small */
if(contrib > 0.0001f) {
if(use_quaternion) {
DQuatNormalize(dq, contrib);
normalize_dq(dq, contrib);
if(armature_weight != 1.0f) {
VECCOPY(dco, co);
DQuatMulVecfl(dq, dco, (defMats)? summat: NULL);
VecSubf(dco, dco, co);
VecMulf(dco, armature_weight);
VecAddf(co, co, dco);
mul_v3m3_dq( dco, (defMats)? summat: NULL,dq);
sub_v3_v3v3(dco, dco, co);
mul_v3_fl(dco, armature_weight);
add_v3_v3v3(co, co, dco);
}
else
DQuatMulVecfl(dq, co, (defMats)? summat: NULL);
mul_v3m3_dq( co, (defMats)? summat: NULL,dq);
smat = summat;
}
else {
VecMulf(vec, armature_weight/contrib);
VecAddf(co, vec, co);
mul_v3_fl(vec, armature_weight/contrib);
add_v3_v3v3(co, vec, co);
}
if(defMats) {
float pre[3][3], post[3][3], tmpmat[3][3];
Mat3CpyMat4(pre, premat);
Mat3CpyMat4(post, postmat);
Mat3CpyMat3(tmpmat, defMats[i]);
copy_m3_m4(pre, premat);
copy_m3_m4(post, postmat);
copy_m3_m3(tmpmat, defMats[i]);
if(!use_quaternion) /* quaternion already is scale corrected */
Mat3MulFloat((float*)smat, armature_weight/contrib);
mul_m3_fl(smat, armature_weight/contrib);
Mat3MulSerie(defMats[i], tmpmat, pre, smat, post,
mul_serie_m3(defMats[i], tmpmat, pre, smat, post,
NULL, NULL, NULL, NULL);
}
}
/* always, check above code */
Mat4MulVecfl(postmat, co);
mul_m4_v3(postmat, co);
/* interpolate with previous modifier position using weight group */
@@ -1160,7 +1165,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed)
{
Mat4CpyMat4(M_accumulatedMatrix, bone->arm_mat);
copy_m4_m4(M_accumulatedMatrix, bone->arm_mat);
}
/* **************** Space to Space API ****************** */
@@ -1174,10 +1179,10 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4])
if (ob==NULL) return;
/* get inverse of (armature) object's matrix */
Mat4Invert(obmat, ob->obmat);
invert_m4_m4(obmat, ob->obmat);
/* multiply given matrix by object's-inverse to find pose-space matrix */
Mat4MulMat4(outmat, obmat, inmat);
mul_m4_m4m4(outmat, obmat, inmat);
}
/* Convert Wolrd-Space Location to Pose-Space Location
@@ -1190,7 +1195,7 @@ void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc)
float nLocMat[4][4];
/* build matrix for location */
Mat4One(xLocMat);
unit_m4(xLocMat);
VECCOPY(xLocMat[3], inloc);
/* get bone-space cursor matrix and extract location */
@@ -1212,24 +1217,24 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm
/* get the inverse matrix of the pchan's transforms */
if (pchan->rotmode)
LocEulSizeToMat4(pc_trans, pchan->loc, pchan->eul, pchan->size);
loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size);
else
LocQuatSizeToMat4(pc_trans, pchan->loc, pchan->quat, pchan->size);
Mat4Invert(inv_trans, pc_trans);
loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, pchan->size);
invert_m4_m4(inv_trans, pc_trans);
/* Remove the pchan's transforms from it's pose_mat.
* This should leave behind the effects of restpose +
* parenting + constraints
*/
Mat4MulMat4(pc_posemat, inv_trans, pchan->pose_mat);
mul_m4_m4m4(pc_posemat, inv_trans, pchan->pose_mat);
/* get the inverse of the leftovers so that we can remove
* that component from the supplied matrix
*/
Mat4Invert(inv_posemat, pc_posemat);
invert_m4_m4(inv_posemat, pc_posemat);
/* get the new matrix */
Mat4MulMat4(outmat, inmat, inv_posemat);
mul_m4_m4m4(outmat, inmat, inv_posemat);
}
/* Convert Pose-Space Location to Bone-Space Location
@@ -1242,7 +1247,7 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc)
float nLocMat[4][4];
/* build matrix for location */
Mat4One(xLocMat);
unit_m4(xLocMat);
VECCOPY(xLocMat[3], inloc);
/* get bone-space cursor matrix and extract location */
@@ -1258,8 +1263,8 @@ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float
{
float imat[4][4];
Mat4Invert(imat, arm_mat);
Mat4MulMat4(delta_mat, pose_mat, imat);
invert_m4_m4(imat, arm_mat);
mul_m4_m4m4(delta_mat, pose_mat, imat);
}
/* **************** Rotation Mode Conversions ****************************** */
@@ -1275,33 +1280,33 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa
if (newMode > 0) { /* to euler */
if (oldMode == ROT_MODE_AXISANGLE) {
/* axis-angle to euler */
AxisAngleToEulO(axis, *angle, eul, newMode);
axis_angle_to_eulO( eul, newMode,axis, *angle);
}
else if (oldMode == ROT_MODE_QUAT) {
/* quat to euler */
QuatToEulO(quat, eul, newMode);
quat_to_eulO( eul, newMode,quat);
}
/* else { no conversion needed } */
}
else if (newMode == ROT_MODE_QUAT) { /* to quat */
if (oldMode == ROT_MODE_AXISANGLE) {
/* axis angle to quat */
AxisAngleToQuat(quat, axis, *angle);
axis_angle_to_quat(quat, axis, *angle);
}
else if (oldMode > 0) {
/* euler to quat */
EulOToQuat(eul, oldMode, quat);
eulO_to_quat( quat,eul, oldMode);
}
/* else { no conversion needed } */
}
else if (newMode == ROT_MODE_AXISANGLE) { /* to axis-angle */
if (oldMode > 0) {
/* euler to axis angle */
EulOToAxisAngle(eul, oldMode, axis, angle);
eulO_to_axis_angle( axis, angle,eul, oldMode);
}
else if (oldMode == ROT_MODE_QUAT) {
/* quat to axis angle */
QuatToAxisAngle(quat, axis, angle);
quat_to_axis_angle( axis, angle,quat);
}
/* when converting to axis-angle, we need a special exception for the case when there is no axis */
@@ -1336,14 +1341,14 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa
void mat3_to_vec_roll(float mat[][3], float *vec, float *roll)
{
if (vec)
VecCopyf(vec, mat[1]);
copy_v3_v3(vec, mat[1]);
if (roll) {
float vecmat[3][3], vecmatinv[3][3], rollmat[3][3];
vec_roll_to_mat3(mat[1], 0.0f, vecmat);
Mat3Inv(vecmatinv, vecmat);
Mat3MulMat3(rollmat, vecmatinv, mat);
invert_m3_m3(vecmatinv, vecmat);
mul_m3_m3m3(rollmat, vecmatinv, mat);
*roll= (float)atan2(rollmat[2][0], rollmat[2][2]);
}
@@ -1358,26 +1363,26 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
float rMatrix[3][3], bMatrix[3][3];
VECCOPY (nor, vec);
Normalize (nor);
normalize_v3(nor);
/* Find Axis & Amount for bone matrix*/
Crossf (axis,target,nor);
cross_v3_v3v3(axis,target,nor);
if (Inpf(axis,axis) > 0.0000000000001) {
if (dot_v3v3(axis,axis) > 0.0000000000001) {
/* if nor is *not* a multiple of target ... */
Normalize (axis);
normalize_v3(axis);
theta= NormalizedVecAngle2(target, nor);
theta= angle_normalized_v3v3(target, nor);
/* Make Bone matrix*/
VecRotToMat3(axis, theta, bMatrix);
vec_rot_to_mat3( bMatrix,axis, theta);
}
else {
/* if nor is a multiple of target ... */
float updown;
/* point same direction, or opposite? */
updown = ( Inpf (target,nor) > 0 ) ? 1.0f : -1.0f;
updown = ( dot_v3v3(target,nor) > 0 ) ? 1.0f : -1.0f;
/* I think this should work ... */
bMatrix[0][0]=updown; bMatrix[0][1]=0.0; bMatrix[0][2]=0.0;
@@ -1386,10 +1391,10 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
}
/* Make Roll matrix*/
VecRotToMat3(nor, roll, rMatrix);
vec_rot_to_mat3( rMatrix,nor, roll);
/* Combine and output result*/
Mat3MulMat3 (mat, rMatrix, bMatrix);
mul_m3_m3m3(mat, rMatrix, bMatrix);
}
@@ -1400,10 +1405,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
float vec[3];
/* Bone Space */
VecSubf (vec, bone->tail, bone->head);
sub_v3_v3v3(vec, bone->tail, bone->head);
vec_roll_to_mat3(vec, bone->roll, bone->bone_mat);
bone->length= VecLenf(bone->head, bone->tail);
bone->length= len_v3v3(bone->head, bone->tail);
/* this is called on old file reading too... */
if(bone->xwidth==0.0) {
@@ -1416,7 +1421,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b)
/* bone transform itself */
Mat4CpyMat3(offs_bone, bone->bone_mat);
copy_m4_m3(offs_bone, bone->bone_mat);
/* The bone's root offset (is in the parent's coordinate system) */
VECCOPY(offs_bone[3], bone->head);
@@ -1425,10 +1430,10 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
offs_bone[3][1]+= prevbone->length;
/* Compose the matrix for this bone */
Mat4MulMat4(bone->arm_mat, offs_bone, prevbone->arm_mat);
mul_m4_m4m4(bone->arm_mat, offs_bone, prevbone->arm_mat);
}
else {
Mat4CpyMat3(bone->arm_mat, bone->bone_mat);
copy_m4_m3(bone->arm_mat, bone->bone_mat);
VECCOPY(bone->arm_mat[3], bone->head);
}
@@ -1436,8 +1441,8 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone)
VECCOPY(bone->arm_head, bone->arm_mat[3]);
/* tail is in current local coord system */
VECCOPY(vec, bone->arm_mat[1]);
VecMulf(vec, bone->length);
VecAddf(bone->arm_tail, bone->arm_head, vec);
mul_v3_fl(vec, bone->length);
add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
/* and the kiddies */
prevbone= bone;
@@ -1689,8 +1694,6 @@ static void splineik_init_tree_from_pchan(Object *ob, bPoseChannel *pchan_tip)
/* setup new empty array for the points list */
if (ikData->points)
MEM_freeN(ikData->points);
// NOTE: just do chainlen+1 always for now, since we may get crashes otherwise
//ikData->numpoints= (ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT)? ikData->chainlen : ikData->chainlen+1;
ikData->numpoints= ikData->chainlen+1;
ikData->points= MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding");
@@ -1749,6 +1752,7 @@ static void splineik_init_tree_from_pchan(Object *ob, bPoseChannel *pchan_tip)
maxScale = totLength / splineLen;
/* apply scaling correction to all of the temporary points */
// TODO: this is really not adequate enough on really short chains
for (i = 0; i < segcount; i++)
jointPoints[i] *= maxScale;
}
@@ -1820,7 +1824,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* step 1a: get xyz positions for the tail endpoint of the bone */
if ( where_on_path(ikData->tar, tree->points[index], vec, dir, NULL, &rad) ) {
/* convert the position to pose-space, then store it */
Mat4MulVecfl(ob->imat, vec);
mul_m4_v3(ob->imat, vec);
VECCOPY(poseTail, vec);
/* set the new radius */
@@ -1828,28 +1832,21 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
}
/* step 1b: get xyz positions for the head endpoint of the bone */
/* firstly, calculate the position that the path suggests */
if ( where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad) ) {
/* store the position, and convert it to pose space */
Mat4MulVecfl(ob->imat, vec);
mul_m4_v3(ob->imat, vec);
VECCOPY(poseHead, vec);
/* set the new radius (it should be the average value) */
radius = (radius+rad) / 2;
}
if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_ROOT) && (pchan == tree->root))
{
// this is the root bone, and it can be controlled however we like...
// TODO: how do we calculate the offset of the root, if we don't even know the binding?
VECCOPY(poseHead, pchan->pose_head);
}
/* step 2: determine the implied transform from these endpoints
* - splineVec: the vector direction that the spline applies on the bone
* - scaleFac: the factor that the bone length is scaled by to get the desired amount
*/
VecSubf(splineVec, poseTail, poseHead);
scaleFac= VecLength(splineVec) / pchan->bone->length;
sub_v3_v3v3(splineVec, poseTail, poseHead);
scaleFac= len_v3(splineVec) / pchan->bone->length;
/* step 3: compute the shortest rotation needed to map from the bone rotation to the current axis
* - this uses the same method as is used for the Damped Track Constraint (see the code there for details)
@@ -1864,49 +1861,68 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
VECCOPY(rmat[0], pchan->pose_mat[0]);
VECCOPY(rmat[1], pchan->pose_mat[1]);
VECCOPY(rmat[2], pchan->pose_mat[2]);
Mat3Ortho(rmat);
normalize_m3(rmat);
/* also, normalise the orientation imposed by the bone, now that we've extracted the scale factor */
Normalize(splineVec);
normalize_v3(splineVec);
/* calculate smallest axis-angle rotation necessary for getting from the
* current orientation of the bone, to the spline-imposed direction
*/
Crossf(raxis, rmat[1], splineVec);
cross_v3_v3v3(raxis, rmat[1], splineVec);
rangle= Inpf(rmat[1], splineVec);
rangle= dot_v3v3(rmat[1], splineVec);
rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) );
/* construct rotation matrix from the axis-angle rotation found above
* - this call takes care to make sure that the axis provided is a unit vector first
*/
AxisAngleToMat3(raxis, rangle, dmat);
axis_angle_to_mat3( dmat,raxis, rangle);
/* combine these rotations so that the y-axis of the bone is now aligned as the spline dictates,
* while still maintaining roll control from the existing bone animation
*/
Mat3MulMat3(tmat, dmat, rmat); // m1, m3, m2
Mat3Ortho(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */
Mat4CpyMat3(poseMat, tmat);
mul_m3_m3m3(tmat, dmat, rmat); // m1, m3, m2
normalize_m3(tmat); /* attempt to reduce shearing, though I doubt this'll really help too much now... */
copy_m4_m3(poseMat, tmat);
}
/* step 4: set the scaling factors for the axes */
// TODO: include a no-scale option?
{
/* only multiply the y-axis by the scaling factor to get nice volume-preservation */
VecMulf(poseMat[1], scaleFac);
/* set the scaling factors of the x and z axes from the average radius of the curve? */
if (ikData->flag & CONSTRAINT_SPLINEIK_RAD2FAT) {
VecMulf(poseMat[0], radius);
VecMulf(poseMat[2], radius);
mul_v3_fl(poseMat[1], scaleFac);
/* set the scaling factors of the x and z axes from... */
switch (ikData->xzScaleMode) {
case CONSTRAINT_SPLINEIK_XZS_RADIUS:
{
/* radius of curve */
mul_v3_fl(poseMat[0], radius);
mul_v3_fl(poseMat[2], radius);
}
break;
case CONSTRAINT_SPLINEIK_XZS_ORIGINAL:
{
/* original scales get used */
float scale;
/* x-axis scale */
scale= len_v3(pchan->pose_mat[0]);
mul_v3_fl(poseMat[0], scale);
/* z-axis scale */
scale= len_v3(pchan->pose_mat[2]);
mul_v3_fl(poseMat[2], scale);
}
break;
}
}
/* step 5: set the location of the bone in the matrix */
VECCOPY(poseMat[3], pchan->pose_head);
VECCOPY(poseMat[3], poseHead);
/* finally, store the new transform */
Mat4CpyMat4(pchan->pose_mat, poseMat);
copy_m4_m4(pchan->pose_mat, poseMat);
VECCOPY(pchan->pose_head, poseHead);
VECCOPY(pchan->pose_tail, poseTail);
@@ -1958,26 +1974,26 @@ void chan_calc_mat(bPoseChannel *chan)
float tmat[3][3];
/* get scaling matrix */
SizeToMat3(chan->size, smat);
size_to_mat3( smat,chan->size);
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (chan->rotmode > 0) {
/* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
EulOToMat3(chan->eul, chan->rotmode, rmat);
eulO_to_mat3( rmat,chan->eul, chan->rotmode);
}
else if (chan->rotmode == ROT_MODE_AXISANGLE) {
/* axis-angle - not really that great for 3D-changing orientations */
AxisAngleToMat3(chan->rotAxis, chan->rotAngle, rmat);
axis_angle_to_mat3( rmat,chan->rotAxis, chan->rotAngle);
}
else {
/* quats are normalised before use to eliminate scaling issues */
NormalQuat(chan->quat); // TODO: do this with local vars only!
QuatToMat3(chan->quat, rmat);
normalize_qt(chan->quat); // TODO: do this with local vars only!
quat_to_mat3( rmat,chan->quat);
}
/* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
Mat3MulMat3(tmat, rmat, smat);
Mat4CpyMat3(chan->chan_mat, tmat);
mul_m3_m3m3(tmat, rmat, smat);
copy_m4_m3(chan->chan_mat, tmat);
/* prevent action channels breaking chains */
/* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */
@@ -2041,8 +2057,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
float mat4[4][4], mat3[3][3];
curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
Mat4CpyMat4(mat4, pchan->pose_mat);
Mat4MulMat34(pchan->pose_mat, mat3, mat4);
copy_m4_m4(mat4, pchan->pose_mat);
mul_m4_m3m4(pchan->pose_mat, mat3, mat4);
}
}
@@ -2059,8 +2075,8 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
/* make a copy of starting conditions */
VECCOPY(loc, pchan->pose_mat[3]);
Mat4ToEul(pchan->pose_mat, eul);
Mat4ToSize(pchan->pose_mat, size);
mat4_to_eul( eul,pchan->pose_mat);
mat4_to_size( size,pchan->pose_mat);
VECCOPY(eulo, eul);
VECCOPY(sizeo, size);
@@ -2070,14 +2086,14 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs;
nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs;
VecAddf(size, size, nor);
add_v3_v3v3(size, size, nor);
if (sizeo[0] != 0)
VecMulf(pchan->pose_mat[0], size[0] / sizeo[0]);
mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]);
if (sizeo[1] != 0)
VecMulf(pchan->pose_mat[1], size[1] / sizeo[1]);
mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]);
if (sizeo[2] != 0)
VecMulf(pchan->pose_mat[2], size[2] / sizeo[2]);
mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]);
}
if (amod->channels & 2) {
/* for rotation */
@@ -2086,10 +2102,10 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs;
compatible_eul(nor, eulo);
VecAddf(eul, eul, nor);
add_v3_v3v3(eul, eul, nor);
compatible_eul(eul, eulo);
LocEulSizeToMat4(pchan->pose_mat, loc, eul, size);
loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size);
}
if (amod->channels & 1) {
/* for location */
@@ -2097,7 +2113,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha
nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1]+ofs, loc[2], 0, 0) - ofs;
nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2]+ofs, 0, 0) - ofs;
VecAddf(pchan->pose_mat[3], loc, nor);
add_v3_v3v3(pchan->pose_mat[3], loc, nor);
}
}
}
@@ -2132,7 +2148,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
float offs_bone[4][4]; // yoffs(b-1) + root(b) + bonemat(b)
/* bone transform itself */
Mat4CpyMat3(offs_bone, bone->bone_mat);
copy_m4_m3(offs_bone, bone->bone_mat);
/* The bone's root offset (is in the parent's coordinate system) */
VECCOPY(offs_bone[3], bone->head);
@@ -2145,39 +2161,39 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
float tmat[4][4];
/* the rotation of the parent restposition */
Mat4CpyMat4(tmat, parbone->arm_mat);
copy_m4_m4(tmat, parbone->arm_mat);
/* the location of actual parent transform */
VECCOPY(tmat[3], offs_bone[3]);
offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
Mat4MulVecfl(parchan->pose_mat, tmat[3]);
mul_m4_v3(parchan->pose_mat, tmat[3]);
Mat4MulSerie(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
}
else if(bone->flag & BONE_NO_SCALE) {
float orthmat[4][4];
/* get the official transform, but we only use the vector from it (optimize...) */
Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
VECCOPY(vec, pchan->pose_mat[3]);
/* do this again, but with an ortho-parent matrix */
Mat4CpyMat4(orthmat, parchan->pose_mat);
Mat4Ortho(orthmat);
Mat4MulSerie(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
copy_m4_m4(orthmat, parchan->pose_mat);
normalize_m4(orthmat);
mul_serie_m4(pchan->pose_mat, orthmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
/* copy correct transform */
VECCOPY(pchan->pose_mat[3], vec);
}
else
Mat4MulSerie(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
mul_serie_m4(pchan->pose_mat, parchan->pose_mat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL);
}
else {
Mat4MulMat4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
mul_m4_m4m4(pchan->pose_mat, pchan->chan_mat, bone->arm_mat);
/* only rootbones get the cyclic offset (unless user doesn't want that) */
if ((bone->flag & BONE_NO_CYCLICOFFSET) == 0)
VecAddf(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset);
add_v3_v3v3(pchan->pose_mat[3], pchan->pose_mat[3], ob->pose->cyclic_offset);
}
/* do NLA strip modifiers - i.e. curve follow */
@@ -2213,8 +2229,8 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti
VECCOPY(pchan->pose_head, pchan->pose_mat[3]);
/* calculate tail */
VECCOPY(vec, pchan->pose_mat[1]);
VecMulf(vec, bone->length);
VecAddf(pchan->pose_tail, pchan->pose_head, vec);
mul_v3_fl(vec, bone->length);
add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec);
}
/* This only reads anim data from channels, and writes to channels */
@@ -2242,14 +2258,14 @@ void where_is_pose (Scene *scene, Object *ob)
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
bone= pchan->bone;
if(bone) {
Mat4CpyMat4(pchan->pose_mat, bone->arm_mat);
copy_m4_m4(pchan->pose_mat, bone->arm_mat);
VECCOPY(pchan->pose_head, bone->arm_head);
VECCOPY(pchan->pose_tail, bone->arm_tail);
}
}
}
else {
Mat4Invert(ob->imat, ob->obmat); // imat is needed
invert_m4_m4(ob->imat, ob->obmat); // imat is needed
/* 1. clear flags */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
@@ -2287,8 +2303,8 @@ void where_is_pose (Scene *scene, Object *ob)
/* calculating deform matrices */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone) {
Mat4Invert(imat, pchan->bone->arm_mat);
Mat4MulMat4(pchan->chan_mat, imat, pchan->pose_mat);
invert_m4_m4(imat, pchan->bone->arm_mat);
mul_m4_m4m4(pchan->chan_mat, imat, pchan->pose_mat);
}
}
}

View File

@@ -43,7 +43,7 @@
#include "DNA_listBase.h"
#include "BLI_rand.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
@@ -135,10 +135,10 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
/* estimate future location of target */
get_effector_data(eff, &efd, &epoint, 1);
VecMulf(efd.vel, efd.distance / (val->max_speed * bbd->timestep));
VecAddf(efd.loc, efd.loc, efd.vel);
VecSubf(efd.vec_to_point, pa->prev_state.co, efd.loc);
efd.distance = VecLength(efd.vec_to_point);
mul_v3_fl(efd.vel, efd.distance / (val->max_speed * bbd->timestep));
add_v3_v3v3(efd.loc, efd.loc, efd.vel);
sub_v3_v3v3(efd.vec_to_point, pa->prev_state.co, efd.loc);
efd.distance = len_v3(efd.vec_to_point);
}
if(rule->type == eBoidRuleType_Goal && boids->options & BOID_ALLOW_CLIMB && surface!=0.0f) {
@@ -152,17 +152,17 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
priority > 2.0f * gabr->fear_factor) {
/* detach from surface and try to fly away from danger */
VECCOPY(efd.vec_to_point, bpa->gravity);
VecMulf(efd.vec_to_point, -1.0f);
mul_v3_fl(efd.vec_to_point, -1.0f);
}
VECCOPY(bbd->wanted_co, efd.vec_to_point);
VecMulf(bbd->wanted_co, mul);
mul_v3_fl(bbd->wanted_co, mul);
bbd->wanted_speed = val->max_speed * priority;
/* with goals factor is approach velocity factor */
if(rule->type == eBoidRuleType_Goal && boids->landing_smoothness > 0.0f) {
float len2 = 2.0f*VecLength(pa->prev_state.vel);
float len2 = 2.0f*len_v3(pa->prev_state.vel);
surface *= pa->size * boids->height;
@@ -198,12 +198,12 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
float radius = val->personal_space * pa->size, ray_dir[3];
VECCOPY(col.co1, pa->prev_state.co);
VecAddf(col.co2, pa->prev_state.co, pa->prev_state.vel);
VecSubf(ray_dir, col.co2, col.co1);
VecMulf(ray_dir, acbr->look_ahead);
add_v3_v3v3(col.co2, pa->prev_state.co, pa->prev_state.vel);
sub_v3_v3v3(ray_dir, col.co2, col.co1);
mul_v3_fl(ray_dir, acbr->look_ahead);
col.t = 0.0f;
hit.index = -1;
hit.dist = col.ray_len = VecLength(ray_dir);
hit.dist = col.ray_len = len_v3(ray_dir);
/* find out closest deflector object */
for(coll = bbd->sim->colliders->first; coll; coll=coll->next) {
@@ -224,9 +224,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
VECCOPY(bbd->wanted_co, col.nor);
VecMulf(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size);
mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size);
bbd->wanted_speed = sqrt(t) * VecLength(pa->prev_state.vel);
bbd->wanted_speed = sqrt(t) * len_v3(pa->prev_state.vel);
return 1;
}
@@ -235,39 +235,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
//check boids in own system
if(acbr->options & BRULE_ACOLL_WITH_BOIDS)
{
neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
neighbors = BLI_kdtree_range_search(bbd->sim->psys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
if(neighbors > 1) for(n=1; n<neighbors; n++) {
VECCOPY(co1, pa->prev_state.co);
VECCOPY(vel1, pa->prev_state.vel);
VECCOPY(co2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.co);
VECCOPY(vel2, (bbd->sim->psys->particles + ptn[n].index)->prev_state.vel);
VecSubf(loc, co1, co2);
sub_v3_v3v3(loc, co1, co2);
VecSubf(vec, vel1, vel2);
sub_v3_v3v3(vec, vel1, vel2);
inp = Inpf(vec,vec);
inp = dot_v3v3(vec,vec);
/* velocities not parallel */
if(inp != 0.0f) {
t = -Inpf(loc, vec)/inp;
t = -dot_v3v3(loc, vec)/inp;
/* cpa is not too far in the future so investigate further */
if(t > 0.0f && t < t_min) {
VECADDFAC(co1, co1, vel1, t);
VECADDFAC(co2, co2, vel2, t);
VecSubf(vec, co2, co1);
sub_v3_v3v3(vec, co2, co1);
len = Normalize(vec);
len = normalize_v3(vec);
/* distance of cpa is close enough */
if(len < 2.0f * val->personal_space * pa->size) {
t_min = t;
VecMulf(vec, VecLength(vel1));
VecMulf(vec, (2.0f - t)/2.0f);
VecSubf(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = VecLength(bbd->wanted_co);
mul_v3_fl(vec, len_v3(vel1));
mul_v3_fl(vec, (2.0f - t)/2.0f);
sub_v3_v3v3(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
}
@@ -281,39 +281,39 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
ParticleSystem *epsys = psys_get_target_system(bbd->sim->ob, pt);
if(epsys) {
neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * VecLength(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
neighbors = BLI_kdtree_range_search(epsys->tree, acbr->look_ahead * len_v3(pa->prev_state.vel), pa->prev_state.co, pa->prev_state.ave, &ptn);
if(neighbors > 0) for(n=0; n<neighbors; n++) {
VECCOPY(co1, pa->prev_state.co);
VECCOPY(vel1, pa->prev_state.vel);
VECCOPY(co2, (epsys->particles + ptn[n].index)->prev_state.co);
VECCOPY(vel2, (epsys->particles + ptn[n].index)->prev_state.vel);
VecSubf(loc, co1, co2);
sub_v3_v3v3(loc, co1, co2);
VecSubf(vec, vel1, vel2);
sub_v3_v3v3(vec, vel1, vel2);
inp = Inpf(vec,vec);
inp = dot_v3v3(vec,vec);
/* velocities not parallel */
if(inp != 0.0f) {
t = -Inpf(loc, vec)/inp;
t = -dot_v3v3(loc, vec)/inp;
/* cpa is not too far in the future so investigate further */
if(t > 0.0f && t < t_min) {
VECADDFAC(co1, co1, vel1, t);
VECADDFAC(co2, co2, vel2, t);
VecSubf(vec, co2, co1);
sub_v3_v3v3(vec, co2, co1);
len = Normalize(vec);
len = normalize_v3(vec);
/* distance of cpa is close enough */
if(len < 2.0f * val->personal_space * pa->size) {
t_min = t;
VecMulf(vec, VecLength(vel1));
VecMulf(vec, (2.0f - t)/2.0f);
VecSubf(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = VecLength(bbd->wanted_co);
mul_v3_fl(vec, len_v3(vel1));
mul_v3_fl(vec, (2.0f - t)/2.0f);
sub_v3_v3v3(bbd->wanted_co, vel1, vec);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
}
@@ -340,9 +340,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa
int ret = 0;
if(neighbors > 1 && ptn[1].dist!=0.0f) {
VecSubf(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co);
VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
sub_v3_v3v3(vec, pa->prev_state.co, bbd->sim->psys->particles[ptn[1].index].state.co);
mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[1].dist) / ptn[1].dist);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
bbd->wanted_speed = val->max_speed;
len = ptn[1].dist;
ret = 1;
@@ -357,9 +357,9 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa
neighbors = BLI_kdtree_range_search(epsys->tree, 2.0f * val->personal_space * pa->size, pa->prev_state.co, NULL, &ptn);
if(neighbors > 0 && ptn[0].dist < len) {
VecSubf(vec, pa->prev_state.co, ptn[0].co);
VecMulf(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
sub_v3_v3v3(vec, pa->prev_state.co, ptn[0].co);
mul_v3_fl(vec, (2.0f * val->personal_space * pa->size - ptn[0].dist) / ptn[1].dist);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
bbd->wanted_speed = val->max_speed;
len = ptn[0].dist;
ret = 1;
@@ -380,19 +380,19 @@ static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
if(neighbors > 1) {
for(n=1; n<neighbors; n++) {
VecAddf(loc, loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co);
VecAddf(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel);
add_v3_v3v3(loc, loc, bbd->sim->psys->particles[ptn[n].index].prev_state.co);
add_v3_v3v3(vec, vec, bbd->sim->psys->particles[ptn[n].index].prev_state.vel);
}
VecMulf(loc, 1.0f/((float)neighbors - 1.0f));
VecMulf(vec, 1.0f/((float)neighbors - 1.0f));
mul_v3_fl(loc, 1.0f/((float)neighbors - 1.0f));
mul_v3_fl(vec, 1.0f/((float)neighbors - 1.0f));
VecSubf(loc, loc, pa->prev_state.co);
VecSubf(vec, vec, pa->prev_state.vel);
sub_v3_v3v3(loc, loc, pa->prev_state.co);
sub_v3_v3v3(vec, vec, pa->prev_state.vel);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
VecAddf(bbd->wanted_co, bbd->wanted_co, loc);
bbd->wanted_speed = VecLength(bbd->wanted_co);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, loc);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
@@ -410,16 +410,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
float vec2[3], t;
/* first check we're not blocking the leader*/
VecSubf(vec, flbr->loc, flbr->oloc);
VecMulf(vec, 1.0f/bbd->timestep);
sub_v3_v3v3(vec, flbr->loc, flbr->oloc);
mul_v3_fl(vec, 1.0f/bbd->timestep);
VecSubf(loc, pa->prev_state.co, flbr->oloc);
sub_v3_v3v3(loc, pa->prev_state.co, flbr->oloc);
mul = Inpf(vec, vec);
mul = dot_v3v3(vec, vec);
/* leader is not moving */
if(mul < 0.01) {
len = VecLength(loc);
len = len_v3(loc);
/* too close to leader */
if(len < 2.0f * val->personal_space * pa->size) {
VECCOPY(bbd->wanted_co, loc);
@@ -428,16 +428,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
}
else {
t = Inpf(loc, vec)/mul;
t = dot_v3v3(loc, vec)/mul;
/* possible blocking of leader in near future */
if(t > 0.0f && t < 3.0f) {
VECCOPY(vec2, vec);
VecMulf(vec2, t);
mul_v3_fl(vec2, t);
VecSubf(vec2, loc, vec2);
sub_v3_v3v3(vec2, loc, vec2);
len = VecLength(vec2);
len = len_v3(vec2);
if(len < 2.0f * val->personal_space * pa->size) {
VECCOPY(bbd->wanted_co, vec2);
@@ -454,15 +454,15 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
else {
VECCOPY(loc, flbr->oloc);
VecSubf(vec, flbr->loc, flbr->oloc);
VecMulf(vec, 1.0/bbd->timestep);
sub_v3_v3v3(vec, flbr->loc, flbr->oloc);
mul_v3_fl(vec, 1.0/bbd->timestep);
}
/* fac is seconds behind leader */
VECADDFAC(loc, loc, vec, -flbr->distance);
VecSubf(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = VecLength(bbd->wanted_co);
sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
@@ -473,13 +473,13 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
for(i = 0; i< bbd->sim->psys->totpart; i+=n){
VECCOPY(vec, bbd->sim->psys->particles[i].prev_state.vel);
VecSubf(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co);
sub_v3_v3v3(loc, pa->prev_state.co, bbd->sim->psys->particles[i].prev_state.co);
mul = Inpf(vec, vec);
mul = dot_v3v3(vec, vec);
/* leader is not moving */
if(mul < 0.01) {
len = VecLength(loc);
len = len_v3(loc);
/* too close to leader */
if(len < 2.0f * val->personal_space * pa->size) {
VECCOPY(bbd->wanted_co, loc);
@@ -488,16 +488,16 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
}
else {
t = Inpf(loc, vec)/mul;
t = dot_v3v3(loc, vec)/mul;
/* possible blocking of leader in near future */
if(t > 0.0f && t < t_min) {
VECCOPY(vec2, vec);
VecMulf(vec2, t);
mul_v3_fl(vec2, t);
VecSubf(vec2, loc, vec2);
sub_v3_v3v3(vec2, loc, vec2);
len = VecLength(vec2);
len = len_v3(vec2);
if(len < 2.0f * val->personal_space * pa->size) {
t_min = t;
@@ -524,8 +524,8 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
/* fac is seconds behind leader */
VECADDFAC(loc, loc, vec, -flbr->distance);
VecSubf(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = VecLength(bbd->wanted_co);
sub_v3_v3v3(bbd->wanted_co, loc, pa->prev_state.co);
bbd->wanted_speed = len_v3(bbd->wanted_co);
ret = 1;
}
@@ -544,30 +544,30 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
bpa->wander[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
Normalize(bpa->wander);
normalize_v3(bpa->wander);
VECCOPY(vec, bpa->wander);
QuatMulVecf(pa->prev_state.rot, vec);
mul_qt_v3(pa->prev_state.rot, vec);
VECCOPY(bbd->wanted_co, pa->prev_state.ave);
VecMulf(bbd->wanted_co, 1.1f);
mul_v3_fl(bbd->wanted_co, 1.1f);
VecAddf(bbd->wanted_co, bbd->wanted_co, vec);
add_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
/* leveling */
if(asbr->level > 0.0f) {
Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
VecMulf(vec, asbr->level);
VecSubf(bbd->wanted_co, bbd->wanted_co, vec);
project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
mul_v3_fl(vec, asbr->level);
sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
}
}
else {
VECCOPY(bbd->wanted_co, pa->prev_state.ave);
/* may happen at birth */
if(Inp2f(bbd->wanted_co,bbd->wanted_co)==0.0f) {
if(dot_v2v2(bbd->wanted_co,bbd->wanted_co)==0.0f) {
bbd->wanted_co[0] = 2.0f*(0.5f - BLI_frand());
bbd->wanted_co[1] = 2.0f*(0.5f - BLI_frand());
bbd->wanted_co[2] = 2.0f*(0.5f - BLI_frand());
@@ -575,9 +575,9 @@ static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
/* leveling */
if(asbr->level > 0.0f) {
Projf(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
VecMulf(vec, asbr->level);
VecSubf(bbd->wanted_co, bbd->wanted_co, vec);
project_v3_v3v3(vec, bbd->wanted_co, bbd->sim->psys->part->acc);
mul_v3_fl(vec, asbr->level);
sub_v3_v3v3(bbd->wanted_co, bbd->wanted_co, vec);
}
}
@@ -641,20 +641,20 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
}
/* decide action if enemy presence found */
if(e_strength > 0.0f) {
VecSubf(bbd->wanted_co, closest_enemy, pa->prev_state.co);
sub_v3_v3v3(bbd->wanted_co, closest_enemy, pa->prev_state.co);
/* attack if in range */
if(closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) {
float damage = BLI_frand();
float enemy_dir[3] = {bbd->wanted_co[0],bbd->wanted_co[1],bbd->wanted_co[2]};
Normalize(enemy_dir);
normalize_v3(enemy_dir);
/* fight mode */
bbd->wanted_speed = 0.0f;
/* must face enemy to fight */
if(Inpf(pa->prev_state.ave, enemy_dir)>0.5f) {
if(dot_v3v3(pa->prev_state.ave, enemy_dir)>0.5f) {
bpa = enemy_pa->boid;
bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy);
}
@@ -669,7 +669,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
/* decide to flee */
if(closest_dist < fbr->flee_distance * fbr->distance) {
VecMulf(bbd->wanted_co, -1.0f);
mul_v3_fl(bbd->wanted_co, -1.0f);
bbd->wanted_speed = val->max_speed;
}
else { /* wait for better odds */
@@ -735,7 +735,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
/* take surface velocity into account */
closest_point_on_surface(surmd, pa->state.co, x, NULL, v);
VecAddf(x, x, v);
add_v3_v3v3(x, x, v);
/* get actual position on surface */
closest_point_on_surface(surmd, x, ground_co, ground_nor, NULL);
@@ -754,12 +754,12 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
VECCOPY(col.co1, pa->state.co);
VECCOPY(col.co2, pa->state.co);
VecAddf(col.co1, col.co1, zvec);
VecSubf(col.co2, col.co2, zvec);
VecSubf(ray_dir, col.co2, col.co1);
add_v3_v3v3(col.co1, col.co1, zvec);
sub_v3_v3v3(col.co2, col.co2, zvec);
sub_v3_v3v3(ray_dir, col.co2, col.co1);
col.t = 0.0f;
hit.index = -1;
hit.dist = col.ray_len = VecLength(ray_dir);
hit.dist = col.ray_len = len_v3(ray_dir);
/* find out upmost deflector object */
for(coll = bbd->sim->colliders->first; coll; coll = coll->next){
@@ -772,9 +772,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
/* then use that object */
if(hit.index>=0) {
t = hit.dist/col.ray_len;
VecLerpf(ground_co, col.co1, col.co2, t);
interp_v3_v3v3(ground_co, col.co1, col.co2, t);
VECCOPY(ground_nor, col.nor);
Normalize(ground_nor);
normalize_v3(ground_nor);
return col.hit_ob;
}
else {
@@ -829,23 +829,23 @@ static void boid_climb(BoidSettings *boids, ParticleData *pa, float *surface_co,
/* gather apparent gravity */
VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
/* raise boid it's size from surface */
VecMulf(nor, pa->size * boids->height);
VecAddf(pa->state.co, surface_co, nor);
mul_v3_fl(nor, pa->size * boids->height);
add_v3_v3v3(pa->state.co, surface_co, nor);
/* remove normal component from velocity */
Projf(vel, pa->state.vel, surface_nor);
VecSubf(pa->state.vel, pa->state.vel, vel);
project_v3_v3v3(vel, pa->state.vel, surface_nor);
sub_v3_v3v3(pa->state.vel, pa->state.vel, vel);
}
static float boid_goal_signed_dist(float *boid_co, float *goal_co, float *goal_nor)
{
float vec[3];
VecSubf(vec, boid_co, goal_co);
sub_v3_v3v3(vec, boid_co, goal_co);
return Inpf(vec, goal_nor);
return dot_v3v3(vec, goal_nor);
}
/* wanted_co is relative to boid location */
static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness)
@@ -859,7 +859,7 @@ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val,
if(boid_rules[rule->type](rule, bbd, val, pa)==0)
return 0;
if(fuzziness < 0.0f || VecLenCompare(bbd->wanted_co, pa->prev_state.vel, fuzziness * VecLength(pa->prev_state.vel))==0)
if(fuzziness < 0.0f || compare_len_v3v3(bbd->wanted_co, pa->prev_state.vel, fuzziness * len_v3(pa->prev_state.vel))==0)
return 1;
else
return 0;
@@ -943,7 +943,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
int n = 0;
for(rule = state->rules.first; rule; rule=rule->next) {
if(apply_boid_rule(bbd, rule, &val, pa, -1.0f)) {
VecAddf(wanted_co, wanted_co, bbd->wanted_co);
add_v3_v3v3(wanted_co, wanted_co, bbd->wanted_co);
wanted_speed += bbd->wanted_speed;
n++;
bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f;
@@ -951,7 +951,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
}
if(n > 1) {
VecMulf(wanted_co, 1.0f/(float)n);
mul_v3_fl(wanted_co, 1.0f/(float)n);
wanted_speed /= (float)n;
}
@@ -971,12 +971,12 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
float cvel[3], dir[3];
VECCOPY(dir, pa->prev_state.ave);
Normalize2(dir);
normalize_v2(dir);
VECCOPY(cvel, bbd->wanted_co);
Normalize2(cvel);
normalize_v2(cvel);
if(Inp2f(cvel, dir) > 0.95 / mul)
if(dot_v2v2(cvel, dir) > 0.95 / mul)
bpa->data.mode = eBoidMode_Liftoff;
}
else if(val.jump_speed > 0.0f) {
@@ -990,20 +990,20 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
float len;
VECCOPY(dir, pa->prev_state.ave);
Normalize2(dir);
normalize_v2(dir);
VECCOPY(cvel, bbd->wanted_co);
Normalize2(cvel);
normalize_v2(cvel);
len = Vec2Length(pa->prev_state.vel);
len = len_v2(pa->prev_state.vel);
/* first of all, are we going in a suitable direction? */
/* or at a suitably slow speed */
if(Inp2f(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
if(dot_v2v2(cvel, dir) > 0.95f / mul || len <= state->rule_fuzziness) {
/* try to reach goal at highest point of the parabolic path */
cur_v = Vec2Length(pa->prev_state.vel);
cur_v = len_v2(pa->prev_state.vel);
z_v = sasqrt(-2.0f * bbd->part->acc[2] * bbd->wanted_co[2]);
ground_v = Vec2Length(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]);
ground_v = len_v2(bbd->wanted_co)*sasqrt(-0.5f * bbd->part->acc[2] / bbd->wanted_co[2]);
len = sasqrt((ground_v-cur_v)*(ground_v-cur_v) + z_v*z_v);
@@ -1014,11 +1014,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
VECCOPY(jump_v, dir);
jump_v[2] = z_v;
VecMulf(jump_v, ground_v);
mul_v3_fl(jump_v, ground_v);
Normalize(jump_v);
VecMulf(jump_v, len);
Vec2Addf(jump_v, jump_v, pa->prev_state.vel);
normalize_v3(jump_v);
mul_v3_fl(jump_v, len);
add_v2_v2v2(jump_v, jump_v, pa->prev_state.vel);
}
}
}
@@ -1103,7 +1103,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
VECCOPY(old_dir, pa->prev_state.ave);
VECCOPY(wanted_dir, bbd->wanted_co);
new_speed = Normalize(wanted_dir);
new_speed = normalize_v3(wanted_dir);
/* first check if we have valid direction we want to go towards */
if(new_speed == 0.0f) {
@@ -1111,39 +1111,39 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
}
else {
float old_dir2[2], wanted_dir2[2], nor[3], angle;
Vec2Copyf(old_dir2, old_dir);
Normalize2(old_dir2);
Vec2Copyf(wanted_dir2, wanted_dir);
Normalize2(wanted_dir2);
copy_v2_v2(old_dir2, old_dir);
normalize_v2(old_dir2);
copy_v2_v2(wanted_dir2, wanted_dir);
normalize_v2(wanted_dir2);
/* choose random direction to turn if wanted velocity */
/* is directly behind regardless of z-coordinate */
if(Inp2f(old_dir2, wanted_dir2) < -0.99f) {
if(dot_v2v2(old_dir2, wanted_dir2) < -0.99f) {
wanted_dir[0] = 2.0f*(0.5f - BLI_frand());
wanted_dir[1] = 2.0f*(0.5f - BLI_frand());
wanted_dir[2] = 2.0f*(0.5f - BLI_frand());
Normalize(wanted_dir);
normalize_v3(wanted_dir);
}
/* constrain direction with maximum angular velocity */
angle = saacos(Inpf(old_dir, wanted_dir));
angle = saacos(dot_v3v3(old_dir, wanted_dir));
angle = MIN2(angle, val.max_ave);
Crossf(nor, old_dir, wanted_dir);
VecRotToQuat(nor, angle, q);
cross_v3_v3v3(nor, old_dir, wanted_dir);
axis_angle_to_quat( q,nor, angle);
VECCOPY(new_dir, old_dir);
QuatMulVecf(q, new_dir);
Normalize(new_dir);
mul_qt_v3(q, new_dir);
normalize_v3(new_dir);
/* save direction in case resulting velocity too small */
VecRotToQuat(nor, angle*dtime, q);
axis_angle_to_quat( q,nor, angle*dtime);
VECCOPY(pa->state.ave, old_dir);
QuatMulVecf(q, pa->state.ave);
Normalize(pa->state.ave);
mul_qt_v3(q, pa->state.ave);
normalize_v3(pa->state.ave);
}
/* constrain speed with maximum acceleration */
old_speed = VecLength(pa->prev_state.vel);
old_speed = len_v3(pa->prev_state.vel);
if(bbd->wanted_speed < old_speed)
new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc);
@@ -1152,11 +1152,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* combine direction and speed */
VECCOPY(new_vel, new_dir);
VecMulf(new_vel, new_speed);
mul_v3_fl(new_vel, new_speed);
/* maintain minimum flying velocity if not landing */
if(level >= landing_level) {
float len2 = Inp2f(new_vel,new_vel);
float len2 = dot_v2v2(new_vel,new_vel);
float root;
len2 = MAX2(len2, val.min_speed*val.min_speed);
@@ -1164,20 +1164,20 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
new_vel[2] = new_vel[2] < 0.0f ? -root : root;
Normalize2(new_vel);
Vec2Mulf(new_vel, sasqrt(len2));
normalize_v2(new_vel);
mul_v2_fl(new_vel, sasqrt(len2));
}
/* finally constrain speed to max speed */
new_speed = Normalize(new_vel);
VecMulf(new_vel, MIN2(new_speed, val.max_speed));
new_speed = normalize_v3(new_vel);
mul_v3_fl(new_vel, MIN2(new_speed, val.max_speed));
/* get acceleration from difference of velocities */
VecSubf(acc, new_vel, pa->prev_state.vel);
sub_v3_v3v3(acc, new_vel, pa->prev_state.vel);
/* break acceleration to components */
Projf(tan_acc, acc, pa->prev_state.ave);
VecSubf(nor_acc, acc, tan_acc);
project_v3_v3v3(tan_acc, acc, pa->prev_state.ave);
sub_v3_v3v3(nor_acc, acc, tan_acc);
}
/* account for effectors */
@@ -1185,32 +1185,32 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
pdDoEffectors(bbd->sim->psys->effectors, bbd->sim->colliders, bbd->part->effector_weights, &epoint, force, NULL);
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
float length = Normalize(force);
float length = normalize_v3(force);
length = MAX2(0.0f, length - boids->land_stick_force);
VecMulf(force, length);
mul_v3_fl(force, length);
}
VecAddf(acc, acc, force);
add_v3_v3v3(acc, acc, force);
/* store smoothed acceleration for nice banking etc. */
VECADDFAC(bpa->data.acc, bpa->data.acc, acc, dtime);
VecMulf(bpa->data.acc, 1.0f / (1.0f + dtime));
mul_v3_fl(bpa->data.acc, 1.0f / (1.0f + dtime));
/* integrate new location & velocity */
/* by regarding the acceleration as a force at this stage we*/
/* can get better control allthough it's a bit unphysical */
VecMulf(acc, 1.0f/pa_mass);
mul_v3_fl(acc, 1.0f/pa_mass);
VECCOPY(dvec, acc);
VecMulf(dvec, dtime*dtime*0.5f);
mul_v3_fl(dvec, dtime*dtime*0.5f);
VECCOPY(bvec, pa->prev_state.vel);
VecMulf(bvec, dtime);
VecAddf(dvec, dvec, bvec);
VecAddf(pa->state.co, pa->state.co, dvec);
mul_v3_fl(bvec, dtime);
add_v3_v3v3(dvec, dvec, bvec);
add_v3_v3v3(pa->state.co, pa->state.co, dvec);
VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime);
@@ -1224,9 +1224,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f};
/* don't take forward acceleration into account (better banking) */
if(Inpf(bpa->data.acc, pa->state.vel) > 0.0f) {
Projf(dvec, bpa->data.acc, pa->state.vel);
VecSubf(dvec, bpa->data.acc, dvec);
if(dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) {
project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel);
sub_v3_v3v3(dvec, bpa->data.acc, dvec);
}
else {
VECCOPY(dvec, bpa->data.acc);
@@ -1234,7 +1234,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* gather apparent gravity */
VECADDFAC(bpa->gravity, grav, dvec, -boids->banking);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
/* stick boid on goal when close enough */
if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
@@ -1257,7 +1257,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* gather apparent gravity */
VECADDFAC(bpa->gravity, bpa->gravity, grav, dtime);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
if(boids->options & BOID_ALLOW_LAND) {
/* stick boid on goal when close enough */
@@ -1289,15 +1289,15 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
///* gather apparent gravity to r_ve */
//VECADDFAC(pa->r_ve, pa->r_ve, ground_nor, -1.0);
//Normalize(pa->r_ve);
//normalize_v3(pa->r_ve);
///* raise boid it's size from surface */
//VecMulf(nor, pa->size * boids->height);
//VecAddf(pa->state.co, ground_co, nor);
//mul_v3_fl(nor, pa->size * boids->height);
//add_v3_v3v3(pa->state.co, ground_co, nor);
///* remove normal component from velocity */
//Projf(v, pa->state.vel, ground_nor);
//VecSubf(pa->state.vel, pa->state.vel, v);
//project_v3_v3v3(v, pa->state.vel, ground_nor);
//sub_v3_v3v3(pa->state.vel, pa->state.vel, v);
break;
}
case eBoidMode_OnLand:
@@ -1323,19 +1323,19 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* Don't take gravity's strength in to account, */
/* otherwise amount of banking is hard to control. */
VECCOPY(grav, ground_nor);
VecMulf(grav, -1.0f);
mul_v3_fl(grav, -1.0f);
Projf(dvec, bpa->data.acc, pa->state.vel);
VecSubf(dvec, bpa->data.acc, dvec);
project_v3_v3v3(dvec, bpa->data.acc, pa->state.vel);
sub_v3_v3v3(dvec, bpa->data.acc, dvec);
/* gather apparent gravity */
VECADDFAC(bpa->gravity, grav, dvec, -boids->banking);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
}
else {
/* gather negative surface normal */
VECADDFAC(bpa->gravity, bpa->gravity, ground_nor, -1.0f);
Normalize(bpa->gravity);
normalize_v3(bpa->gravity);
}
break;
}
@@ -1343,36 +1343,36 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* save direction to state.ave unless the boid is falling */
/* (boids can't effect their direction when falling) */
if(bpa->data.mode!=eBoidMode_Falling && VecLength(pa->state.vel) > 0.1*pa->size) {
if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) {
VECCOPY(pa->state.ave, pa->state.vel);
Normalize(pa->state.ave);
normalize_v3(pa->state.ave);
}
/* apply damping */
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
VecMulf(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac);
mul_v3_fl(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac);
/* calculate rotation matrix based on forward & down vectors */
if(bpa->data.mode == eBoidMode_InAir) {
VECCOPY(mat[0], pa->state.ave);
Projf(dvec, bpa->gravity, pa->state.ave);
VecSubf(mat[2], bpa->gravity, dvec);
Normalize(mat[2]);
project_v3_v3v3(dvec, bpa->gravity, pa->state.ave);
sub_v3_v3v3(mat[2], bpa->gravity, dvec);
normalize_v3(mat[2]);
}
else {
Projf(dvec, pa->state.ave, bpa->gravity);
VecSubf(mat[0], pa->state.ave, dvec);
Normalize(mat[0]);
project_v3_v3v3(dvec, pa->state.ave, bpa->gravity);
sub_v3_v3v3(mat[0], pa->state.ave, dvec);
normalize_v3(mat[0]);
VECCOPY(mat[2], bpa->gravity);
}
VecMulf(mat[2], -1.0f);
Crossf(mat[1], mat[2], mat[0]);
mul_v3_fl(mat[2], -1.0f);
cross_v3_v3v3(mat[1], mat[2], mat[0]);
/* apply rotation */
Mat3ToQuat_is_ok(mat, q);
QuatCopy(pa->state.rot, q);
mat3_to_quat_is_ok( q,mat);
copy_qt_qt(pa->state.rot, q);
}
BoidRule *boid_new_rule(int type)

View File

@@ -33,7 +33,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
@@ -104,7 +104,7 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert)
float global_pos[3];
/* boolean happens in global space, transform both with obmat */
VecMat4MulVecfl(
mul_v3_m4v3(
global_pos,
iterator->ob->obmat,
verts[iterator->pos].co
@@ -327,11 +327,11 @@ static void InterpCSGFace(
for (j = 0; j < nr; j++) {
// get coordinate into the space of the original mesh
if (mapmat)
VecMat4MulVecfl(obco, mapmat, co[j]);
mul_v3_m4v3(obco, mapmat, co[j]);
else
VecCopyf(obco, co[j]);
copy_v3_v3(obco, co[j]);
InterpWeightsQ3Dfl(orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco, w[j]);
interp_weights_face_v3( w[j],orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco);
}
CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index);
@@ -375,7 +375,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
// we have to map the vertex coordinates back in the coordinate frame
// of the resulting object, since it was computed in world space
VecMat4MulVecfl(mvert->co, parinv, csgvert.position);
mul_v3_m4v3(mvert->co, parinv, csgvert.position);
}
// a hash table to remap materials to indices
@@ -478,9 +478,9 @@ DerivedMesh *NewBooleanDerivedMesh_intern(
// we map the final object back into ob's local coordinate space. For this
// we need to compute the inverse transform from global to ob (inv_mat),
// and the transform from ob to ob_select for use in interpolation (map_mat)
Mat4Invert(inv_mat, ob->obmat);
Mat4MulMat4(map_mat, ob_select->obmat, inv_mat);
Mat4Invert(inv_mat, ob_select->obmat);
invert_m4_m4(inv_mat, ob->obmat);
mul_m4_m4m4(map_mat, ob_select->obmat, inv_mat);
invert_m4_m4(inv_mat, ob_select->obmat);
{
// interface with the boolean module:
@@ -526,8 +526,8 @@ DerivedMesh *NewBooleanDerivedMesh_intern(
CSG_FreeVertexDescriptor(&vd_o);
CSG_FreeFaceDescriptor(&fd_o);
}
// else
// XXX error("Unknown internal error in boolean");
else
printf("Unknown internal error in boolean");
CSG_FreeBooleanOperation(bool_op);

View File

@@ -47,7 +47,7 @@
#include "BKE_library.h"
#include "BKE_material.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
/**
* Implementation of boolean ops mesh interface.
@@ -151,7 +151,7 @@ CSG_AddMeshToBlender(
if (mesh == NULL) return 0;
if (mesh->base == NULL) return 0;
Mat4Invert(inv_mat,mesh->base->object->obmat);
invert_m4_m4(inv_mat,mesh->base->object->obmat);
// Create a new blender mesh object - using 'base' as
// a template for the new object.

View File

@@ -42,7 +42,7 @@
#include "RNA_access.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_rand.h"
@@ -846,8 +846,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
/* setup starting time, direction vector and accumulated time */
starttime= painter->accumtime;
Vec2Subf(dmousepos, pos, painter->lastmousepos);
len= Normalize2(dmousepos);
sub_v2_v2v2(dmousepos, pos, painter->lastmousepos);
len= normalize_v2(dmousepos);
painter->accumtime += curtime - painter->lasttime;
/* do paint op over unpainted time distance */
@@ -881,8 +881,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
/* setup starting distance, direction vector and accumulated distance */
startdistance= painter->accumdistance;
Vec2Subf(dmousepos, pos, painter->lastmousepos);
len= Normalize2(dmousepos);
sub_v2_v2v2(dmousepos, pos, painter->lastmousepos);
len= normalize_v2(dmousepos);
painter->accumdistance += len;
/* do paint op over unpainted distance */

View File

@@ -45,7 +45,7 @@
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_linklist.h"
#include "MEM_guardedalloc.h"
@@ -55,7 +55,7 @@ static float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, con
{
float dist;
if(RayIntersectsTriangle((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL))
if(isect_ray_tri_v3((float*)ray->origin, (float*)ray->direction, (float*)v0, (float*)v1, (float*)v2, &dist, NULL))
return dist;
return FLT_MAX;
@@ -68,10 +68,10 @@ static float sphereray_tri_intersection(const BVHTreeRay *ray, float radius, con
float p1[3];
float plane_normal[3], hit_point[3];
CalcNormFloat((float*)v0, (float*)v1, (float*)v2, plane_normal);
normal_tri_v3( plane_normal,(float*)v0, (float*)v1, (float*)v2);
VECADDFAC( p1, ray->origin, ray->direction, m_dist);
if(SweepingSphereIntersectsTriangleUV((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point))
if(isect_sweeping_sphere_tri_v3((float*)ray->origin, p1, radius, (float*)v0, (float*)v1, (float*)v2, &idist, hit_point))
{
return idist * m_dist;
}
@@ -384,9 +384,9 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const
float w[3], x[3], y[3], z[3];
VECCOPY(w, v0);
VECCOPY(x, e0);
VecMulf(x, S);
mul_v3_fl(x, S);
VECCOPY(y, e1);
VecMulf(y, T);
mul_v3_fl(y, T);
VECADD(z, w, x);
VECADD(z, z, y);
//VECSUB(d, p, z);
@@ -430,7 +430,7 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float *co,
nearest->index = index;
nearest->dist = dist;
VECCOPY(nearest->co, nearest_tmp);
CalcNormFloat(t0, t1, t2, nearest->no);
normal_tri_v3( nearest->no,t0, t1, t2);
}
t1 = t2;
@@ -469,7 +469,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r
hit->dist = dist;
VECADDFAC(hit->co, ray->origin, ray->direction, dist);
CalcNormFloat(t0, t1, t2, hit->no);
normal_tri_v3( hit->no,t0, t1, t2);
}
t1 = t2;
@@ -492,16 +492,17 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co,
t0 = vert[ edge->v1 ].co;
t1 = vert[ edge->v2 ].co;
PclosestVL3Dfl(nearest_tmp, co, t0, t1);
dist = VecLenf(nearest_tmp, co);
// NOTE: casts to "float*" here are due to co being "const float*"
closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1);
dist = len_v3v3(nearest_tmp, (float*)co);
if(dist < nearest->dist)
{
nearest->index = index;
nearest->dist = dist;
VECCOPY(nearest->co, nearest_tmp);
VecSubf(nearest->no, t0, t1);
Normalize(nearest->no);
sub_v3_v3v3(nearest->no, t0, t1);
normalize_v3(nearest->no);
}
}

View File

@@ -45,7 +45,7 @@
#include "BKE_multires.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_editVert.h"
@@ -440,7 +440,7 @@ int planes_contain_AABB(PBVHNode *node, void *data)
}
}
if(Inpf(planes[i], vmin) + planes[i][3] > 0)
if(dot_v3v3(planes[i], vmin) + planes[i][3] > 0)
return 0;
}
@@ -523,12 +523,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
/* TODO make this better (cache facenormals as layer?) */
float nor[3];
if(mface->v4) {
CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co,
mvert[mface->v3].co, mvert[mface->v4].co,
nor);
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
} else {
CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co,
mvert[mface->v3].co, nor);
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
}
glNormal3fv(nor);
}
@@ -697,12 +694,9 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
else {
float nor[3];
if(mf->v4) {
CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, mv[mf->v4].co,
nor);
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
} else {
CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, nor);
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
}
glNormal3fv(nor);
}
@@ -872,12 +866,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
else {
float nor[3];
if(mf->v4) {
CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, mv[mf->v4].co,
nor);
normal_quad_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
} else {
CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, nor);
normal_tri_v3( nor,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
}
glNormal3fv(nor);
}
@@ -1047,12 +1038,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
/* TODO ideally a normal layer should always be available */
float nor[3];
if(mface->v4) {
CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co,
mvert[mface->v3].co, mvert[mface->v4].co,
nor);
normal_quad_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co, mvert[mface->v4].co);
} else {
CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co,
mvert[mface->v3].co, nor);
normal_tri_v3( nor,mvert[mface->v1].co, mvert[mface->v2].co, mvert[mface->v3].co);
}
glNormal3fv(nor);
}
@@ -1389,18 +1377,16 @@ static void cdDM_foreachMappedFaceCenter(
orig = i;
VECCOPY(cent, mv[mf->v1].co);
VecAddf(cent, cent, mv[mf->v2].co);
VecAddf(cent, cent, mv[mf->v3].co);
add_v3_v3v3(cent, cent, mv[mf->v2].co);
add_v3_v3v3(cent, cent, mv[mf->v3].co);
if (mf->v4) {
CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, mv[mf->v4].co, no);
VecAddf(cent, cent, mv[mf->v4].co);
VecMulf(cent, 0.25f);
normal_quad_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
add_v3_v3v3(cent, cent, mv[mf->v4].co);
mul_v3_fl(cent, 0.25f);
} else {
CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, no);
VecMulf(cent, 0.33333333333f);
normal_tri_v3( no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
mul_v3_fl(cent, 0.33333333333f);
}
func(userData, orig, cent, no);
@@ -1750,26 +1736,24 @@ void CDDM_calc_normals(DerivedMesh *dm)
float *f_no = face_nors[i];
if(mf->v4)
CalcNormFloat4(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, mv[mf->v4].co, f_no);
normal_quad_v3( f_no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
else
CalcNormFloat(mv[mf->v1].co, mv[mf->v2].co,
mv[mf->v3].co, f_no);
normal_tri_v3( f_no,mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
VecAddf(temp_nors[mf->v1], temp_nors[mf->v1], f_no);
VecAddf(temp_nors[mf->v2], temp_nors[mf->v2], f_no);
VecAddf(temp_nors[mf->v3], temp_nors[mf->v3], f_no);
add_v3_v3v3(temp_nors[mf->v1], temp_nors[mf->v1], f_no);
add_v3_v3v3(temp_nors[mf->v2], temp_nors[mf->v2], f_no);
add_v3_v3v3(temp_nors[mf->v3], temp_nors[mf->v3], f_no);
if(mf->v4)
VecAddf(temp_nors[mf->v4], temp_nors[mf->v4], f_no);
add_v3_v3v3(temp_nors[mf->v4], temp_nors[mf->v4], f_no);
}
/* normalize vertex normals and assign */
for(i = 0; i < numVerts; i++, mv++) {
float *no = temp_nors[i];
if (Normalize(no) == 0.0) {
if (normalize_v3(no) == 0.0) {
VECCOPY(no, mv->co);
Normalize(no);
normalize_v3(no);
}
mv->no[0] = (short)(no[0] * 32767.0);
@@ -1981,7 +1965,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts
mvert = CustomData_get_layer(&orig->vertData, CD_MVERT);
mrdm->orco = MEM_callocN(sizeof(float) * 3 * orig->getNumVerts(orig), "multires orco");
for(i = 0; i < orig->getNumVerts(orig); ++i)
VecCopyf(mrdm->orco[i], mvert[i].co);
copy_v3_v3(mrdm->orco[i], mvert[i].co);
}
else
DM_init(dm, numVerts, numEdges, numFaces);

View File

@@ -403,7 +403,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul
/* Get the current position. */
VECCOPY(verts->xconst, mvert[i].co);
Mat4MulVecfl(ob->obmat, verts->xconst);
mul_m4_v3(ob->obmat, verts->xconst);
}
effectors = pdInitEffectors(clmd->scene, ob, NULL, clmd->sim_parms->effector_weights);
@@ -723,7 +723,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *
if (clmd->clothObject) {
/* inverse matrix is not uptodate... */
Mat4Invert (ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
mvert = CDDM_get_verts(dm);
numverts = dm->getNumVerts(dm);
@@ -731,7 +731,7 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *
for (i = 0; i < numverts; i++)
{
VECCOPY (mvert[i].co, cloth->verts[i].x);
Mat4MulVecfl (ob->imat, mvert[i].co); /* cloth is in global coords */
mul_m4_v3(ob->imat, mvert[i].co); /* cloth is in global coords */
}
}
}
@@ -867,7 +867,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
if(first)
{
VECCOPY ( verts->x, mvert[i].co );
Mat4MulVecfl ( ob->obmat, verts->x );
mul_m4_v3( ob->obmat, verts->x );
}
/* no GUI interface yet */
@@ -884,7 +884,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
VECCOPY ( verts->xconst, verts->x );
VECCOPY ( verts->txold, verts->x );
VECCOPY ( verts->tx, verts->x );
VecMulf ( verts->v, 0.0f );
mul_v3_fl( verts->v, 0.0f );
verts->impulse_count = 0;
VECCOPY ( verts->impulse, tnull );

View File

@@ -529,7 +529,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier
// calculate tangential velocity
VECCOPY ( temp, collpair->normal );
VecMulf ( temp, magrelVel );
mul_v3_fl( temp, magrelVel );
VECSUB ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
@@ -539,7 +539,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
Normalize ( vrel_t_pre );
normalize_v3( vrel_t_pre );
impulse = magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 ); // 2.0 *
VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse );
@@ -681,7 +681,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap
if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) )
{
VECCOPY ( collpair->normal, collpair->vector );
Normalize ( collpair->normal );
normalize_v3( collpair->normal );
collpair->distance = distance;
collpair->flag = 0;
@@ -726,6 +726,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap
return collpair;
}
#if 0
static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end )
{
int result = 0;
@@ -778,7 +779,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo
// calculate tangential velocity
VECCOPY ( temp, collpair->normal );
VecMulf ( temp, magrelVel );
mul_v3_fl( temp, magrelVel );
VECSUB ( vrel_t_pre, relativeVelocity, temp );
// Decrease in magnitude of relative tangential velocity due to coulomb friction
@@ -788,7 +789,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo
// Apply friction impulse.
if ( magtangent > ALMOST_ZERO )
{
Normalize ( vrel_t_pre );
normalize_v3( vrel_t_pre );
impulse = 2.0 * magtangent / ( 1.0 + w1*w1 + w2*w2 + w3*w3 );
VECADDMUL ( cloth1->verts[collpair->ap1].impulse, vrel_t_pre, w1 * impulse );
@@ -834,6 +835,7 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo
}
return result;
}
#endif
static float projectPointOntoLine(float *p, float *a, float *b)
{
@@ -853,15 +855,15 @@ static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,flo
// printf("l1: %f, l1: %f, l2: %f, l2: %f\n", line1[0], line1[1], line2[0], line2[1]);
Crossf(out_normal, line1, line2);
cross_v3_v3v3(out_normal, line1, line2);
length = Normalize(out_normal);
length = normalize_v3(out_normal);
if (length <= FLT_EPSILON)
{ // lines are collinear
VECSUB(out_normal, np2, np1);
Normalize(out_normal);
normalize_v3(out_normal);
}
}
@@ -901,7 +903,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
VECSUB(line1, np12, np11);
VECSUB(line2, np22, np21);
Crossf(cross, line1, line2);
cross_v3_v3v3(cross, line1, line2);
length = INPR(cross, cross);
if (length < FLT_EPSILON)
@@ -912,7 +914,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
*out_a1 = 0;
calculateEENormal(np11, np12, np21, np22, out_normal);
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(temp2, temp, np21);
VECADD(temp2, temp2, np11);
return INPR(temp2, temp2);
@@ -928,7 +930,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return (np22 - (np11 + (np12 - np11) * out_a1)).lengthSquared();
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(temp2, temp, np11);
VECSUB(temp2, np22, temp2);
return INPR(temp2, temp2);
@@ -943,7 +945,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return (np21 - (np11 + (np12 - np11) * out_a1)).lengthSquared();
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(temp2, temp, np11);
VECSUB(temp2, np21, temp2);
return INPR(temp2, temp2);
@@ -991,12 +993,12 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// p1= np11 + (np12 - np11) * out_a1;
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(p1, np11, temp);
// p2 = np21 + (np22 - np21) * out_a2;
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(p2, np21, temp);
calculateEENormal(np11, np12, np21, np22, out_normal);
@@ -1022,7 +1024,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// p1 = np11 + (np12 - np11) * out_a1;
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(p1, np11, temp);
*out_a2 = projectPointOntoLine(p1, np21, np22);
@@ -1032,7 +1034,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return (p1 - (np21 + (np22 - np21) * out_a2)).lengthSquared();
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(temp, temp, np21);
VECSUB(temp, p1, temp);
return INPR(temp, temp);
@@ -1044,7 +1046,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// p2 = np21 + (np22 - np21) * out_a2;
VECSUB(temp, np22, np21);
VecMulf(temp, *out_a2);
mul_v3_fl(temp, *out_a2);
VECADD(p2, np21, temp);
*out_a1 = projectPointOntoLine(p2, np11, np12);
@@ -1054,7 +1056,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
// return ((np11 + (np12 - np11) * out_a1) - p2).lengthSquared();
VECSUB(temp, np12, np11);
VecMulf(temp, *out_a1);
mul_v3_fl(temp, *out_a1);
VECADD(temp, temp, np11);
VECSUB(temp, temp, p2);
return INPR(temp, temp);
@@ -1065,6 +1067,7 @@ static float edgedge_distance(float np11[3], float np12[3], float np21[3], float
return 0;
}
#if 0
static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair )
{
EdgeCollPair edgecollpair;
@@ -1217,16 +1220,16 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
float desiredVn;
VECCOPY(vrel_1_to_2, verts1[edgecollpair.p11].tv);
VecMulf(vrel_1_to_2, 1.0 - a);
mul_v3_fl(vrel_1_to_2, 1.0 - a);
VECCOPY(temp, verts1[edgecollpair.p12].tv);
VecMulf(temp, a);
mul_v3_fl(temp, a);
VECADD(vrel_1_to_2, vrel_1_to_2, temp);
VECCOPY(temp, verts1[edgecollpair.p21].tv);
VecMulf(temp, 1.0 - b);
mul_v3_fl(temp, 1.0 - b);
VECCOPY(temp2, verts1[edgecollpair.p22].tv);
VecMulf(temp2, b);
mul_v3_fl(temp2, b);
VECADD(temp, temp, temp2);
VECSUB(vrel_1_to_2, vrel_1_to_2, temp);
@@ -1237,7 +1240,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi
if(out_normalVelocity < 0.0)
{
out_normalVelocity*= -1.0;
VecNegf(out_normal);
negate_v3(out_normal);
}
*/
/* Inelastic repulsion impulse. */
@@ -1292,6 +1295,7 @@ static int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierDa
return 1;
}
#endif
// return all collision objects in scene
@@ -1707,7 +1711,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
continue;
}
length = Normalize ( temp );
length = normalize_v3( temp );
if ( length < mindistance )
{
@@ -1715,17 +1719,17 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
if ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED )
{
VecMulf ( temp, -correction );
mul_v3_fl( temp, -correction );
VECADD ( verts[j].tx, verts[j].tx, temp );
}
else if ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED )
{
VecMulf ( temp, correction );
mul_v3_fl( temp, correction );
VECADD ( verts[i].tx, verts[i].tx, temp );
}
else
{
VecMulf ( temp, -correction*0.5 );
mul_v3_fl( temp, -correction*0.5 );
VECADD ( verts[j].tx, verts[j].tx, temp );
VECSUB ( verts[i].tx, verts[i].tx, temp );

View File

@@ -52,7 +52,7 @@
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_threads.h"
#include "IMB_imbuf.h"
@@ -462,35 +462,35 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
if(bezt[0].h2==HD_AUTO) {
hlen= VecLenf(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */
/* clip handle point */
VECCOPY(vec, bezt[1].vec[0]);
if(vec[0] < bezt[0].vec[1][0])
vec[0]= bezt[0].vec[1][0];
VecSubf(vec, vec, bezt[0].vec[1]);
nlen= VecLength(vec);
sub_v3_v3v3(vec, vec, bezt[0].vec[1]);
nlen= len_v3(vec);
if(nlen>FLT_EPSILON) {
VecMulf(vec, hlen/nlen);
VecAddf(bezt[0].vec[2], vec, bezt[0].vec[1]);
VecSubf(bezt[0].vec[0], bezt[0].vec[1], vec);
mul_v3_fl(vec, hlen/nlen);
add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]);
sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec);
}
}
a= cuma->totpoint-1;
if(bezt[a].h2==HD_AUTO) {
hlen= VecLenf(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */
/* clip handle point */
VECCOPY(vec, bezt[a-1].vec[2]);
if(vec[0] > bezt[a].vec[1][0])
vec[0]= bezt[a].vec[1][0];
VecSubf(vec, vec, bezt[a].vec[1]);
nlen= VecLength(vec);
sub_v3_v3v3(vec, vec, bezt[a].vec[1]);
nlen= len_v3(vec);
if(nlen>FLT_EPSILON) {
VecMulf(vec, hlen/nlen);
VecAddf(bezt[a].vec[0], vec, bezt[a].vec[1]);
VecSubf(bezt[a].vec[2], bezt[a].vec[1], vec);
mul_v3_fl(vec, hlen/nlen);
add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]);
sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -46,6 +46,8 @@
#include "BKE_screen.h"
#include "BKE_global.h"
#include "BPY_extern.h"
#include <string.h>
/* struct */
@@ -408,16 +410,26 @@ struct bContextDataResult {
static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result)
{
int done= 0, recursion= C->data.recursion;
int ret= 0;
memset(result, 0, sizeof(bContextDataResult));
if(CTX_py_dict_get(C)) {
return bpy_context_get(C, member, result);
return BPY_context_get(C, member, result);
// if (BPY_context_get(C, member, result))
// return 1;
}
/* we check recursion to ensure that we do not get infinite
* loops requesting data from ourselfs in a context callback */
if(!done && recursion < 1 && C->wm.store) {
/* Ok, this looks evil...
* if(ret) done= -(-ret | -done);
*
* Values in order of importance
* (0, -1, 1) - Where 1 is highest priority
* */
if(done!=1 && recursion < 1 && C->wm.store) {
bContextStoreEntry *entry;
C->data.recursion= 1;
@@ -429,21 +441,28 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
}
}
}
if(!done && recursion < 2 && C->wm.region) {
if(done!=1 && recursion < 2 && C->wm.region) {
C->data.recursion= 2;
if(C->wm.region->type && C->wm.region->type->context)
done= C->wm.region->type->context(C, member, result);
if(C->wm.region->type && C->wm.region->type->context) {
ret = C->wm.region->type->context(C, member, result);
if(ret) done= -(-ret | -done);
}
}
if(!done && recursion < 3 && C->wm.area) {
if(done!=1 && recursion < 3 && C->wm.area) {
C->data.recursion= 3;
if(C->wm.area->type && C->wm.area->type->context)
done= C->wm.area->type->context(C, member, result);
if(C->wm.area->type && C->wm.area->type->context) {
ret = C->wm.area->type->context(C, member, result);
if(ret) done= -(-ret | -done);
}
}
if(!done && recursion < 4 && C->wm.screen) {
if(done!=1 && recursion < 4 && C->wm.screen) {
bContextDataCallback cb= C->wm.screen->context;
C->data.recursion= 4;
if(cb)
done= cb(C, member, result);
if(cb) {
ret = cb(C, member, result);
if(ret) done= -(-ret | -done);
}
}
C->data.recursion= recursion;
@@ -455,7 +474,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
{
bContextDataResult result;
if(C && ctx_data_get((bContext*)C, member, &result))
if(C && ctx_data_get((bContext*)C, member, &result)==1)
return result.ptr.data;
return NULL;
@@ -465,7 +484,7 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void *
{
bContextDataResult result;
if(ctx_data_get((bContext*)C, member, &result)) {
if(ctx_data_get((bContext*)C, member, &result)==1) {
*pointer= result.ptr.data;
return 1;
}
@@ -479,7 +498,7 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
{
bContextDataResult result;
if(ctx_data_get((bContext*)C, member, &result)) {
if(ctx_data_get((bContext*)C, member, &result)==1) {
*list= result.list;
return 1;
}
@@ -494,7 +513,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
{
bContextDataResult result;
if(ctx_data_get((bContext*)C, member, &result))
if(ctx_data_get((bContext*)C, member, &result)==1)
return result.ptr;
else
return PointerRNA_NULL;
@@ -514,7 +533,7 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
{
bContextDataResult result;
if(ctx_data_get((bContext*)C, member, &result)) {
if(ctx_data_get((bContext*)C, member, &result)==1) {
return result.list;
}
else {
@@ -524,11 +543,13 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
}
}
void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb)
/* 1:found, -1:found but not set, 0:not found */
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb)
{
bContextDataResult result;
int ret= ctx_data_get((bContext*)C, member, &result);
if(ctx_data_get((bContext*)C, member, &result)) {
if(ret==1) {
*r_ptr= result.ptr;
*r_lb= result.list;
}
@@ -536,6 +557,8 @@ void CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, List
memset(r_ptr, 0, sizeof(*r_ptr));
memset(r_lb, 0, sizeof(*r_lb));
}
return ret;
}
static void data_dir_add(ListBase *lb, const char *member)

View File

@@ -40,7 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_object_types.h"
#include "DNA_curve_types.h"
@@ -145,6 +145,7 @@ Curve *add_curve(char *name, int type)
cu->fsize= 1.0;
cu->ulheight = 0.05;
cu->texflag= CU_AUTOSPACE;
cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform...
cu->bb= unit_boundbox();
@@ -991,7 +992,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float
for(i=0; i<3; i++) {
p[i]= (-6*t + 6)*p0[i] + (18*t - 12)*p1[i] + (-18*t + 6)*p2[i] + (6*t)*p3[i];
}
Normalize(p);
normalize_v3(p);
p = (float *)(((char *)p)+stride);
}
}
@@ -1597,7 +1598,7 @@ static void bevel_list_calc_bisect(BevList *bl)
nr= bl->nr;
while(nr--) {
/* totally simple */
VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
bevp0= bevp1;
bevp1= bevp2;
@@ -1615,8 +1616,8 @@ static void bevel_list_flip_tangents(BevList *bl)
nr= bl->nr;
while(nr--) {
if(RAD2DEG(VecAngle2(bevp0->tan, bevp1->tan)) > 90)
VecNegf(bevp1->tan);
if(RAD2DEG(angle_v2v2(bevp0->tan, bevp1->tan)) > 90)
negate_v3(bevp1->tan);
bevp0= bevp1;
bevp1= bevp2;
@@ -1636,9 +1637,9 @@ static void bevel_list_apply_tilt(BevList *bl)
nr= bl->nr;
while(nr--) {
AxisAngleToQuat(q, bevp1->dir, bevp1->alfa);
QuatMul(bevp1->quat, q, bevp1->quat);
NormalQuat(bevp1->quat);
axis_angle_to_quat(q, bevp1->dir, bevp1->alfa);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
normalize_qt(bevp1->quat);
bevp0= bevp1;
bevp1= bevp2;
@@ -1682,18 +1683,18 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
while(nr--) {
/* interpolate quats */
float zaxis[3] = {0,0,1}, cross[3], q2[4];
QuatInterpol(q, bevp0_quat, bevp2->quat, 0.5);
NormalQuat(q);
interp_qt_qtqt(q, bevp0_quat, bevp2->quat, 0.5);
normalize_qt(q);
QuatMulVecf(q, zaxis);
Crossf(cross, zaxis, bevp1->dir);
AxisAngleToQuat(q2, cross, NormalizedVecAngle2(zaxis, bevp1->dir));
NormalQuat(q2);
mul_qt_v3(q, zaxis);
cross_v3_v3v3(cross, zaxis, bevp1->dir);
axis_angle_to_quat(q2, cross, angle_normalized_v3v3(zaxis, bevp1->dir));
normalize_qt(q2);
QUATCOPY(bevp0_quat, bevp1->quat);
QuatMul(q, q2, q);
QuatInterpol(bevp1->quat, bevp1->quat, q, 0.5);
NormalQuat(bevp1->quat);
mul_qt_qtqt(q, q2, q);
interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5);
normalize_qt(bevp1->quat);
bevp0= bevp1;
@@ -1715,8 +1716,8 @@ static void make_bevel_list_3D_zup(BevList *bl)
nr= bl->nr;
while(nr--) {
/* totally simple */
VecBisect3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
vectoquat(bevp1->dir, 5, 1, bevp1->quat);
bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec);
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
bevp0= bevp1;
bevp1= bevp2;
@@ -1742,15 +1743,15 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
while(nr--) {
if(nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */
vectoquat(bevp1->dir, 5, 1, bevp1->quat);
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
}
else {
float angle= NormalizedVecAngle2(bevp0->dir, bevp1->dir);
float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir);
if(angle > 0.0f) { /* otherwise we can keep as is */
Crossf(cross_tmp, bevp0->dir, bevp1->dir);
AxisAngleToQuat(q, cross_tmp, angle);
QuatMul(bevp1->quat, q, bevp0->quat);
cross_v3_v3v3(cross_tmp, bevp0->dir, bevp1->dir);
axis_angle_to_quat(q, cross_tmp, angle);
mul_qt_qtqt(bevp1->quat, q, bevp0->quat);
}
else {
QUATCOPY(bevp1->quat, bevp0->quat);
@@ -1787,26 +1788,26 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
bevp_last--;
/* quats and vec's are normalized, should not need to re-normalize */
QuatMulVecf(bevp_first->quat, vec_1);
QuatMulVecf(bevp_last->quat, vec_2);
Normalize(vec_1);
Normalize(vec_2);
mul_qt_v3(bevp_first->quat, vec_1);
mul_qt_v3(bevp_last->quat, vec_2);
normalize_v3(vec_1);
normalize_v3(vec_2);
/* align the vector, can avoid this and it looks 98% OK but
* better to align the angle quat roll's before comparing */
{
Crossf(cross_tmp, bevp_last->dir, bevp_first->dir);
angle = NormalizedVecAngle2(bevp_first->dir, bevp_last->dir);
AxisAngleToQuat(q, cross_tmp, angle);
QuatMulVecf(q, vec_2);
cross_v3_v3v3(cross_tmp, bevp_last->dir, bevp_first->dir);
angle = angle_normalized_v3v3(bevp_first->dir, bevp_last->dir);
axis_angle_to_quat(q, cross_tmp, angle);
mul_qt_v3(q, vec_2);
}
angle= NormalizedVecAngle2(vec_1, vec_2);
angle= angle_normalized_v3v3(vec_1, vec_2);
/* flip rotation if needs be */
Crossf(cross_tmp, vec_1, vec_2);
Normalize(cross_tmp);
if(NormalizedVecAngle2(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI))
cross_v3_v3v3(cross_tmp, vec_1, vec_2);
normalize_v3(cross_tmp);
if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI))
angle = -angle;
bevp2= (BevPoint *)(bl+1);
@@ -1817,8 +1818,8 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
while(nr--) {
ang_fac= angle * (1.0f-((float)nr/bl->nr)); /* also works */
AxisAngleToQuat(q, bevp1->dir, ang_fac);
QuatMul(bevp1->quat, q, bevp1->quat);
axis_angle_to_quat(q, bevp1->dir, ang_fac);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
bevp0= bevp1;
bevp1= bevp2;
@@ -1847,9 +1848,9 @@ static void make_bevel_list_3D_tangent(BevList *bl)
nr= bl->nr;
while(nr--) {
Crossf(cross_tmp, bevp1->tan, bevp1->dir);
Crossf(bevp1->tan, cross_tmp, bevp1->dir);
Normalize(bevp1->tan);
cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir);
cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir);
normalize_v3(bevp1->tan);
bevp0= bevp1;
bevp1= bevp2;
@@ -1871,9 +1872,9 @@ static void make_bevel_list_3D_tangent(BevList *bl)
float cross_tmp[3];
float zero[3] = {0,0,0};
Crossf(cross_tmp, bevp1->tan, bevp1->dir);
Normalize(cross_tmp);
triatoquat(zero, cross_tmp, bevp1->tan, bevp1->quat); /* XXX - could be faster */
cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir);
normalize_v3(cross_tmp);
tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */
bevp0= bevp1;
bevp1= bevp2;
@@ -2279,14 +2280,14 @@ void makeBevelList(Object *ob)
bevp1= bevp2+1;
/* simple quat/dir */
VecSubf(bevp1->dir, bevp1->vec, bevp2->vec);
Normalize(bevp1->dir);
sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec);
normalize_v3(bevp1->dir);
vectoquat(bevp1->dir, 5, 1, bevp1->quat);
vec_to_quat( bevp1->quat,bevp1->dir, 5, 1);
AxisAngleToQuat(q, bevp1->dir, bevp1->alfa);
QuatMul(bevp1->quat, q, bevp1->quat);
NormalQuat(bevp1->quat);
axis_angle_to_quat(q, bevp1->dir, bevp1->alfa);
mul_qt_qtqt(bevp1->quat, q, bevp1->quat);
normalize_qt(bevp1->quat);
VECCOPY(bevp2->dir, bevp1->dir);
QUATCOPY(bevp2->quat, bevp1->quat);
}
@@ -2420,10 +2421,10 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
if(leftviolate || rightviolate) { /* align left handle */
float h1[3], h2[3];
VecSubf(h1, p2-3, p2);
VecSubf(h2, p2, p2+3);
len1= Normalize(h1);
len2= Normalize(h2);
sub_v3_v3v3(h1, p2-3, p2);
sub_v3_v3v3(h2, p2, p2+3);
len1= normalize_v3(h1);
len2= normalize_v3(h2);
vz= INPR(h1, h2);
@@ -2459,8 +2460,8 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
*(p2+5)= *(p2+2)+dz1;
}
len2= VecLenf(p2, p2+3);
len1= VecLenf(p2, p2-3);
len2= len_v3v3(p2, p2+3);
len1= len_v3v3(p2, p2-3);
if(len1==0.0) len1=1.0;
if(len2==0.0) len2=1.0;
@@ -2587,18 +2588,18 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(flag==0 || (bezt1->f1 & flag) ) {
bezt1->h1= 0;
/* distance too short: vectorhandle */
if( VecLenf( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) {
if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) {
bezt1->h1= HD_VECT;
leftsmall= 1;
}
else {
/* aligned handle? */
if(DistVL2Dfl(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) {
if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) {
align= 1;
bezt1->h1= HD_ALIGN;
}
/* or vector handle? */
if(DistVL2Dfl(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001)
if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001)
bezt1->h1= HD_VECT;
}
@@ -2607,7 +2608,7 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(flag==0 || (bezt1->f3 & flag) ) {
bezt1->h2= 0;
/* distance too short: vectorhandle */
if( VecLenf( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) {
if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) {
bezt1->h2= HD_VECT;
rightsmall= 1;
}
@@ -2616,7 +2617,7 @@ void autocalchandlesNurb(Nurb *nu, int flag)
if(align) bezt1->h2= HD_ALIGN;
/* or vector handle? */
if(DistVL2Dfl(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001)
if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001)
bezt1->h2= HD_VECT;
}

View File

@@ -34,7 +34,7 @@
#include "BKE_customdata.h"
#include "BKE_utildefines.h" // CLAMP
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_mempool.h"
@@ -410,21 +410,21 @@ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, fl
vrat = v - y;
uopp = 1 - urat;
VecCopyf(d[0], disps[y * st + x]);
VecCopyf(d[1], disps[y * st + x2]);
VecCopyf(d[2], disps[y2 * st + x]);
VecCopyf(d[3], disps[y2 * st + x2]);
VecMulf(d[0], uopp);
VecMulf(d[1], urat);
VecMulf(d[2], uopp);
VecMulf(d[3], urat);
copy_v3_v3(d[0], disps[y * st + x]);
copy_v3_v3(d[1], disps[y * st + x2]);
copy_v3_v3(d[2], disps[y2 * st + x]);
copy_v3_v3(d[3], disps[y2 * st + x2]);
mul_v3_fl(d[0], uopp);
mul_v3_fl(d[1], urat);
mul_v3_fl(d[2], uopp);
mul_v3_fl(d[3], urat);
VecAddf(d2[0], d[0], d[1]);
VecAddf(d2[1], d[2], d[3]);
VecMulf(d2[0], 1 - vrat);
VecMulf(d2[1], vrat);
add_v3_v3v3(d2[0], d[0], d[1]);
add_v3_v3v3(d2[1], d[2], d[3]);
mul_v3_fl(d2[0], 1 - vrat);
mul_v3_fl(d2[1], vrat);
VecAddf(out, d2[0], d2[1]);
add_v3_v3v3(out, d2[0], d2[1]);
}
static void layerSwap_mdisps(void *data, int *ci)
@@ -440,7 +440,7 @@ static void layerSwap_mdisps(void *data, int *ci)
for(y = 0; y < st; ++y) {
for(x = 0; x < st; ++x) {
VecCopyf(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]);
copy_v3_v3(d[(st - y - 1) * st + (st - x - 1)], s->disps[y * st + x]);
}
}
@@ -462,7 +462,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight
/* Initialize the destination */
for(i = 0; i < d->totdisp; ++i) {
float z[3] = {0,0,0};
VecCopyf(d->disps[i], z);
copy_v3_v3(d->disps[i], z);
}
/* For now, some restrictions on the input */
@@ -493,7 +493,7 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight
float srcdisp[3];
mdisps_bilinear(srcdisp, s->disps, st, mid3[0], mid3[1]);
VecCopyf(d->disps[y * st + x], srcdisp);
copy_v3_v3(d->disps[y * st + x], srcdisp);
}
}
}

View File

@@ -59,7 +59,7 @@
#include "BKE_mesh.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#ifdef HAVE_CONFIG_H
#include <config.h>

View File

@@ -34,7 +34,7 @@
#endif
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "DNA_anim_types.h"
#include "DNA_action_types.h"

View File

@@ -56,7 +56,7 @@
#include "DNA_key_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_edgehash.h"
@@ -220,12 +220,12 @@ void addnormalsDispList(Object *ob, ListBase *lb)
for(; b<dl->nr; b++) {
CalcNormFloat4(v1, v3, v4, v2, nor);
normal_quad_v3( nor,v1, v3, v4, v2);
VecAddf(n1, n1, nor);
VecAddf(n2, n2, nor);
VecAddf(n3, n3, nor);
VecAddf(n4, n4, nor);
add_v3_v3v3(n1, n1, nor);
add_v3_v3v3(n2, n2, nor);
add_v3_v3v3(n3, n3, nor);
add_v3_v3v3(n4, n4, nor);
v2= v1; v1+= 3;
v4= v3; v3+= 3;
@@ -236,7 +236,7 @@ void addnormalsDispList(Object *ob, ListBase *lb)
a= dl->parts*dl->nr;
v1= ndata;
while(a--) {
Normalize(v1);
normalize_v3(v1);
v1+= 3;
}
}
@@ -475,11 +475,11 @@ static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, floa
init_fastshade_shadeinput(re);
RE_DataBase_GetView(re, tmat);
Mat4MulMat4(mat, ob->obmat, tmat);
mul_m4_m4m4(mat, ob->obmat, tmat);
Mat4Invert(tmat, mat);
Mat3CpyMat4(imat, tmat);
if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0);
invert_m4_m4(tmat, mat);
copy_m3_m4(imat, tmat);
if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0);
if (need_orco_r) *need_orco_r= 0;
for(a=0; a<ob->totcol; a++) {
@@ -563,7 +563,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
Normalize(vn);
normalize_v3(vn);
}
for (i=0; i<totface; i++) {
@@ -586,15 +586,15 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
VECCOPY(nor, &nors[i*3]);
} else {
if (mf->v4)
CalcNormFloat4(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co, nor);
normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
else
CalcNormFloat(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, nor);
normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
}
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalize(n1);
normalize_v3(n1);
for (j=0; j<nverts; j++) {
MVert *mv= &mvert[vidx[j]];
@@ -603,7 +603,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
VECCOPY(vec, mv->co);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
vec[0]+= 0.001*vn[0];
vec[1]+= 0.001*vn[1];
vec[2]+= 0.001*vn[2];
@@ -708,14 +708,14 @@ void shadeDispList(Scene *scene, Base *base)
n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2];
n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2];
n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2];
Normalize(n1);
normalize_v3(n1);
fp= dl->verts;
a= dl->nr;
while(a--) {
VECCOPY(vec, fp);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
@@ -731,12 +731,12 @@ void shadeDispList(Scene *scene, Base *base)
while(a--) {
VECCOPY(vec, fp);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalize(n1);
normalize_v3(n1);
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
@@ -769,13 +769,13 @@ void shadeDispList(Scene *scene, Base *base)
a= dl->nr;
while(a--) {
VECCOPY(vec, fp);
Mat4MulVecfl(mat, vec);
mul_m4_v3(mat, vec);
/* transpose ! */
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalize(n1);
normalize_v3(n1);
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
@@ -1612,7 +1612,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
vec[1]= fp1[2];
vec[2]= 0.0;
QuatMulVecf(bevp->quat, vec);
mul_qt_v3(bevp->quat, vec);
data[0]= bevp->vec[0] + fac*vec[0];
data[1]= bevp->vec[1] + fac*vec[1];

View File

@@ -52,7 +52,7 @@
#include "DNA_texture_types.h"
#include "DNA_scene_types.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_jitter.h"
#include "BLI_listbase.h"
@@ -221,8 +221,8 @@ static void precalculate_effector(EffectorCache *eff)
if(cu->path && cu->path->data) {
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius);
Mat4MulVecfl(eff->ob->obmat, eff->guide_loc);
Mat4Mul3Vecfl(eff->ob->obmat, eff->guide_dir);
mul_m4_v3(eff->ob->obmat, eff->guide_loc);
mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir);
}
}
}
@@ -433,8 +433,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect
return visibility;
VECCOPY(norm, efd->vec_to_point);
VecNegf(norm);
len = Normalize(norm);
negate_v3(norm);
len = normalize_v3(norm);
// check all collision objects
for(col = colls->first; col; col = col->next)
@@ -520,7 +520,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi
float falloff = weights ? weights->weight[0] * weights->weight[eff->pd->forcefield] : 1.0f;
float fac, r_fac;
fac = Inpf(efd->nor, efd->vec_to_point2);
fac = dot_v3v3(efd->nor, efd->vec_to_point2);
if(eff->pd->zdir == PFIELD_Z_POS && fac < 0.0f)
falloff=0.0f;
@@ -537,7 +537,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi
break;
VECADDFAC(temp, efd->vec_to_point, efd->nor, -fac);
r_fac= VecLength(temp);
r_fac= len_v3(temp);
falloff*= falloff_func_rad(eff->pd, r_fac);
break;
case PFIELD_FALL_CONE:
@@ -545,7 +545,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *poi
if(falloff == 0.0f)
break;
r_fac=saacos(fac/VecLength(efd->vec_to_point))*180.0f/(float)M_PI;
r_fac=saacos(fac/len_v3(efd->vec_to_point))*180.0f/(float)M_PI;
falloff*= falloff_func_rad(eff->pd, r_fac);
break;
@@ -574,12 +574,12 @@ int closest_point_on_surface(SurfaceModifierData *surmd, float *co, float *surfa
MFace *mface = CDDM_get_face(surmd->dm, nearest.index);
VECCOPY(surface_vel, surmd->v[mface->v1].co);
VecAddf(surface_vel, surface_vel, surmd->v[mface->v2].co);
VecAddf(surface_vel, surface_vel, surmd->v[mface->v3].co);
add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v2].co);
add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v3].co);
if(mface->v4)
VecAddf(surface_vel, surface_vel, surmd->v[mface->v4].co);
add_v3_v3v3(surface_vel, surface_vel, surmd->v[mface->v4].co);
VecMulf(surface_vel, mface->v4 ? 0.25f : 0.333f);
mul_v3_fl(surface_vel, mface->v4 ? 0.25f : 0.333f);
}
return 1;
}
@@ -596,9 +596,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
float vec[3];
/* using velocity corrected location allows for easier sliding over effector surface */
VecCopyf(vec, point->vel);
VecMulf(vec, point->vel_to_frame);
VecAddf(vec, vec, point->loc);
copy_v3_v3(vec, point->vel);
mul_v3_fl(vec, point->vel_to_frame);
add_v3_v3v3(vec, vec, point->loc);
ret = closest_point_on_surface(eff->surmd, vec, efd->loc, efd->nor, real_velocity ? efd->vel : NULL);
@@ -612,10 +612,10 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
dm->getVertCo(dm, *efd->index, efd->loc);
dm->getVertNo(dm, *efd->index, efd->nor);
Mat4MulVecfl(eff->ob->obmat, efd->loc);
Mat4Mul3Vecfl(eff->ob->obmat, efd->nor);
mul_m4_v3(eff->ob->obmat, efd->loc);
mul_mat3_m4_v3(eff->ob->obmat, efd->nor);
Normalize(efd->nor);
normalize_v3(efd->nor);
efd->size = 0.0f;
@@ -660,15 +660,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
/* use z-axis as normal*/
VECCOPY(efd->nor, ob->obmat[2]);
Normalize(efd->nor);
normalize_v3(efd->nor);
/* for vortex the shape chooses between old / new force */
if(eff->pd->shape == PFIELD_SHAPE_PLANE) {
/* efd->loc is closes point on effector xy-plane */
float temp[3];
VecSubf(temp, point->loc, ob->obmat[3]);
Projf(efd->loc, temp, efd->nor);
VecSubf(efd->loc, point->loc, efd->loc);
sub_v3_v3v3(temp, point->loc, ob->obmat[3]);
project_v3_v3v3(efd->loc, temp, efd->nor);
sub_v3_v3v3(efd->loc, point->loc, efd->loc);
}
else {
VECCOPY(efd->loc, ob->obmat[3]);
@@ -679,7 +679,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
where_is_object_time(eff->scene, ob, cfra - 1.0);
VecSubf(efd->vel, efd->vel, ob->obmat[3]);
sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]);
}
*eff->ob = obcopy;
@@ -690,8 +690,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
if(ret) {
VecSubf(efd->vec_to_point, point->loc, efd->loc);
efd->distance = VecLength(efd->vec_to_point);
sub_v3_v3v3(efd->vec_to_point, point->loc, efd->loc);
efd->distance = len_v3(efd->vec_to_point);
if(eff->flag & PE_USE_NORMAL_DATA) {
VECCOPY(efd->vec_to_point2, efd->vec_to_point);
@@ -699,9 +699,9 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
}
else {
/* for some effectors we need the object center every time */
VecSubf(efd->vec_to_point2, point->loc, eff->ob->obmat[3]);
sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->obmat[3]);
VECCOPY(efd->nor2, eff->ob->obmat[2]);
Normalize(efd->nor2);
normalize_v3(efd->nor2);
}
}
@@ -764,12 +764,12 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
VECCOPY(tex_co,point->loc);
if(eff->pd->flag & PFIELD_TEX_2D) {
float fac=-Inpf(tex_co, efd->nor);
float fac=-dot_v3v3(tex_co, efd->nor);
VECADDFAC(tex_co, tex_co, efd->nor, fac);
}
if(eff->pd->flag & PFIELD_TEX_OBJECT) {
Mat4Mul3Vecfl(eff->ob->obmat, tex_co);
mul_mat3_m4_v3(eff->ob->obmat, tex_co);
}
hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 1, result);
@@ -815,11 +815,11 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
}
if(eff->pd->flag & PFIELD_TEX_2D){
float fac = -Inpf(force, efd->nor);
float fac = -dot_v3v3(force, efd->nor);
VECADDFAC(force, force, efd->nor, fac);
}
VecAddf(total_force, total_force, force);
add_v3_v3v3(total_force, total_force, force);
}
void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
{
@@ -844,51 +844,51 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
switch(pd->forcefield){
case PFIELD_WIND:
VECCOPY(force, efd->nor);
VecMulf(force, strength * efd->falloff);
mul_v3_fl(force, strength * efd->falloff);
break;
case PFIELD_FORCE:
Normalize(force);
VecMulf(force, strength * efd->falloff);
normalize_v3(force);
mul_v3_fl(force, strength * efd->falloff);
break;
case PFIELD_VORTEX:
/* old vortex force */
if(pd->shape == PFIELD_SHAPE_POINT) {
Crossf(force, efd->nor, efd->vec_to_point);
Normalize(force);
VecMulf(force, strength * efd->distance * efd->falloff);
cross_v3_v3v3(force, efd->nor, efd->vec_to_point);
normalize_v3(force);
mul_v3_fl(force, strength * efd->distance * efd->falloff);
}
else {
/* new vortex force */
Crossf(temp, efd->nor2, efd->vec_to_point2);
VecMulf(temp, strength * efd->falloff);
cross_v3_v3v3(temp, efd->nor2, efd->vec_to_point2);
mul_v3_fl(temp, strength * efd->falloff);
Crossf(force, efd->nor2, temp);
VecMulf(force, strength * efd->falloff);
cross_v3_v3v3(force, efd->nor2, temp);
mul_v3_fl(force, strength * efd->falloff);
VECADDFAC(temp, temp, point->vel, -point->vel_to_sec);
VecAddf(force, force, temp);
add_v3_v3v3(force, force, temp);
}
break;
case PFIELD_MAGNET:
if(eff->pd->shape == PFIELD_SHAPE_POINT)
/* magnetic field of a moving charge */
Crossf(temp, efd->nor, efd->vec_to_point);
cross_v3_v3v3(temp, efd->nor, efd->vec_to_point);
else
VecCopyf(temp, efd->nor);
copy_v3_v3(temp, efd->nor);
Normalize(temp);
VecMulf(temp, strength * efd->falloff);
Crossf(force, point->vel, temp);
VecMulf(force, point->vel_to_sec);
normalize_v3(temp);
mul_v3_fl(temp, strength * efd->falloff);
cross_v3_v3v3(force, point->vel, temp);
mul_v3_fl(force, point->vel_to_sec);
break;
case PFIELD_HARMONIC:
VecMulf(force, -strength * efd->falloff);
VecCopyf(temp, point->vel);
VecMulf(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec);
VecAddf(force, force, temp);
mul_v3_fl(force, -strength * efd->falloff);
copy_v3_v3(temp, point->vel);
mul_v3_fl(temp, -damp * 2.0f * (float)sqrt(fabs(strength)) * point->vel_to_sec);
add_v3_v3v3(force, force, temp);
break;
case PFIELD_CHARGE:
VecMulf(force, point->charge * strength * efd->falloff);
mul_v3_fl(force, point->charge * strength * efd->falloff);
break;
case PFIELD_LENNARDJ:
fac = pow((efd->size + point->size) / efd->distance, 6.0);
@@ -898,7 +898,7 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
/* limit the repulsive term drastically to avoid huge forces */
fac = ((fac>2.0) ? 2.0 : fac);
VecMulf(force, strength * fac);
mul_v3_fl(force, strength * fac);
break;
case PFIELD_BOID:
/* Boid field is handled completely in boids code. */
@@ -913,16 +913,16 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
force[0] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[0], temp[1], temp[2], 2,0,2);
force[1] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[1], temp[2], temp[0], 2,0,2);
force[2] = -1.0f + 2.0f * BLI_gTurbulence(pd->f_size, temp[2], temp[0], temp[1], 2,0,2);
VecMulf(force, strength * efd->falloff);
mul_v3_fl(force, strength * efd->falloff);
break;
case PFIELD_DRAG:
VECCOPY(force, point->vel);
fac = Normalize(force) * point->vel_to_sec;
fac = normalize_v3(force) * point->vel_to_sec;
strength = MIN2(strength, 2.0f);
damp = MIN2(damp, 2.0f);
VecMulf(force, -efd->falloff * fac * (strength * fac + damp));
mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp));
break;
}
@@ -937,12 +937,12 @@ void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *
if(pd->flag & PFIELD_DO_ROTATION && point->ave && point->rot) {
float xvec[3] = {1.0f, 0.0f, 0.0f};
float dave[3];
QuatMulVecf(point->rot, xvec);
Crossf(dave, xvec, force);
mul_qt_v3(point->rot, xvec);
cross_v3_v3v3(dave, xvec, force);
if(pd->f_flow != 0.0f) {
VECADDFAC(dave, dave, point->ave, -pd->f_flow * efd->falloff);
}
VecAddf(point->ave, point->ave, dave);
add_v3_v3v3(point->ave, point->ave, dave);
}
}

View File

@@ -64,7 +64,7 @@
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BKE_blender.h"
@@ -180,7 +180,7 @@ static void mesh_add_normals_flags(Mesh *me)
v3= me->mvert+mface->v3;
v4= me->mvert+mface->v4;
CalcNormFloat(v1->co, v2->co, v3->co, nor);
normal_tri_v3( nor,v1->co, v2->co, v3->co);
sno[0]= 32767.0*nor[0];
sno[1]= 32767.0*nor[1];
sno[2]= 32767.0*nor[2];
@@ -1249,7 +1249,7 @@ static void read_inventor(Scene *scene, char *str, struct ListBase *listb)
VECCOPY(bp->vec, data);
if(coordtype==4) {
bp->vec[3]= data[3];
VecMulf(bp->vec, 1.0f/data[3]);
mul_v3_fl(bp->vec, 1.0f/data[3]);
}
else bp->vec[3]= 1.0;
data+= coordtype;
@@ -1837,7 +1837,7 @@ static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL)
float vert[3];
VECCOPY(vert, verts[(index)].co);
Mat4MulVecfl(ob->obmat, vert);
mul_m4_v3(ob->obmat, vert);
if (ENDIAN_ORDER==B_ENDIAN) {
SWITCH_INT(vert[0]);
@@ -2174,7 +2174,7 @@ static void write_camera_vrml(FILE *fp, Object *ob)
Camera *cam;
if(ob==0) return;
Mat4Invert(ob->imat, ob->obmat);
invert_m4_m4(ob->imat, ob->obmat);
fprintf(fp, "\tMatrixTransform {\n");
@@ -3031,10 +3031,10 @@ static void dxf_read_line(Scene *scene, int noob) {
mvert= &me->mvert[(me->totvert-2)];
VecSubf(mvert->co, cent, vcenter);
sub_v3_v3v3(mvert->co, cent, vcenter);
mvert++;
if (vspace) { VECCOPY(mvert->co, epoint);
} else VecSubf(mvert->co, epoint, vcenter);
} else sub_v3_v3v3(mvert->co, epoint, vcenter);
mface= &(((MFace*)me->mface)[me->totface-1]);
mface->v1= me->totvert-2;
@@ -3237,7 +3237,7 @@ static void dxf_read_ellipse(Scene *scene, int noob)
if (vspace) {
VECCOPY(mvert->co, epoint);
} else {
VecSubf(mvert->co, epoint, vcenter);
sub_v3_v3v3(mvert->co, epoint, vcenter);
}
if (v > 0) {
@@ -3360,7 +3360,7 @@ static void dxf_read_arc(Scene *scene, int noob)
if (vspace) {
VECCOPY(mvert->co, epoint);
} else {
VecSubf(mvert->co, epoint, vcenter);
sub_v3_v3v3(mvert->co, epoint, vcenter);
}
if (v > 0) {
@@ -3470,7 +3470,7 @@ static void dxf_read_polyline(Scene *scene, int noob) {
mvert= &me->mvert[me->totvert-1];
if (vspace) { VECCOPY(mvert->co, vert);
} else VecSubf(mvert->co, vert, vcenter);
} else sub_v3_v3v3(mvert->co, vert, vcenter);
}
/* make edges */
@@ -3556,7 +3556,7 @@ static void dxf_read_polyline(Scene *scene, int noob) {
mvert= &me->mvert[(me->totvert-1)];
if (vspace) { VECCOPY(mvert->co, vert);
} else VecSubf(mvert->co, vert, vcenter);
} else sub_v3_v3v3(mvert->co, vert, vcenter);
} else if (vflags & 128) {
if(vids[2]==0) {
@@ -3687,7 +3687,7 @@ static void dxf_read_lwpolyline(Scene *scene, int noob) {
if (vspace) {
VECCOPY(mvert->co, vert);
} else {
VecSubf(mvert->co, vert, vcenter);
sub_v3_v3v3(mvert->co, vert, vcenter);
}
if (v > 0) {
@@ -3859,20 +3859,20 @@ static void dxf_read_3dface(Scene *scene, int noob)
ftmp=NULL;
mvert= &me->mvert[(me->totvert-nverts)];
VecSubf(mvert->co, cent, vcenter);
sub_v3_v3v3(mvert->co, cent, vcenter);
mvert++;
if (vspace) { VECCOPY(mvert->co, vert2);
} else VecSubf(mvert->co, vert2, vcenter);
} else sub_v3_v3v3(mvert->co, vert2, vcenter);
mvert++;
if (vspace) { VECCOPY(mvert->co, vert3);
} else VecSubf(mvert->co, vert3, vcenter);
} else sub_v3_v3v3(mvert->co, vert3, vcenter);
if (nverts==4) {
mvert++;
if (vspace) { VECCOPY(mvert->co, vert4);
} else VecSubf(mvert->co, vert4, vcenter);
} else sub_v3_v3v3(mvert->co, vert4, vcenter);
}
mface= &(((MFace*)me->mface)[me->totface-1]);

View File

@@ -43,7 +43,7 @@
#include "DNA_anim_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_noise.h"
#include "BKE_fcurve.h"
@@ -924,11 +924,11 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
}
/* use the final posed locations */
Mat4ToQuat(pchan->pose_mat, q1);
Mat4ToQuat(pchan2->pose_mat, q2);
mat4_to_quat( q1,pchan->pose_mat);
mat4_to_quat( q2,pchan2->pose_mat);
QuatInv(q1);
QuatMul(quat, q1, q2);
invert_qt(q1);
mul_qt_qtqt(quat, q1, q2);
angle = 2.0f * (saacos(quat[0]));
angle= ABS(angle);
@@ -1017,13 +1017,13 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o)
if (d > 0.0) {
t= sqrt(d);
o[0]= (float)(Sqrt3d(-q+t) + Sqrt3d(-q-t) - a);
o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a);
if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1;
else return 0;
}
else if (d == 0.0) {
t= Sqrt3d(-q);
t= sqrt3d(-q);
o[0]= (float)(2*t - a);
if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++;

View File

@@ -40,7 +40,7 @@
#include "DNA_particle_types.h"
#include "DNA_scene_types.h" // N_T
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BKE_cdderivedmesh.h"
@@ -563,13 +563,13 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
float vec[3];
VECCOPY(vec, mvert[0].co);
Mat4MulVecfl(obmat, vec);
mul_m4_v3(obmat, vec);
bbsx = vec[0]; bbsy = vec[1]; bbsz = vec[2];
bbex = vec[0]; bbey = vec[1]; bbez = vec[2];
for(i = 1; i < totvert; i++) {
VECCOPY(vec, mvert[i].co);
Mat4MulVecfl(obmat, vec);
mul_m4_v3(obmat, vec);
if(vec[0] < bbsx){ bbsx= vec[0]; }
if(vec[1] < bbsy){ bbsy= vec[1]; }
@@ -626,7 +626,7 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
verts = MEM_callocN( totvert*3*sizeof(float), "elbeemmesh_vertices");
for(i=0; i<totvert; i++) {
VECCOPY( &verts[i*3], mvert[i].co);
if(useGlobalCoords) { Mat4MulVecfl(ob->obmat, &verts[i*3]); }
if(useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); }
}
*vertices = verts;

View File

@@ -41,7 +41,7 @@
#include "DNA_anim_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_math.h"
#include "BLI_noise.h"
#include "BKE_fcurve.h"

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