This commit is contained in:
Campbell Barton 2008-11-19 03:43:03 +00:00
commit e6a4f4cf29
16 changed files with 248 additions and 138 deletions

@ -249,7 +249,7 @@ if len(B.quickdebug) > 0 and printdebug != 0:
# remove stdc++ from LLIBS if we are building a statc linked CXXFLAGS
if env['WITH_BF_STATICCXX']:
if 'stdc++' in env['LLIBS']:
env['LLIBS'] = env['LLIBS'].replace('stdc++', ' ')
env['LLIBS'].remove('stdc++')
else:
print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'

@ -216,14 +216,14 @@ CXXFLAGS = [ '-pipe','-fPIC','-funsigned-char', '-fpascal-strings']
PLATFORM_LINKFLAGS = '-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime'
#note to build succesfully on 10.3.9 SDK you need to patch 10.3.9 by adding the SystemStubs.a lib from 10.4
LLIBS = 'stdc++ SystemStubs'
LLIBS = ['stdc++', 'SystemStubs']
# some flags shuffling for different Os versions
if MAC_MIN_VERS == '10.3':
CFLAGS = ['-fuse-cxa-atexit']+CFLAGS
CXXFLAGS = ['-fuse-cxa-atexit']+CXXFLAGS
PLATFORM_LINKFLAGS = '-fuse-cxa-atexit '+PLATFORM_LINKFLAGS
LLIBS = LLIBS + ' crt3.o'
LLIBS.append('crt3.o')
if USE_SDK==True:
SDK_FLAGS=['-isysroot', MACOSX_SDK,'-mmacosx-version-min='+MAC_MIN_VERS]
@ -261,6 +261,7 @@ CC_WARN = ['-Wall', '-Wno-long-double']
##DYNLDFLAGS = -shared $(LDFLAGS)
BF_PROFILE_CCFLAGS = ['-pg', '-g ']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_PROFILE = False
BF_DEBUG = False

@ -193,12 +193,13 @@ CC_WARN = ['-Wall']
##FIX_STUBS_WARNINGS = -Wno-unused
LLIBS = 'util c m dl pthread stdc++'
LLIBS = ['util', 'c', 'm', 'dl', 'pthread', 'stdc++']
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
BF_PROFILE = False
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_DEBUG = False
BF_DEBUG_CCFLAGS = ['-g']

@ -149,6 +149,10 @@ LLIBS = [ '-ldxguid', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32', '-lm', '-lw
BF_DEBUG = False
BF_DEBUG_CCFLAGS= []
BF_PROFILE = False
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_BUILDDIR = '../build/linuxcross'
BF_INSTALLDIR='../install/linuxcross'
BF_DOCDIR='../install/doc'

@ -151,12 +151,13 @@ CC_WARN = ['-Wall']
##FIX_STUBS_WARNINGS = -Wno-unused
LLIBS = 'm stdc++ pthread util'
LLIBS = ['m', 'stdc++', 'pthread', 'util']
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
BF_PROFILE_CCFLAGS = ['-pg', '-g']
BF_PROFILE = False
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_DEBUG = False
BF_DEBUG_CCFLAGS = ['-g']

@ -165,11 +165,12 @@ CC_WARN = ['-Wall']
##FIX_STUBS_WARNINGS = -Wno-unused
LLIBS = 'c m dl pthread stdc++'
LLIBS = ['c', 'm', 'dl', 'pthread', 'stdc++']
##LOPTS = --dynamic
##DYNLDFLAGS = -shared $(LDFLAGS)
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_CCFLAGS = ['-pg', '-g ']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_PROFILE = False
BF_DEBUG = False

@ -164,7 +164,8 @@ LLIBS = ['-lshell32', '-lshfolder', '-lgdi32', '-lmsvcrt', '-lwinmm', '-lmingw32
BF_DEBUG = False
BF_DEBUG_CCFLAGS= ['-g']
BF_PROFILE_CCFLAGS = ['-pg','-g']
BF_PROFILE_CCFLAGS = ['-pg', '-g ']
BF_PROFILE_LINKFLAGS = ['-pg']
BF_PROFILE = False
BF_BUILDDIR = '..\\build\\win32-mingw'

@ -181,7 +181,7 @@ C_WARN = []
CC_WARN = []
CXX_WARN = []
LLIBS = 'ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid'
LLIBS = ['ws2_32', 'vfw32', 'winmm', 'kernel32', 'user32', 'gdi32', 'comdlg32', 'advapi32', 'shfolder', 'shell32', 'ole32', 'oleaut32', 'uuid']
PLATFORM_LINKFLAGS = '''
/SUBSYSTEM:CONSOLE
@ -197,6 +197,11 @@ PLATFORM_LINKFLAGS = '''
/LARGEADDRESSAWARE
'''
# # Todo
# BF_PROFILE_CCFLAGS = ['-pg', '-g ']
# BF_PROFILE_LINKFLAGS = ['-pg']
# BF_PROFILE = False
BF_BUILDDIR = '..\\build\\win32-vc'
BF_INSTALLDIR='..\\install\\win32-vc'
BF_DOCDIR='..\\install\\doc'

@ -7,7 +7,7 @@ Group: 'Import'
Tooltip: 'Import for DXF geometry data (Drawing eXchange Format).'
"""
__author__ = 'Kitsu(Ed Blake) & migius(Remigiusz Fiedler)'
__version__ = '1.12 - 2008.08.03 by migius'
__version__ = '1.12 - 2008.11.16 by migius'
__url__ = ["http://blenderartists.org/forum/showthread.php?t=84319",
"http://wiki.blender.org/index.php/Scripts/Manual/Import/DXF-3D"]
__email__ = ["migius(at)4d-vectors.de","Kitsune_e(at)yahoo.com"]
@ -111,6 +111,9 @@ History:
-- support ortho mode for VIEWs and VPORTs as cameras
v1.12 - 2008.11.16 by migius
d1 remove try_finally: cause not supported in python <2.5
d1 add Bezier curves bevel radius support (default 1.0)
v1.12 - 2008.08.03 by migius
c2 warningfix: relocating of globals: layersmap, oblist
c2 modif UI: buttons newScene+targetLayer moved to start panel
@ -299,7 +302,7 @@ History:
import Blender
from Blender import *
#from Blender.Mathutils import Vector, Matrix
import bpy
#import bpy #not used yet
#import BPyMessages
from dxfReader import readDXF
@ -311,7 +314,7 @@ from math import *
try:
import os
if os.name:# != 'mac':
if os.name != 'mac':
import psyco
psyco.log(Blender.Get('tempdir')+"/blender.log-psyco")
#psyco.log()
@ -320,7 +323,7 @@ try:
psyco.profile(0.2)
#print 'psyco imported'
except ImportError:
#print 'psyco not imported'
print 'psyco not imported'
pass
#try: Curve.orderU
@ -346,7 +349,7 @@ THIN_RESOLUTION = 8 #(4-64) thin_cylinder arc_resolution - number of segments
MIN_THICK = MIN_DIST * 10.0 #minimal thickness by forced thickness
MIN_WIDTH = MIN_DIST * 10.0 #minimal width by forced width
TRIM_LIMIT = 3.0 #limit for triming of polylines-wide-segments (values:0.0 - 5.0)
ELEVATION = 0.0 #standard elevation = coordinate Z
ELEVATION = 0.0 #standard elevation = coordinate Z value
BYBLOCK = 0
BYLAYER = 256
@ -817,6 +820,7 @@ class Line: #-----------------------------------------------------------------
curve.append(BezTriple.New(points[1]))
for point in curve:
point.handleTypes = [VECT, VECT]
point.radius = 1.0
curve.flagU = 0 # 0 sets the curve not cyclic=open
c.setResolu(settings.var['curve_res'])
c.update() #important for handles calculation
@ -1341,9 +1345,11 @@ class Polyline: #--------------------------------------------------------------
nurbs_points.append(pkt)
firstpoint = nurbs_points[0]
curve = pline.appendNurb(firstpoint)
curve.setType(4) # set curvetype NURBS
curve.setType(4) # set curve_type NURBS
print 'deb: dir(curve):', dir(curve[-1]) #----------------
for point in nurbs_points[1:]:
curve.append(point)
#TODO: what is the trick for bevel radius? curve[-1].radius = 1.0
if self.closed:
curve.flagU = 1+0 # Set curve cyclic=close and uni
else:
@ -1359,6 +1365,7 @@ class Polyline: #--------------------------------------------------------------
curve.append(BezTriple.New(p))
for point in curve:
point.handleTypes = [AUTO, AUTO]
point.radius = 1.0
if self.closed:
curve.flagU = 1 # Set curve cyclic=close
else:
@ -1380,6 +1387,7 @@ class Polyline: #--------------------------------------------------------------
curve.append(BezTriple.New(p))
for point in curve:
point.handleTypes = [AUTO, AUTO]
point.radius = 1.0
#curve.setType(1) #Bezier curve
if self.closed:
curve.flagU = 5 #1 # Set curve cyclic=close
@ -1392,6 +1400,7 @@ class Polyline: #--------------------------------------------------------------
p0h1 = [p0h1[i]+begtangent[i] for i in range(3)]
curve.__setitem__(0,BezTriple.New(p0h1+p0+p0h2))
curve[0].handleTypes = [FREE, ALIGN] #remi--todo-----
curve[0].radius = 1.0
if endtangent:
#print 'deb:polyline2dCurve.draw curve[-1].vec:', curve[-1].vec #-----
#print 'deb:polyline2dCurve.draw endtangent:', endtangent #-----
@ -1401,6 +1410,7 @@ class Polyline: #--------------------------------------------------------------
curve.__setitem__(-1,BezTriple.New(p0h1+p0+p0h2))
#print 'deb:polyline2dCurve.draw curve[-1].vec:', curve[-1].vec #-----
curve[-1].handleTypes = [ALIGN, FREE] #remi--todo-----
curve[-1].radius = 1.0
@ -1420,13 +1430,16 @@ class Polyline: #--------------------------------------------------------------
if i == 0: curve = pline.appendNurb(BezTriple.New(verts[0]))
else: curve.append(BezTriple.New(verts[0]))
curve[-1].handleTypes = [VECT, VECT] #--todo--calculation of bezier-tangents
curve[-1].radius = 1.0
for p in verts[1:]:
curve.append(BezTriple.New(p))
curve[-1].handleTypes = [AUTO, AUTO]
curve[-1].radius = 1.0
else:
if i == 0: curve = pline.appendNurb(BezTriple.New(point1.loc))
else: curve.append(BezTriple.New(point1.loc))
curve[-1].handleTypes = [VECT, VECT] #--todo--calculation of bezier-tangents
curve[-1].radius = 1.0
elif True: #----- optimised Bezier-Handles calculation --------------------------------
#print 'deb:drawPlineCurve: i:', i #---------
@ -1446,10 +1459,12 @@ class Polyline: #--------------------------------------------------------------
if i == 0: curve = pline.appendNurb(BezTriple.New(VectorTriples[0]))
else: curve.append(BezTriple.New(VectorTriples[0]))
curve[-1].handleTypes = [prevHandleType, FREE]
curve[-1].radius = 1.0
for p in VectorTriples[1:-1]:
curve.append(BezTriple.New(p))
curve[-1].handleTypes = [FREE, FREE]
curve[-1].radius = 1.0
prevHandleVect = VectorTriples[-1][:3]
prevHandleType = FREE
@ -1462,11 +1477,13 @@ class Polyline: #--------------------------------------------------------------
curve.append(BezTriple.New(VectorTriples))
curve[-1].handleTypes = [FREE, VECT]
prevHandleType = VECT
curve[-1].radius = 1.0
else:
if i == 0: curve = pline.appendNurb(BezTriple.New(point1.loc))
else: curve.append(BezTriple.New(point1.loc))
curve[-1].handleTypes = [VECT, VECT]
curve[-1].radius = 1.0
#print 'deb:drawPlineCurve: curve[-1].vec[0]', curve[-1].vec[0] #----------
@ -1486,10 +1503,12 @@ class Polyline: #--------------------------------------------------------------
curve.__setitem__(0,BezTriple.New(p0h1+p0+p0h2))
curve[0].handleTypes = [FREE,prevHandleType2]
curve[0].radius = 1.0
#print 'deb:drawPlineCurve:closed curve[0].vec:', curve[0].vec #----------
#print 'deb:drawPlineCurve:closed curve[0].handleTypes:', curve[0].handleTypes #----------
else:
curve[0].handleTypes[0] = VECT
curve[0].radius = 1.0
else:
curve.flagU = 0 # Set curve not cyclic=open
@ -2177,9 +2196,10 @@ DXF: X value; APP: 3D point, Y and Z values of control points (in WCS) (one entr
self.ctrlpk_len = getit(obj, 73, 0) # Number of control points
self.fit_pk_len = getit(obj, 74, 0) # Number of fit points (if any)
#TODO: import SPLINE as Bezier curve directly, possible?
#print 'deb:Spline self.fit_pk_len=', self.fit_pk_len #------------------------
#self.fit_pk_len = 0 # temp for debug
if self.fit_pk_len and 'spline_as'==5:
if self.fit_pk_len and settings.var['splines_as']==5:
self.spline = False
self.curved = True
else:
@ -2675,6 +2695,7 @@ class Circle: #----------------------------------------------------------------
curve.append(BezTriple.New(p))
for point in curve:
point.handleTypes = [FREE, FREE]
point.radius = 1.0
else: # standard version
c = Curve.New(obname) # create new curve data
p1 = (0, -radius, 0)
@ -2693,6 +2714,7 @@ class Circle: #----------------------------------------------------------------
curve.append(p4)
for point in curve:
point.handleTypes = [AUTO, AUTO]
point.radius = 1.0
curve.flagU = 1 # 1 sets the curve cyclic=closed
if settings.var['fill_on']:
@ -2893,6 +2915,7 @@ class Arc: #-----------------------------------------------------------------
curve.append(BezTriple.New(p))
for point in curve:
point.handleTypes = [FREE, FREE]
point.radius = 1.0
curve.flagU = 0 # 0 sets the curve not cyclic=open
arc.setResolu(settings.var['curve_res'])
@ -3449,6 +3472,7 @@ class Ellipse: #---------------------------------------------------------------
curve.append(BezTriple.New(p))
for point in curve:
point.handleTypes = [FREE, FREE]
point.radius = 1.0
curve.flagU = 1 # 0 sets the curve not cyclic=open
if settings.var['fill_on']:
arc.setFlag(6) # 2+4 set top and button caps
@ -3459,6 +3483,7 @@ class Ellipse: #---------------------------------------------------------------
curve.append(BezTriple.New(p))
for point in curve:
point.handleTypes = [FREE, FREE]
point.radius = 1.0
curve.flagU = 0 # 0 sets the curve not cyclic=open
arc.setResolu(settings.var['curve_res'])
@ -4397,8 +4422,7 @@ def analyzeDXF(dxfFile): #---------------------------------------
Draw.PupMenu('DXF importer: report saved in INF-file:%t|' + '\'%s\'' %infFile)
except:
Draw.PupMenu('DXF importer: ERROR by writing report in INF-file:%t|' + '\'%s\'' %infFile)
finally:
f.close()
#finally: f.close()
@ -4417,7 +4441,8 @@ def main(dxfFile): #---------------#############################-----------
global cur_COUNTER #counter for progress_bar
cur_COUNTER = 0
try:
#try:
if 1:
#print "Getting settings..."
global GUI_A, GUI_B, g_scale_as
if not GUI_A['g_scale_on'].val:
@ -4500,7 +4525,7 @@ def main(dxfFile): #---------------#############################-----------
#settings.write(message)
if UI_MODE: Draw.PupMenu('DXF importer: Done!|finished in %.4f sec.' % time_text)
finally:
#finally:
# restore state even if things didn't work
#print 'deb:drawEntities finally!' #-----------------------
Window.WaitCursor(False)
@ -5190,6 +5215,7 @@ def drawCurveCircle(circle): #--- no more used --------------------------------
curve.append(p4)
for point in curve:
point.handleTypes = [AUTO, AUTO]
point.radius = 1.0
curve.flagU = 1 # Set curve cyclic
c.update()
@ -5231,6 +5257,7 @@ def drawCurveArc(self): #---- only for ELLIPSE --------------------------------
curve.append(p4)
for point in curve:
point.handleTypes = [AUTO, AUTO]
point.radius = 1.0
curve.flagU = 1 # Set curve cyclic
a.update()
@ -5270,12 +5297,12 @@ GUI_B = {} # GUI-buttons dictionary for drawingTypes
# settings default, initialize ------------------------
points_as_menu = "convert to: %t|empty %x1|mesh.vertex %x2|thin sphere %x3|thin box %x4|*curve.vertex %x5"
lines_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
lines_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|thin box %x4|Bezier-curve %x5|*NURBS-curve %x6"
mlines_as_menu = "convert to: %t|*edge %x1|*mesh %x2|*thin cylinder %x3|*thin box %x|*curve %x5"
plines_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|*thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
splines_as_menu = "convert to: %t|mesh %x2|*thin cylinder %x3|*thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
splines_as_menu = "convert to: %t|mesh %x2|*thin cylinder %x3|*thin box %x4|*Bezier-curve %x5|NURBS-curve %x6"
plines3_as_menu = "convert to: %t|*edge %x1|mesh %x2|*thin cylinder %x3|*thin box %x4|Bezier-curve %x5|NURBS-curve %x6"
plmesh_as_menu = "convert to: %t|*edge %x1|mesh %x2|NURBS-surface %x6"
plmesh_as_menu = "convert to: %t|*edge %x1|mesh %x2|*NURBS-surface %x6"
solids_as_menu = "convert to: %t|*edge %x1|mesh %x2"
blocks_as_menu = "convert to: %t|dupliGroup %x1|*real.Group %x2|*exploded %x3"
texts_as_menu = "convert to: %t|text %x1|*mesh %x2|*curve %x5"
@ -5456,11 +5483,9 @@ def saveConfig(): #--todo-----------------------------------------------
else:
#if BPyMessages.Warning_SaveOver(iniFile): #<- remi find it too abstarct
if sys.exists(iniFile):
try:
f = file(iniFile, 'r')
try: header_str = f.readline()
finally: f.close()
except: pass
f = file(iniFile, 'r')
header_str = f.readline()
f.close()
if header_str.startswith(INIFILE_HEADER[0:13]):
if Draw.PupMenu(' OK ? %t|SAVE OVER: ' + '\'%s\'' %iniFile) == 1:
save_ok = True
@ -5480,10 +5505,9 @@ def saveConfig(): #--todo-----------------------------------------------
output_str = '{\n'.join(output_str.split('{'))
try:
f = file(iniFile, 'w')
try:
f.write(INIFILE_HEADER + '\n# this is a comment line\n')
f.write(output_str)
finally: f.close()
f.write(INIFILE_HEADER + '\n# this is a comment line\n')
f.write(output_str)
f.close()
#Draw.PupMenu('DXF importer: INI-file: Done!%t|config-data saved in ' + '\'%s\'' %iniFile)
except:
Draw.PupMenu('DXF importer: INI-file: Error!%t|failure by writing to ' + '\'%s\'|no config-data saved!' %iniFile)
@ -5508,25 +5532,22 @@ def loadConfig(): #remi--todo-----------------------------------------------
update_RegistryKey('iniFileName', iniFile)
#print 'deb:loadConfig iniFile: ', iniFile #----------------------
if iniFile.lower().endswith(INIFILE_EXTENSION) and sys.exists(iniFile):
try:
f = file(iniFile, 'r')
try:
header_str = f.readline()
if header_str.startswith(INIFILE_HEADER):
data_str = f.read()
f.close()
#print 'deb:loadConfig data_str from %s: \n' %iniFile , data_str #-----------------
data = eval(data_str)
for k, v in data[0].iteritems():
try: GUI_A[k].val = v
except: GUI_A[k] = Draw.Create(v)
for k, v in data[1].iteritems():
try: GUI_B[k].val = v
except: GUI_B[k] = Draw.Create(v)
else:
Draw.PupMenu('DXF importer: INI-file: Alert!%t|no valid header in INI-file: ' + '\'%s\'' %iniFile)
finally: f.close()
except: pass
f = file(iniFile, 'r')
header_str = f.readline()
if header_str.startswith(INIFILE_HEADER):
data_str = f.read()
f.close()
#print 'deb:loadConfig data_str from %s: \n' %iniFile , data_str #-----------------
data = eval(data_str)
for k, v in data[0].iteritems():
try: GUI_A[k].val = v
except: GUI_A[k] = Draw.Create(v)
for k, v in data[1].iteritems():
try: GUI_B[k].val = v
except: GUI_B[k] = Draw.Create(v)
else:
f.close()
Draw.PupMenu('DXF importer: INI-file: Alert!%t|no valid header in INI-file: ' + '\'%s\'' %iniFile)
else:
Draw.PupMenu('DXF importer: INI-file: Alert!%t|no valid INI-file selected!')
print "DXF importer: Alert!: no valid INI-file selected."

@ -1351,8 +1351,8 @@ void Mat4ToQuat( float m[][4], float *q)
void QuatOne(float *q)
{
q[0]= q[2]= q[3]= 0.0;
q[1]= 1.0;
q[0]= 1.0;
q[1]= q[2]= q[3]= 0.0;
}
void NormalQuat(float *q)

@ -403,9 +403,14 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf);
*
* @attention defined in imageprocess.c
*/
void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float x, float y, int xout, int yout);
void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
/**
* Change the ordering of the color bytes pointed to by rect from
* rgba to abgr. size * 4 color bytes are reordered.

@ -80,6 +80,17 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
}
}
}
static void pixel_from_buffer(struct ImBuf *ibuf, unsigned char *outI, float *outF, int x, int y)
{
int offset = ibuf->x * y * 4 + 4*x;
if (ibuf->rect)
outI= (unsigned char *)ibuf->rect + offset;
if (ibuf->rect_float)
outF= (float *)ibuf->rect_float + offset;
}
/**************************************************************************
* INTERPOLATIONS
@ -92,32 +103,40 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
/* More info: http://wiki.blender.org/index.php/User:Damiles#Bicubic_pixel_interpolation
*/
/* function assumes out to be zero'ed, only does RGBA */
static float P(float k){
float p1, p2, p3, p4;
p1 = MAX2(k+2.0f,0);
p2 = MAX2(k+1.0f,0);
p3 = MAX2(k,0);
p4 = MAX2(k-1.0f,0);
return (float)(1.0f/6.0f)*( p1*p1*p1 - 4.0f * p2*p2*p2 + 6.0f * p3*p3*p3 - 4.0f * p4*p4*p4);
}
#if 0
/* older, slower function, works the same as above */
static float P(float k){
return (float)(1.0f/6.0f)*( pow( MAX2(k+2.0f,0) , 3.0f ) - 4.0f * pow( MAX2(k+1.0f,0) , 3.0f ) + 6.0f * pow( MAX2(k,0) , 3.0f ) - 4.0f * pow( MAX2(k-1.0f,0) , 3.0f));
}
#endif
void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, int yout)
void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *outF, float u, float v)
{
int i,j,n,m,x1,y1;
unsigned char *dataI,*outI;
float a,b,w,wx,wy[4], outR,outG,outB,outA,*dataF,*outF;
int do_rect, do_float;
unsigned char *dataI;
float a,b,w,wx,wy[4], outR,outG,outB,outA,*dataF;
if (in == NULL) return;
if (in->rect == NULL && in->rect_float == NULL) return;
/* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
do_rect= (out->rect != NULL);
do_float= (out->rect_float != NULL);
i= (int)floor(u);
j= (int)floor(v);
a= u - i;
b= v - j;
i= (int)floor(x);
j= (int)floor(y);
a= x - i;
b= y - j;
outR= 0.0f;
outG= 0.0f;
outB= 0.0f;
outA= 0.0f;
outR = outG = outB = outA = 0.0f;
/* Optimized and not so easy to read */
/* avoid calling multiple times */
wy[0] = P(b-(-1));
@ -137,14 +156,14 @@ void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, in
/* except that would call P() 16 times per pixel therefor pow() 64 times, better precalc these */
w = wx * wy[m+1];
if (do_float) {
if (outF) {
dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
outR+= dataF[0] * w;
outG+= dataF[1] * w;
outB+= dataF[2] * w;
outA+= dataF[3] * w;
}
if (do_rect) {
if (outI) {
dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1;
outR+= dataI[0] * w;
outG+= dataI[1] * w;
@ -155,15 +174,42 @@ void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, in
}
}
}
if (do_rect) {
outI= (unsigned char *)out->rect + out->x * yout * 4 + 4*xout;
/* Done with optimized part */
#if 0
/* older, slower function, works the same as above */
for(n= -1; n<= 2; n++){
for(m= -1; m<= 2; m++){
x1= i+n;
y1= j+m;
if (x1>0 && x1 < in->x && y1>0 && y1<in->y) {
if (do_float) {
dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
outR+= dataF[0] * P(n-a) * P(b-m);
outG+= dataF[1] * P(n-a) * P(b-m);
outB+= dataF[2] * P(n-a) * P(b-m);
outA+= dataF[3] * P(n-a) * P(b-m);
}
if (do_rect) {
dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1;
outR+= dataI[0] * P(n-a) * P(b-m);
outG+= dataI[1] * P(n-a) * P(b-m);
outB+= dataI[2] * P(n-a) * P(b-m);
outA+= dataI[3] * P(n-a) * P(b-m);
}
}
}
}
#endif
if (outI) {
outI[0]= (int)outR;
outI[1]= (int)outG;
outI[2]= (int)outB;
outI[3]= (int)outA;
}
if (do_float) {
outF= (float *)out->rect_float + out->x * yout * 4 + 4*xout;
if (outF) {
outF[0]= outR;
outF[1]= outG;
outF[2]= outB;
@ -171,23 +217,33 @@ void bicubic_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, in
}
}
void bicubic_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
{
unsigned char *outI = NULL;
float *outF = NULL;
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) return;
pixel_from_buffer(out, outI, outF, xout, yout); /* gcc warns these could be uninitialized, but its ok */
bicubic_interpolation_color(in, outI, outF, u, v);
}
/* function assumes out to be zero'ed, only does RGBA */
/* BILINEAR INTERPOLATION */
void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float *outF, float u, float v)
{
float *row1, *row2, *row3, *row4, a, b, *outF;
unsigned char *row1I, *row2I, *row3I, *row4I, *outI;
float *row1, *row2, *row3, *row4, a, b;
unsigned char *row1I, *row2I, *row3I, *row4I;
float a_b, ma_b, a_mb, ma_mb;
float empty[4]= {0.0f, 0.0f, 0.0f, 0.0f};
unsigned char emptyI[4]= {0, 0, 0, 0};
int y1, y2, x1, x2;
int do_rect, do_float;
if (in==NULL) return;
if (in->rect==NULL && in->rect_float==NULL) return;
do_rect= (out->rect != NULL);
do_float= (out->rect_float != NULL);
/* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
x1= (int)floor(u);
x2= (int)ceil(u);
@ -197,16 +253,7 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i
// sample area entirely outside image?
if (x2<0 || x1>in->x-1 || y2<0 || y1>in->y-1) return;
if (do_rect)
outI=(unsigned char *)out->rect + out->x * yout * 4 + 4*xout;
else
outI= NULL;
if (do_float)
outF=(float *)out->rect_float + out->x * yout * 4 + 4*xout;
else
outF= NULL;
if (do_float) {
if (outF) {
// sample including outside of edges of image
if (x1<0 || y1<0) row1= empty;
else row1= (float *)in->rect_float + in->x * y1 * 4 + 4*x1;
@ -229,7 +276,7 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i
outF[2]= ma_mb*row1[2] + a_mb*row3[2] + ma_b*row2[2]+ a_b*row4[2];
outF[3]= ma_mb*row1[3] + a_mb*row3[3] + ma_b*row2[3]+ a_b*row4[3];
}
if (do_rect) {
if (outI) {
// sample including outside of edges of image
if (x1<0 || y1<0) row1I= emptyI;
else row1I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1;
@ -254,45 +301,44 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i
}
}
void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, int yout)
{
unsigned char *outI = NULL;
float *outF = NULL;
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) return;
pixel_from_buffer(out, outI, outF, xout, yout); /* gcc warns these could be uninitialized, but its ok */
bilinear_interpolation_color(in, outI, outF, u, v);
}
/* function assumes out to be zero'ed, only does RGBA */
/* NEAREST INTERPOLATION */
void neareast_interpolation(ImBuf *in, ImBuf *out, float u, float v,int xout, int yout)
void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float *outF, float u, float v)
{
float *outF,*dataF;
unsigned char *dataI,*outI;
float *dataF;
unsigned char *dataI;
int y1, x1;
int do_rect, do_float;
if (in==NULL) return;
if (in->rect==NULL && in->rect_float==NULL) return;
do_rect= (out->rect != NULL);
do_float= (out->rect_float != NULL);
/* ImBuf in must have a valid rect or rect_float, assume this is alredy checked */
x1= (int)(u);
y1= (int)(v);
if (do_rect)
outI=(unsigned char *)out->rect + out->x * yout * 4 + 4*xout;
else
outI= NULL;
if (do_float)
outF=(float *)out->rect_float + out->x * yout * 4 + 4*xout;
else
outF= NULL;
// sample area entirely outside image?
if (x1<0 || x1>in->x-1 || y1<0 || y1>in->y-1) return;
// sample including outside of edges of image
if (x1<0 || y1<0) {
if (do_rect) {
if (outI) {
outI[0]= 0;
outI[1]= 0;
outI[2]= 0;
outI[3]= 0;
}
if (do_float) {
if (outF) {
outF[0]= 0.0f;
outF[1]= 0.0f;
outF[2]= 0.0f;
@ -300,14 +346,14 @@ void neareast_interpolation(ImBuf *in, ImBuf *out, float u, float v,int xout, in
}
} else {
dataI= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1;
if (do_rect) {
if (outI) {
outI[0]= dataI[0];
outI[1]= dataI[1];
outI[2]= dataI[2];
outI[3]= dataI[3];
}
dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
if (do_float) {
if (outF) {
outF[0]= dataF[0];
outF[1]= dataF[1];
outF[2]= dataF[2];
@ -315,3 +361,16 @@ void neareast_interpolation(ImBuf *in, ImBuf *out, float u, float v,int xout, in
}
}
}
void neareast_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, int yout)
{
unsigned char *outI = NULL;
float *outF = NULL;
if (in == NULL || (in->rect == NULL && in->rect_float == NULL)) return;
pixel_from_buffer(out, outI, outF, xout, yout); /* gcc warns these could be uninitialized, but its ok */
neareast_interpolation_color(in, outI, outF, x, y);
}

@ -36,7 +36,7 @@ if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
targetdir = '#'+targetdir
makesdna_tool.Append (LIBPATH = targetdir)
if env['BF_PROFILE']:
makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_LINKFLAGS'])
targetdir = root_build_dir + '/makesdna'

@ -410,7 +410,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas)
if(canvaswidth != canvas->GetWidth() || canvasheight != canvas->GetHeight())
{
UpdateOffsetMatrix(canvas);
UpdateCanvasTextureCoord(viewport);
UpdateCanvasTextureCoord((unsigned int*)viewport);
need_tex_update = true;
}

@ -190,7 +190,7 @@ def setup_syslibs(lenv):
if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw','linuxcross'):
syslibs += Split(lenv['BF_PTHREADS_LIB'])
syslibs += Split(lenv['LLIBS'])
syslibs += lenv['LLIBS']
return syslibs
@ -476,7 +476,7 @@ class BlenderEnvironment(SConsEnvironment):
lenv.Append(LINKFLAGS = lenv['BF_PYTHON_LINKFLAGS'])
lenv.Append(LINKFLAGS = lenv['BF_OPENGL_LINKFLAGS'])
if lenv['BF_PROFILE']:
lenv.Append(LINKFLAGS = lenv['BF_PROFILE_FLAGS'])
lenv.Append(LINKFLAGS = lenv['BF_PROFILE_LINKFLAGS'])
lenv.Append(CPPPATH=includes)
if root_build_dir[0]==os.sep or root_build_dir[1]==':':
lenv.Append(LIBPATH=root_build_dir + '/lib')

@ -19,13 +19,15 @@ BoolVariable = SCons.Variables.BoolVariable
def print_arguments(args, bc):
if len(args):
for k,v in args.iteritems():
if type(v)==list:
v = ' '.join(v)
print '\t'+bc.OKBLUE+k+bc.ENDC+' = '+bc.OKGREEN + v + bc.ENDC
else:
print '\t'+bc.WARNING+'No command-line arguments given'+bc.ENDC
def validate_arguments(args, bc):
opts_list = [
'WITH_BF_PYTHON', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'BF_PYTHON_LINKFLAGS', 'WITH_BF_STATICPYTHON', 'BF_PYTHON_LIB_STATIC',
'WITH_BF_PYTHON', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'WITH_BF_STATICPYTHON', 'BF_PYTHON_LIB_STATIC',
'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH', 'WITH_BF_STATICOPENAL', 'BF_OPENAL_LIB_STATIC',
'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH',
'BF_PTHREADS', 'BF_PTHREADS_INC', 'BF_PTHREADS_LIB', 'BF_PTHREADS_LIBPATH',
@ -47,17 +49,11 @@ def validate_arguments(args, bc):
'WITH_BF_YAFRAY',
'WITH_BF_FREETYPE', 'BF_FREETYPE', 'BF_FREETYPE_INC', 'BF_FREETYPE_LIB', 'BF_FREETYPE_LIBPATH',
'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC', 'BF_OPENGL_LINKFLAGS',
'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC',
'WITH_BF_FTGL', 'BF_FTGL', 'BF_FTGL_INC', 'BF_FTGL_LIB',
'WITH_BF_PLAYER',
'WITH_BF_NOBLENDER',
'WITH_BF_BINRELOC',
'CFLAGS', 'CCFLAGS', 'CXXFLAGS', 'CPPFLAGS',
'REL_CFLAGS', 'REL_CCFLAGS', 'REL_CXXFLAGS',
'BF_PROFILE_FLAGS', 'BF_PROFILE_FLAGS', 'BF_PROFILE_CXXFLAGS',
'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS',
'C_WARN', 'CC_WARN', 'CXX_WARN',
'LLIBS', 'PLATFORM_LINKFLAGS',
'LCGDIR',
'BF_CXX', 'WITH_BF_STATICCXX', 'BF_CXX_LIB_STATIC',
'WITH_BF_VERSE', 'BF_VERSE_INCLUDE',
@ -72,7 +68,20 @@ def validate_arguments(args, bc):
'WITH_BF_DOCS',
'BF_NUMJOBS',
]
# Have options here that scons expects to be lists
opts_list_split = [
'BF_PYTHON_LINKFLAGS',
'BF_OPENGL_LINKFLAGS',
'CFLAGS', 'CCFLAGS', 'CXXFLAGS', 'CPPFLAGS',
'REL_CFLAGS', 'REL_CCFLAGS', 'REL_CXXFLAGS',
'BF_PROFILE_CFLAGS', 'BF_PROFILE_CCFLAGS', 'BF_PROFILE_CXXFLAGS', 'BF_PROFILE_LINKFLAGS',
'BF_DEBUG_CFLAGS', 'BF_DEBUG_CCFLAGS', 'BF_DEBUG_CXXFLAGS',
'C_WARN', 'CC_WARN', 'CXX_WARN',
'LLIBS', 'PLATFORM_LINKFLAGS',
]
arg_list = ['BF_DEBUG', 'BF_QUIET', 'BF_CROSS', 'BF_UPDATE',
'BF_INSTALLDIR', 'BF_TOOLSET', 'BF_BINNAME',
'BF_BUILDDIR', 'BF_FANCY', 'BF_QUICK', 'BF_PROFILE',
@ -81,12 +90,13 @@ def validate_arguments(args, bc):
'BF_LISTDEBUG', 'LCGDIR', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG',
'BF_DOCDIR']
all_list = opts_list + arg_list
okdict = {}
for k,v in args.iteritems():
if k in all_list:
if (k in opts_list) or (k in arg_list):
okdict[k] = v
elif k in opts_list_split:
okdict[k] = v.split() # "" have alredy been stripped
else:
print '\t'+bc.WARNING+'Invalid argument: '+bc.ENDC+k+'='+v
@ -340,6 +350,7 @@ def read_opts(cfg, args):
('BF_PROFILE_CFLAGS', 'C only profiling flags', ''),
('BF_PROFILE_CCFLAGS', 'C and C++ profiling flags', ''),
('BF_PROFILE_CXXFLAGS', 'C++ only profiling flags', ''),
('BF_PROFILE_LINKFLAGS', 'Profile linkflags', ''),
(BoolVariable('BF_DEBUG', 'Add debug flags if true', False)),
('BF_DEBUG_CFLAGS', 'C only debug flags', ''),