This commit is contained in:
Daniel Genrich 2008-01-02 14:36:46 +00:00
commit a9c36825aa
178 changed files with 11739 additions and 6662 deletions

@ -170,6 +170,9 @@ else:
opts = btools.read_opts(optfiles, B.arguments)
opts.Update(env)
if not env['BF_FANCY']:
B.bc.disable()
# disable elbeem (fluidsim) compilation?
if env['BF_NO_ELBEEM'] == 1:
env['CPPFLAGS'].append('-DDISABLE_ELBEEM')

@ -18,7 +18,7 @@ BF_OPENAL_LIB = 'openal_static'
BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
WITH_BF_FFMPEG = 'false'
BF_FFMPEG_LIB = 'avformat avutil avcodec'
BF_FFMPEG_LIB = 'avformat swscale avcodec avutil xvidcore x264'
BF_FFMPEG_LIBPATH = LIBDIR + '/gcc/ffmpeg/lib'
BF_FFMPEG_INC = LIBDIR + '/gcc/ffmpeg/include'

@ -54,5 +54,5 @@ install: all debug
ifeq ($(OS),darwin)
ranlib $(NAN_VERSE)/lib/libverse.a
endif
$(CCC) $(LDFLAGS) -o $(DIR)/verse$(EXT) $(DIR)/libverse.a $(LIBS) $(SLIBS) $(LLIBS) $(DADD) $(LOPTS)
$(CCC) $(CCFLAGS) $(LDFLAGS) -o $(DIR)/verse$(EXT) $(DIR)/libverse.a $(LIBS) $(SLIBS) $(LLIBS) $(DADD) $(LOPTS)
@$(CP) $(DIR)/verse$(EXT) $(OCGDIR)/bin

@ -333,6 +333,7 @@ void *MEM_mapallocN(unsigned int len, const char *str)
}
/* Prints in python syntax for easy */
void MEM_printmemlist()
{
MemHead *membl;
@ -341,13 +342,33 @@ void MEM_printmemlist()
membl = membase->first;
if (membl) membl = MEMNEXT(membl);
print_error("# membase_debug.py\n");
print_error("membase = [\\\n");
while(membl) {
print_error("%s len: %d %p\n",membl->name,membl->len, membl+1);
fprintf(stderr, "{'len':%i, 'name':'''%s''', 'pointer':'%p'},\\\n", membl->len, membl->name, membl+1);
if(membl->next)
membl= MEMNEXT(membl->next);
else break;
}
fprintf(stderr, "]\n\n");
fprintf(stderr,
"mb_userinfo = {}\n"
"totmem = 0\n"
"for mb_item in membase:\n"
"\tmb_item_user_size = mb_userinfo.setdefault(mb_item['name'], [0,0])\n"
"\tmb_item_user_size[0] += 1 # Add a user\n"
"\tmb_item_user_size[1] += mb_item['len'] # Increment the size\n"
"\ttotmem += mb_item['len']\n"
"print '(membase) items:', len(membase), '| unique-names:', len(mb_userinfo), '| total-mem:', totmem\n"
"mb_userinfo_sort = mb_userinfo.items()\n"
"for sort_name, sort_func in (('size', lambda a: -a[1][1]), ('users', lambda a: -a[1][0]), ('name', lambda a: a[0])):\n"
"\tprint '\\nSorting by:', sort_name\n"
"\tmb_userinfo_sort.sort(key = sort_func)\n"
"\tfor item in mb_userinfo_sort:\n"
"\t\tprint 'name:%%s, users:%%i, len:%%i' %% (item[0], item[1][0], item[1][1])\n"
);
mem_unlock_thread();
}

@ -422,6 +422,12 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\modifier.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\multires-firstlevel.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\multires.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\nla.c">
</File>
@ -615,6 +621,9 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_modifier.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_multires.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_nla.h">
</File>

@ -358,6 +358,9 @@
<File
RelativePath="..\..\..\source\blender\blenlib\intern\boxpack2d.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenlib\intern\bpath.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenlib\intern\dynlib.c">
</File>
@ -428,6 +431,9 @@
<File
RelativePath="..\..\..\source\blender\blenlib\BLI_boxpack2d.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenlib\BLI_bpath.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenlib\intern\BLI_callbacks.h">
</File>

@ -439,9 +439,6 @@
<File
RelativePath="..\..\..\source\blender\src\meshtools.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\multires-firstlevel.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\multires.c">
</File>
@ -463,6 +460,9 @@
<File
RelativePath="..\..\..\source\blender\blenpluginapi\intern\pluginapi.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\poselib.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\poseobject.c">
</File>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 64 KiB

@ -1,167 +0,0 @@
#!BPY
"""
Name: 'Fix Broken Paths'
Blender: 242
Group: 'Image'
Tooltip: 'Search for new image paths to make relative links to'
"""
__author__ = "Campbell Barton AKA Ideasman"
__url__ = ["blenderartist.org"]
__bpydoc__ = """\
Find image target paths
This script searches for images whos
file paths do not point to an existing image file,
all image paths are made relative where possible.
usefull when moving projects between computers, when absolute paths links are broken.
"""
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Campbell J Barton
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
from Blender import *
try:
import os
except:
Draw.PupMenu('You need a full python install to use this script')
os= None
#==============================================#
# Strips the slashes from the back of a string #
#==============================================#
def stripPath(path):
return path.split('/')[-1].split('\\')[-1]
# finds the file starting at the root.
def findImage(findRoot, imagePath):
newImageFile = None
imageFile = imagePath.split('/')[-1].split('\\')[-1]
# ROOT, DIRS, FILES
pathWalk = os.walk(findRoot)
pathList = [True]
matchList = [] # Store a list of (match, size), choose the biggest.
while True:
try:
pathList = pathWalk.next()
except:
break
for file in pathList[2]:
# FOUND A MATCH
if file.lower() == imageFile.lower():
name = pathList[0] + sys.sep + file
try:
size = os.path.getsize(name)
except:
size = 0
if size:
print ' found:', name
matchList.append( (name, size) )
if matchList == []:
print 'no match for:', imageFile
return None
else:
# Sort by file size
matchList.sort(lambda A, B: cmp(B[1], A[1]) )
print 'using:', matchList[0][0]
# First item is the largest
return matchList[0][0] # 0 - first, 0 - pathname
# Makes the pathe relative to the blend file path.
def makeRelative(path, blendBasePath):
if path.startswith(blendBasePath):
path = path.replace(blendBasePath, '//')
path = path.replace('//\\', '//')
return path
def find_images(findRoot):
print findRoot
# findRoot = Draw.PupStrInput ('find in: ', '', 100)
if findRoot == '':
Draw.PupMenu('No Directory Selected')
return
# Account for //
findRoot = sys.expandpath(findRoot)
# Strip filename
while findRoot[-1] != '/' and findRoot[-1] != '\\':
findRoot = findRoot[:-1]
if not findRoot.endswith(sys.sep):
findRoot += sys.sep
if findRoot != '/' and not sys.exists(findRoot[:-1]):
Draw.PupMenu('Directory Dosent Exist')
blendBasePath = sys.expandpath('//')
Window.WaitCursor(1)
# ============ DIR DONE\
images = Image.Get()
len_images = float(len(images))
for idx, i in enumerate(images):
progress = idx / len_images
Window.DrawProgressBar(progress, 'searching for images')
# If files not there?
if not sys.exists(sys.expandpath(i.filename )):
newImageFile = findImage(findRoot, i.filename)
if newImageFile != None:
newImageFile= makeRelative(newImageFile, blendBasePath)
print 'newpath relink:', newImageFile
i.filename = newImageFile
i.reload()
else:
# Exists
newImageFile= makeRelative(i.filename, blendBasePath)
if newImageFile!=i.filename:
print 'newpath relative:', newImageFile
i.filename = newImageFile
Window.RedrawAll()
Window.DrawProgressBar(1.0, '')
Window.WaitCursor(0)
if __name__ == '__main__' and os:
Window.FileSelector(find_images, 'SEARCH ROOT DIR', sys.expandpath('//'))

@ -542,6 +542,9 @@ def get_float_func(filepath):
return lambda f: float(f.replace(',', '.'))
elif '.' in line:
return float
# incase all vert values were ints
return float
def load_obj(filepath, CLAMP_SIZE= 0.0, CREATE_FGONS= True, CREATE_SMOOTH_GROUPS= True, CREATE_EDGES= True, SPLIT_OBJECTS= True, SPLIT_GROUPS= True, SPLIT_MATERIALS= True, IMAGE_SEARCH=True):
'''

@ -190,6 +190,7 @@ void AVI_set_debug (int mode) {
AVI_DEBUG= mode;
}
/*
int AVI_is_avi (char *name) {
FILE *fp;
int ret;
@ -209,6 +210,195 @@ int AVI_is_avi (char *name) {
fclose(fp);
return ret;
}
*/
int AVI_is_avi (char *name) {
int temp, fcca, j;
AviMovie movie;
AviMainHeader header;
AviBitmapInfoHeader bheader;
DEBUG("opening movie\n");
memset(&movie, 0, sizeof(AviMovie));
movie.type = AVI_MOVIE_READ;
movie.fp = fopen (name, "rb");
movie.offset_table = NULL;
if (movie.fp == NULL)
return 0;
if (GET_FCC (movie.fp) != FCC("RIFF") ||
!(movie.size = GET_FCC (movie.fp))) {
fclose(movie.fp);
return 0;
}
movie.header = &header;
if (GET_FCC (movie.fp) != FCC("AVI ") ||
GET_FCC (movie.fp) != FCC("LIST") ||
!GET_FCC (movie.fp) ||
GET_FCC (movie.fp) != FCC("hdrl") ||
(movie.header->fcc = GET_FCC (movie.fp)) != FCC("avih") ||
!(movie.header->size = GET_FCC (movie.fp))) {
DEBUG("bad initial header info\n");
fclose(movie.fp);
return 0;
}
movie.header->MicroSecPerFrame = GET_FCC(movie.fp);
movie.header->MaxBytesPerSec = GET_FCC(movie.fp);
movie.header->PaddingGranularity = GET_FCC(movie.fp);
movie.header->Flags = GET_FCC(movie.fp);
movie.header->TotalFrames = GET_FCC(movie.fp);
movie.header->InitialFrames = GET_FCC(movie.fp);
movie.header->Streams = GET_FCC(movie.fp);
movie.header->SuggestedBufferSize = GET_FCC(movie.fp);
movie.header->Width = GET_FCC(movie.fp);
movie.header->Height = GET_FCC(movie.fp);
movie.header->Reserved[0] = GET_FCC(movie.fp);
movie.header->Reserved[1] = GET_FCC(movie.fp);
movie.header->Reserved[2] = GET_FCC(movie.fp);
movie.header->Reserved[3] = GET_FCC(movie.fp);
fseek (movie.fp, movie.header->size-14*4, SEEK_CUR);
if (movie.header->Streams < 1) {
DEBUG("streams less than 1\n");
fclose(movie.fp);
return 0;
}
movie.streams = (AviStreamRec *) MEM_callocN (sizeof(AviStreamRec) * movie.header->Streams, "moviestreams");
for (temp=0; temp < movie.header->Streams; temp++) {
if (GET_FCC(movie.fp) != FCC("LIST") ||
!GET_FCC (movie.fp) ||
GET_FCC (movie.fp) != FCC ("strl") ||
(movie.streams[temp].sh.fcc = GET_FCC (movie.fp)) != FCC ("strh") ||
!(movie.streams[temp].sh.size = GET_FCC (movie.fp))) {
DEBUG("bad stream header information\n");
MEM_freeN(movie.streams);
fclose(movie.fp);
return 0;
}
movie.streams[temp].sh.Type = GET_FCC (movie.fp);
movie.streams[temp].sh.Handler = GET_FCC (movie.fp);
fcca = movie.streams[temp].sh.Handler;
if (movie.streams[temp].sh.Type == FCC("vids")) {
if (fcca == FCC ("DIB ") ||
fcca == FCC ("RGB ") ||
fcca == FCC ("rgb ") ||
fcca == FCC ("RAW ") ||
fcca == 0) {
movie.streams[temp].format = AVI_FORMAT_AVI_RGB;
} else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) {
movie.streams[temp].format = AVI_FORMAT_MJPEG;
} else {
MEM_freeN(movie.streams);
fclose(movie.fp);
return 0;
}
}
movie.streams[temp].sh.Flags = GET_FCC (movie.fp);
movie.streams[temp].sh.Priority = GET_TCC (movie.fp);
movie.streams[temp].sh.Language = GET_TCC (movie.fp);
movie.streams[temp].sh.InitialFrames = GET_FCC (movie.fp);
movie.streams[temp].sh.Scale = GET_FCC (movie.fp);
movie.streams[temp].sh.Rate = GET_FCC (movie.fp);
movie.streams[temp].sh.Start = GET_FCC (movie.fp);
movie.streams[temp].sh.Length = GET_FCC (movie.fp);
movie.streams[temp].sh.SuggestedBufferSize = GET_FCC (movie.fp);
movie.streams[temp].sh.Quality = GET_FCC (movie.fp);
movie.streams[temp].sh.SampleSize = GET_FCC (movie.fp);
movie.streams[temp].sh.left = GET_TCC (movie.fp);
movie.streams[temp].sh.top = GET_TCC (movie.fp);
movie.streams[temp].sh.right = GET_TCC (movie.fp);
movie.streams[temp].sh.bottom = GET_TCC (movie.fp);
fseek (movie.fp, movie.streams[temp].sh.size-14*4, SEEK_CUR);
if (GET_FCC (movie.fp) != FCC("strf")) {
DEBUG("no stream format information\n");
MEM_freeN(movie.streams);
fclose(movie.fp);
return 0;
}
movie.streams[temp].sf_size= GET_FCC(movie.fp);
if (movie.streams[temp].sh.Type == FCC("vids")) {
j = movie.streams[temp].sf_size - (sizeof(AviBitmapInfoHeader) - 8);
if (j >= 0) {
AviBitmapInfoHeader *bi;
movie.streams[temp].sf= &bheader;
bi= (AviBitmapInfoHeader *) movie.streams[temp].sf;
bi->fcc= FCC("strf");
bi->size= movie.streams[temp].sf_size;
bi->Size= GET_FCC(movie.fp);
bi->Width= GET_FCC(movie.fp);
bi->Height= GET_FCC(movie.fp);
bi->Planes= GET_TCC(movie.fp);
bi->BitCount= GET_TCC(movie.fp);
bi->Compression= GET_FCC(movie.fp);
bi->SizeImage= GET_FCC(movie.fp);
bi->XPelsPerMeter= GET_FCC(movie.fp);
bi->YPelsPerMeter= GET_FCC(movie.fp);
bi->ClrUsed= GET_FCC(movie.fp);
bi->ClrImportant= GET_FCC(movie.fp);
fcca = bi->Compression;
if ( movie.streams[temp].format ==
AVI_FORMAT_AVI_RGB) {
if (fcca == FCC ("DIB ") ||
fcca == FCC ("RGB ") ||
fcca == FCC ("rgb ") ||
fcca == FCC ("RAW ") ||
fcca == 0 ) {
} else if ( fcca == FCC ("mjpg") ||
fcca == FCC ("MJPG")) {
movie.streams[temp].format = AVI_FORMAT_MJPEG;
} else {
MEM_freeN(movie.streams);
fclose(movie.fp);
return 0;
}
}
}
if (j > 0) fseek (movie.fp, j, SEEK_CUR);
} else fseek (movie.fp, movie.streams[temp].sf_size, SEEK_CUR);
/* Walk to the next LIST */
while (GET_FCC (movie.fp) != FCC("LIST")) {
temp= GET_FCC (movie.fp);
if (temp<0 || ftell(movie.fp) > movie.size) {
DEBUG("incorrect size in header or error in AVI\n");
MEM_freeN(movie.streams);
fclose(movie.fp);
return 0;
}
fseek(movie.fp, temp, SEEK_CUR);
}
fseek(movie.fp, -4L, SEEK_CUR);
}
MEM_freeN(movie.streams);
fclose(movie.fp);
return 1;
}
AviError AVI_open_movie (char *name, AviMovie *movie) {
int temp, fcca, size, j;

@ -207,19 +207,6 @@ void post_layer_create(struct VLayer *vlayer);
void post_layer_destroy(struct VLayer *vlayer);
void post_server_add(void);
/* multires.c */
struct Multires;
struct MultiresLevel;
struct MultiresLevel *multires_level_n(struct Multires *mr, int n);
void multires_free(struct Multires *mr);
void multires_set_level(struct Object *ob, struct Mesh *me, const int render);
void multires_update_levels(struct Mesh *me, const int render);
void multires_calc_level_maps(struct MultiresLevel *lvl);
struct Multires *multires_copy(struct Multires *orig);
/* sculptmode.c */
void sculptmode_free_all(struct Scene *sce);
void sculptmode_init(struct Scene *sce);
/* zbuf.c */
void antialias_tagbuf(int xsize, int ysize, char *rectmove);

@ -114,7 +114,7 @@ struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser);
struct Image *BKE_add_image_file(const char *name);
/* adds image, adds ibuf, generates color or pattern */
struct Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid, float color[4]);
struct Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4]);
/* for reload, refresh, pack */
void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal);

@ -95,7 +95,7 @@ void do_ipo_nocalc(struct Ipo *ipo);
void do_ipo(struct Ipo *ipo);
void do_mat_ipo(struct Material *ma);
void do_ob_ipo(struct Object *ob);
void do_seq_ipo(struct Sequence *seq);
void do_seq_ipo(struct Sequence *seq, int cfra);
void do_ob_ipodrivers(struct Object *ob, struct Ipo *ipo, float ctime);
int has_ipo_code(struct Ipo *ipo, int code);

@ -111,6 +111,11 @@ UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned
UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v);
void free_uv_vert_map(UvVertMap *vmap);
/* Partial Mesh Visibility */
struct PartialVisibility *mesh_pmv_copy(struct PartialVisibility *);
void mesh_pmv_free(struct PartialVisibility *);
void mesh_pmv_revert(struct Object *ob, struct Mesh *me);
void mesh_pmv_off(struct Object *ob, struct Mesh *me);
/* functions for making menu's from customdata layers */
int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to work out how many chars to allocate */

@ -0,0 +1,68 @@
/*
* $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) 2007 by Nicholas Bishop
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
struct CustomData;
struct EditMesh;
struct Multires;
struct MultiresLevel;
struct Mesh;
struct Object;
/* Level access */
struct MultiresLevel *current_level(struct Multires *mr);
struct MultiresLevel *multires_level_n(struct Multires *mr, int n);
/* Level control */
void multires_add_level(struct Object *ob, struct Mesh *me, const char subdiv_type);
void multires_set_level(struct Object *ob, struct Mesh *me, const int render);
void multires_free_level(struct MultiresLevel *lvl);
void multires_edge_level_update(struct Object *ob, struct Mesh *me);
void multires_free(struct Multires *mr);
struct Multires *multires_copy(struct Multires *orig);
void multires_create(struct Object *ob, struct Mesh *me);
/* CustomData */
void multires_delete_layer(struct Mesh *me, struct CustomData *cd, const int type, int n);
void multires_add_layer(struct Mesh *me, struct CustomData *cd, const int type, const int n);
void multires_del_lower_customdata(struct Multires *mr, struct MultiresLevel *cr_lvl);
void multires_to_mcol(struct MultiresColFace *f, MCol mcol[4]);
/* After adding or removing vcolor layers, run this */
void multires_load_cols(struct Mesh *me);
/* Private (used in multires-firstlevel.c) */
void multires_level_to_mesh(struct Object *ob, struct Mesh *me, const int render);
void multires_update_levels(struct Mesh *me, const int render);
void multires_update_first_level(struct Mesh *me, struct EditMesh *em);
void multires_update_customdata(struct MultiresLevel *lvl1, struct CustomData *src,
struct CustomData *dst, const int type);
void multires_customdata_to_mesh(struct Mesh *me, struct EditMesh *em,
struct MultiresLevel *lvl, struct CustomData *src,
struct CustomData *dst, const int type);

@ -143,6 +143,7 @@ void nodeVerifyType(struct bNodeTree *ntree, struct bNode *node);
void nodeAddToPreview(struct bNode *, float *, int, int);
void nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
struct bNode *nodeAddNodeType(struct bNodeTree *ntree, int type, struct bNodeTree *ngroup);
void nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node);
@ -150,6 +151,8 @@ struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node);
struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
int nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **nodep, int *sockindex);
struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
int nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
@ -303,6 +306,8 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str
#define CMP_NODE_INVERT 251
#define CMP_NODE_NORMALIZE 252
#define CMP_NODE_CROP 253
#define CMP_NODE_DBLUR 254
#define CMP_NODE_BILATERALBLUR 255
#define CMP_NODE_GLARE 301
#define CMP_NODE_TONEMAP 302

@ -112,8 +112,8 @@ typedef struct ParticleSeam{
typedef struct ParticleCacheKey{
float co[3];
float vel[3];
float rot[4];
float col[3];
float rot[4];
int steps;
} ParticleCacheKey;
@ -165,7 +165,7 @@ typedef struct ParticleThreadContext {
float *jit, *jitoff, *weight;
float maxweight;
int *index, jitlevel;
int *index, *skip, jitlevel;
int from, cfrom, distr;
@ -214,8 +214,10 @@ void free_hair(struct ParticleSystem *psys);
void free_keyed_keys(struct ParticleSystem *psys);
void psys_free(struct Object * ob, struct ParticleSystem * psys);
void psys_particles_to_render_backup(struct Object *ob, struct ParticleSystem *psys);
void psys_render_backup_to_particles(struct Object *ob, struct ParticleSystem *psys);
void psys_render_set(struct Object *ob, struct ParticleSystem *psys, float viewmat[][4], float winmat[][4], int winx, int winy);
void psys_render_restore(struct Object *ob, struct ParticleSystem *psys);
int psys_render_simplify_distribution(struct ParticleThreadContext *ctx, int tot);
int psys_render_simplify_params(struct ParticleSystem *psys, struct ChildParticle *cpa, float *params);
void clear_particles_from_cache(struct Object *ob, struct ParticleSystem *psys, int cfra);
//void psys_remove_from_particle_list(struct Object *ob, short nbr, struct ParticleSystem *psys);

@ -34,11 +34,13 @@
#ifndef BKE_SCENE_H
#define BKE_SCENE_H
struct bglMats;
struct Scene;
struct Object;
struct Base;
struct AviCodecData;
struct QuicktimeCodecData;
struct SculptData;
/* sequence related defines */
#define WHILE_SEQ(base) { \

@ -0,0 +1,93 @@
/*
* $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) 2007 by Nicholas Bishop
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BKE_SCULPT_H
#define BKE_SCULPT_H
struct NumInput;
struct Scene;
struct SculptData;
struct SculptSession;
typedef enum PropsetMode {
PropsetNone = 0,
PropsetSize,
PropsetStrength,
PropsetTexRot
} PropsetMode;
typedef struct PropsetData {
PropsetMode mode;
unsigned int tex;
short origloc[2];
float *texdata;
short origsize;
char origstrength;
float origtexrot;
struct NumInput *num;
} PropsetData;
typedef struct SculptSession {
struct ProjVert *projverts;
struct bglMats *mats;
/* An array of lists; array is sized as
large as the number of verts in the mesh,
the list for each vert contains the index
for all the faces that use that vertex */
struct ListBase *vertex_users;
struct IndexNode *vertex_users_mem;
int vertex_users_size;
/* Used temporarily per-stroke */
float *vertexcosnos;
ListBase damaged_rects;
ListBase damaged_verts;
/* Used to cache the render of the active texture */
unsigned int texcache_w, texcache_h, *texcache;
struct PropsetData *propset;
/* For rotating around a pivot point */
vec3f pivot;
struct SculptStroke *stroke;
} SculptSession;
void sculptdata_init(struct Scene *sce);
void sculptdata_free(struct Scene *sce);
void sculptsession_free(struct Scene *sce);
void sculpt_vertexusers_free(struct SculptSession *ss);
void sculpt_reset_curve(struct SculptData *sd);
#endif

@ -101,6 +101,8 @@
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
#define AVG2(x, y) ( 0.5 * ((x) + (y)) )
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
#define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);}
#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}

@ -310,15 +310,6 @@ void post_geometry_free_constraint(struct VNode *vnode) {}
void post_layer_create(struct VLayer *vlayer) {}
void post_layer_destroy(struct VLayer *vlayer) {}
void post_server_add(void) {}
/* Multires/sculpt stubs */
struct MultiresLevel *multires_level_n(struct Multires *mr, int n) {return NULL;}
void multires_free(struct Multires *mr) {}
void multires_set_level(struct Object *ob, struct Mesh *me, const int render) {}
void multires_update_levels(struct Mesh *me, const int render) {}
void multires_calc_level_maps(struct MultiresLevel *lvl) {}
struct Multires *multires_copy(struct Multires *orig) {return NULL;}
void sculptmode_init(struct Scene *sce) {}
void sculptmode_free_all(struct Scene *sce) {}
/* zbuf.c stub */
void antialias_tagbuf(int xsize, int ysize, char *rectmove) {}

@ -74,6 +74,7 @@
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BKE_object.h"
#include "BKE_subsurf.h"
#include "BKE_texture.h"
@ -87,8 +88,6 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "multires.h"
// headers for fluidsim bobj meshes
#include <stdlib.h>
#include "LBM_fluidsim.h"
@ -2598,7 +2597,8 @@ float *multires_render_pin(Object *ob, Mesh *me, int *orig_lvl)
}
/* Propagate the changes to render level - fails if mesh topology changed */
void multires_render_final(Object *ob, Mesh *me, DerivedMesh **dm, float *vert_copy, const int orig_lvl)
void multires_render_final(Object *ob, Mesh *me, DerivedMesh **dm, float *vert_copy,
const int orig_lvl, CustomDataMask dataMask)
{
if(me->mr) {
if((*dm)->getNumVerts(*dm) == me->totvert &&
@ -2619,6 +2619,9 @@ void multires_render_final(Object *ob, Mesh *me, DerivedMesh **dm, float *vert_c
(*dm)= CDDM_copy(old);
old->release(old);
if(dataMask & CD_MASK_ORCO)
add_orco_dm(ob, *dm, NULL);
/* Restore the original verts */
me->mr->newlvl= BLI_countlist(&me->mr->levels);
multires_set_level(ob, me, 1);
@ -2646,7 +2649,7 @@ DerivedMesh *mesh_create_derived_render(Object *ob, CustomDataMask dataMask)
vert_copy= multires_render_pin(ob, me, &orig_lvl);
mesh_calc_modifiers(ob, NULL, NULL, &final, 1, 1, 0, dataMask);
multires_render_final(ob, me, &final, vert_copy, orig_lvl);
multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask);
return final;
}
@ -2681,7 +2684,7 @@ DerivedMesh *mesh_create_derived_no_deform_render(Object *ob,
vert_copy= multires_render_pin(ob, me, &orig_lvl);
mesh_calc_modifiers(ob, vertCos, NULL, &final, 1, 0, 0, dataMask);
multires_render_final(ob, me, &final, vert_copy, orig_lvl);
multires_render_final(ob, me, &final, vert_copy, orig_lvl, dataMask);
return final;
}

@ -177,6 +177,10 @@ void free_action (bAction *act)
if (act->chanbase.first)
BLI_freelistN(&act->chanbase);
/* Free pose-references */
if (act->markers.first)
BLI_freelistN(&act->markers);
}
bAction *copy_action (bAction *src)
@ -188,6 +192,7 @@ bAction *copy_action (bAction *src)
dst= copy_libblock(src);
duplicatelist(&(dst->chanbase), &(src->chanbase));
duplicatelist(&(dst->markers), &(src->markers));
for (dchan=dst->chanbase.first, schan=src->chanbase.first; dchan; dchan=dchan->next, schan=schan->next){
dchan->ipo = copy_ipo(dchan->ipo);

@ -74,6 +74,10 @@
#include <config.h>
#endif
#define MAX_DUPLI_RECUR 4
static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist, float (*par_space_mat)[][4], int level);
void free_path(Path *path)
{
if(path->data) MEM_freeN(path->data);
@ -306,7 +310,7 @@ static void group_duplilist(ListBase *lb, Object *ob, int level)
group= ob->dup_group;
/* simple preventing of too deep nested groups */
if(level>4) return;
if(level>MAX_DUPLI_RECUR) return;
/* handles animated groups, and */
/* we need to check update for objects that are not in scene... */
@ -315,25 +319,29 @@ static void group_duplilist(ListBase *lb, Object *ob, int level)
for(go= group->gobject.first; go; go= go->next) {
/* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */
if(go->ob!=ob) {
Mat4MulMat4(mat, go->ob->obmat, ob->obmat);
dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0);
dob->no_draw= (dob->origlay & group->layer)==0;
if(go->ob->dup_group && (go->ob->transflag & OB_DUPLIGROUP)) {
if(go->ob->transflag & OB_DUPLI) {
Mat4CpyMat4(dob->ob->obmat, dob->mat);
group_duplilist(lb, go->ob, level+1);
object_duplilist_recursive((ID *)group, go->ob, lb, &ob->obmat, level+1);
Mat4CpyMat4(dob->ob->obmat, dob->omat);
}
}
}
}
static void frames_duplilist(ListBase *lb, Object *ob)
static void frames_duplilist(ListBase *lb, Object *ob, int level)
{
extern int enable_cu_speed; /* object.c */
Object copyob;
int cfrao, ok;
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
cfrao= G.scene->r.cfra;
if(ob->parent==NULL && ob->track==NULL && ob->ipo==NULL && ob->constraints.first==NULL) return;
@ -362,8 +370,11 @@ static void frames_duplilist(ListBase *lb, Object *ob)
}
struct vertexDupliData {
ID *id; /* scene or group, for recursive loops */
int level;
ListBase *lb;
float pmat[4][4];
float obmat[4][4]; /* Only used for dupliverts inside dupligroups, where the ob->obmat is modified */
Object *ob, *par;
};
@ -375,9 +386,9 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
VECCOPY(vec, co);
Mat4MulVecfl(vdd->pmat, vec);
VecSubf(vec, vec, vdd->pmat[3]);
VecAddf(vec, vec, vdd->ob->obmat[3]);
VecAddf(vec, vec, vdd->obmat[3]);
Mat4CpyMat4(obmat, vdd->ob->obmat);
Mat4CpyMat4(obmat, vdd->obmat);
VECCOPY(obmat[3], vec);
if(vdd->par->transflag & OB_DUPLIROT) {
@ -395,19 +406,32 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n
Mat4MulMat43(obmat, tmat, mat);
}
new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index);
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 */
object_duplilist_recursive((ID *)vdd->id, vdd->ob, vdd->lb, &obmat, vdd->level+1);
Mat4CpyMat4(vdd->ob->obmat, tmpmat);
}
}
static void vertex_duplilist(ListBase *lb, Scene *sce, Object *par)
static void vertex_duplilist(ListBase *lb, ID *id, Object *par, float (*par_space_mat)[][4], int level)
{
Object *ob;
Base *base;
Object *ob, *ob_iter;
Base *base = NULL;
float vec[3], no[3], pmat[4][4];
int lay, totvert, a;
int lay, totvert, a, oblay;
DerivedMesh *dm;
struct vertexDupliData vdd;
Scene *sce = NULL;
Group *group = NULL;
GroupObject * go = NULL;
Mat4CpyMat4(pmat, par->obmat);
lay= G.scene->lay;
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
if(par==G.obedit)
dm= editmesh_get_derived_cage(CD_MASK_BAREMESH);
@ -416,16 +440,45 @@ static void vertex_duplilist(ListBase *lb, Scene *sce, Object *par)
totvert = dm->getNumVerts(dm);
base= sce->base.first;
while(base) {
if(base->object->type>0 && (lay & base->lay) && G.obedit!=base->object) {
ob= base->object->parent;
/* having to loop on scene OR group objects is NOT FUN */
if (GS(id->name) == ID_SCE) {
sce = (Scene *)id;
lay= sce->lay;
base= sce->base.first;
} else {
group = (Group *)id;
lay= group->layer;
go = group->gobject.first;
}
/* Start looping on Scene OR Group objects */
while (base || go) {
if (sce) {
ob_iter= base->object;
oblay = base->lay;
} else {
ob_iter= go->ob;
oblay = ob_iter->lay;
}
if (lay & oblay && G.obedit!=ob_iter) {
ob=ob_iter->parent;
while(ob) {
if(ob==par) {
struct vertexDupliData vdd;
ob = ob_iter;
/* End Scene/Group object loop, below is generic */
ob= base->object;
/* par_space_mat - only used for groups so we can modify the space dupli's are in
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);
} else {
Mat4CpyMat4(vdd.obmat, ob->obmat);
}
vdd.id= id;
vdd.level= level;
vdd.lb= lb;
vdd.ob= ob;
vdd.par= par;
@ -451,26 +504,33 @@ static void vertex_duplilist(ListBase *lb, Scene *sce, Object *par)
ob= ob->parent;
}
}
base= base->next;
if (sce) base= base->next; /* scene loop */
else go= go->next; /* group loop */
}
dm->release(dm);
}
static void face_duplilist(ListBase *lb, Scene *sce, Object *par)
static void face_duplilist(ListBase *lb, ID *id, Object *par, float (*par_space_mat)[][4], int level)
{
Object *ob;
Base *base;
Object *ob, *ob_iter;
Base *base = NULL;
DerivedMesh *dm;
MFace *mface;
MVert *mvert;
float pmat[4][4], imat[3][3];
int lay, totface, a;
int lay, oblay, totface, a;
Scene *sce = NULL;
Group *group = NULL;
GroupObject *go = NULL;
float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
Mat4CpyMat4(pmat, par->obmat);
lay= G.scene->lay;
if(par==G.obedit) {
int totvert;
dm= editmesh_get_derived_cage(CD_MASK_BAREMESH);
@ -491,16 +551,45 @@ static void face_duplilist(ListBase *lb, Scene *sce, Object *par)
}
for(base= sce->base.first; base; base= base->next) {
/* having to loop on scene OR group objects is NOT FUN */
if (GS(id->name) == ID_SCE) {
sce = (Scene *)id;
lay= sce->lay;
base= sce->base.first;
} else {
group = (Group *)id;
lay= group->layer;
go = group->gobject.first;
}
/* Start looping on Scene OR Group objects */
while (base || go) {
if (sce) {
ob_iter= base->object;
oblay = base->lay;
} else {
ob_iter= go->ob;
oblay = ob_iter->lay;
}
if(base->object->type>0 && (lay & base->lay) && G.obedit!=base->object) {
ob= base->object->parent;
if (lay & oblay && G.obedit!=ob_iter) {
ob=ob_iter->parent;
while(ob) {
if(ob==par) {
ob = ob_iter;
/* End Scene/Group object loop, below is generic */
/* par_space_mat - only used for groups so we can modify the space dupli's are in
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);
} else {
Mat4CpyMat4(ob__obmat, ob->obmat);
}
ob= base->object;
Mat3CpyMat4(imat, ob->parentinv);
/* mballs have a different dupli handling */
if(ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
@ -519,9 +608,10 @@ static void face_duplilist(ListBase *lb, Scene *sce, Object *par)
Mat4MulVecfl(pmat, cent);
VecSubf(cent, cent, pmat[3]);
VecAddf(cent, cent, ob->obmat[3]);
VecAddf(cent, cent, ob__obmat[3]);
Mat4CpyMat4(obmat, ob__obmat);
Mat4CpyMat4(obmat, ob->obmat);
VECCOPY(obmat[3], cent);
/* rotation */
@ -542,7 +632,14 @@ static void face_duplilist(ListBase *lb, Scene *sce, Object *par)
Mat4MulMat43(obmat, tmat, mat);
new_dupli_object(lb, ob, obmat, lay, a);
if(ob->transflag & OB_DUPLI) {
float tmpmat[4][4];
Mat4CpyMat4(tmpmat, ob->obmat);
Mat4CpyMat4(ob->obmat, obmat); /* pretend we are really this mat */
object_duplilist_recursive((ID *)id, ob, lb, &ob->obmat, level+1);
Mat4CpyMat4(ob->obmat, tmpmat);
}
}
break;
@ -550,6 +647,8 @@ static void face_duplilist(ListBase *lb, Scene *sce, Object *par)
ob= ob->parent;
}
}
if (sce) base= base->next; /* scene loop */
else go= go->next; /* group loop */
}
if(par==G.obedit) {
@ -560,7 +659,7 @@ static void face_duplilist(ListBase *lb, Scene *sce, Object *par)
dm->release(dm);
}
static void new_particle_duplilist(ListBase *lb, Scene *sce, Object *par, ParticleSystem *psys)
static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, ParticleSystem *psys, int level)
{
GroupObject *go;
Object *ob, **oblist=0;
@ -575,6 +674,11 @@ static void new_particle_duplilist(ListBase *lb, Scene *sce, Object *par, Partic
if(psys==0) return;
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
if (GS(id->name)!=ID_SCE) return; /* No support for groups YET! TODO */
part=psys->part;
if(part==0) return;
@ -722,7 +826,7 @@ static Object *find_family_object(Object **obar, char *family, char ch)
}
static void font_duplilist(ListBase *lb, Object *par)
static void font_duplilist(ListBase *lb, Object *par, int level)
{
Object *ob, *obar[256];
Curve *cu;
@ -730,6 +834,9 @@ static void font_duplilist(ListBase *lb, Object *par)
float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof;
int slen, a;
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
Mat4CpyMat4(pmat, par->obmat);
/* in par the family name is stored, use this to find the other objects */
@ -769,45 +876,63 @@ static void font_duplilist(ListBase *lb, Object *par)
}
/* ***************************** */
static void object_duplilist_recursive(ID *id, Object *ob, ListBase *duplilist, float (*par_space_mat)[][4], int level)
{
if((ob->transflag & OB_DUPLI)==0)
return;
/* Should the dupli's be greated for this object? - Respect restrict flags */
if (G.rendering) {
if (ob->restrictflag & OB_RESTRICT_RENDER) {
return;
}
} else {
if (ob->restrictflag & OB_RESTRICT_VIEW) {
return;
}
}
if(ob->transflag & OB_DUPLIPARTS) {
ParticleSystem *psys = ob->particlesystem.first;
for(; psys; psys=psys->next)
new_particle_duplilist(duplilist, id, ob, psys, level+1);
}
else if(ob->transflag & OB_DUPLIVERTS) {
if(ob->type==OB_MESH) {
vertex_duplilist(duplilist, id, ob, par_space_mat, level+1);
}
else if(ob->type==OB_FONT) {
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
font_duplilist(duplilist, ob, level+1);
}
}
}
else if(ob->transflag & OB_DUPLIFACES) {
if(ob->type==OB_MESH)
face_duplilist(duplilist, id, ob, par_space_mat, level+1);
}
else if(ob->transflag & OB_DUPLIFRAMES) {
if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */
frames_duplilist(duplilist, ob, level+1);
}
} else if(ob->transflag & OB_DUPLIGROUP) {
DupliObject *dob;
group_duplilist(duplilist, ob, level+1); /* now recursive */
if (level==0) {
for(dob= duplilist->first; dob; dob= dob->next)
Mat4CpyMat4(dob->ob->obmat, dob->mat);
}
}
}
/* note; group dupli's already set transform matrix. see note in group_duplilist() */
ListBase *object_duplilist(Scene *sce, Object *ob)
{
ListBase *duplilist= MEM_mallocN(sizeof(ListBase), "duplilist");
duplilist->first= duplilist->last= NULL;
if(ob->transflag & OB_DUPLI) {
if(ob->transflag & OB_DUPLIPARTS) {
ParticleSystem *psys = ob->particlesystem.first;
for(; psys; psys=psys->next)
new_particle_duplilist(duplilist, sce, ob, psys);
}
else if(ob->transflag & OB_DUPLIVERTS) {
if(ob->type==OB_MESH) {
vertex_duplilist(duplilist, sce, ob);
}
else if(ob->type==OB_FONT) {
font_duplilist(duplilist, ob);
}
}
else if(ob->transflag & OB_DUPLIFACES) {
if(ob->type==OB_MESH)
face_duplilist(duplilist, sce, ob);
}
else if(ob->transflag & OB_DUPLIFRAMES)
frames_duplilist(duplilist, ob);
else if(ob->transflag & OB_DUPLIGROUP) {
DupliObject *dob;
group_duplilist(duplilist, ob, 0); /* now recursive */
/* make copy already, because in group dupli's deform displists can be made, requiring parent matrices */
for(dob= duplilist->first; dob; dob= dob->next)
Mat4CpyMat4(dob->ob->obmat, dob->mat);
}
}
object_duplilist_recursive((ID *)sce, ob, duplilist, NULL, 0);
return duplilist;
}

@ -167,18 +167,30 @@ void curvemap_remove(CurveMap *cuma, int flag)
void curvemap_insert(CurveMap *cuma, float x, float y)
{
CurveMapPoint *cmp= MEM_callocN((cuma->totpoint+1)*sizeof(CurveMapPoint), "curve points");
int a;
memcpy(cmp, cuma->curve, (cuma->totpoint)*sizeof(CurveMapPoint));
int a, b, foundloc= 0;
/* insert fragments of the old one and the new point to the new curve */
cuma->totpoint++;
for(a=0, b=0; a<cuma->totpoint; a++) {
if((x < cuma->curve[a].x) && !foundloc) {
cmp[a].x= x;
cmp[a].y= y;
cmp[a].flag= CUMA_SELECT;
foundloc= 1;
}
else {
cmp[a].x= cuma->curve[b].x;
cmp[a].y= cuma->curve[b].y;
cmp[a].flag= cuma->curve[b].flag;
cmp[a].flag &= ~CUMA_SELECT; /* make sure old points don't remain selected */
cmp[a].shorty= cuma->curve[b].shorty;
b++;
}
}
/* free old curve and replace it with new one */
MEM_freeN(cuma->curve);
cuma->curve= cmp;
cuma->curve[cuma->totpoint].x= x;
cuma->curve[cuma->totpoint].y= y;
cuma->curve[cuma->totpoint].flag = CUMA_SELECT;
for(a=0; a<cuma->totpoint; a++, cmp++)
cmp->flag= 0;
cuma->totpoint++;
}
void curvemap_reset(CurveMap *cuma, rctf *clipr)

@ -1467,7 +1467,7 @@ void makeBevelList(Object *ob)
BevPoint *bevp, *bevp2, *bevp1 = NULL, *bevp0;
float *data, *data_a, *v1, *v2, min, inp, x1, x2, y1, y2, vec[3];
struct bevelsort *sortdata, *sd, *sd1;
int a, b, len, nr, poly, resolu;
int a, b, nr, poly, resolu, len=0;
/* this function needs an object, because of tflag and upflag */
cu= ob->data;

@ -98,32 +98,50 @@
/* used by sequencer and image premul option - IMA_DO_PREMUL */
void converttopremul(struct ImBuf *ibuf)
{
int x, y, val;
char *cp;
int x, y;
if(ibuf==0) return;
if(ibuf->depth==24) { /* put alpha at 255 */
cp= (char *)(ibuf->rect);
for(y=0; y<ibuf->y; y++) {
for(x=0; x<ibuf->x; x++, cp+=4) {
cp[3]= 255;
if (ibuf->rect) {
int val;
char *cp;
if(ibuf->depth==24) { /* put alpha at 255 */
cp= (char *)(ibuf->rect);
for(y=0; y<ibuf->y; y++) {
for(x=0; x<ibuf->x; x++, cp+=4) {
cp[3]= 255;
}
}
} else {
cp= (char *)(ibuf->rect);
for(y=0; y<ibuf->y; y++) {
for(x=0; x<ibuf->x; x++, cp+=4) {
val= cp[3];
cp[0]= (cp[0]*val)>>8;
cp[1]= (cp[1]*val)>>8;
cp[2]= (cp[2]*val)>>8;
}
}
}
return;
}
cp= (char *)(ibuf->rect);
for(y=0; y<ibuf->y; y++) {
for(x=0; x<ibuf->x; x++, cp+=4) {
if(cp[3]==0) {
cp[0]= cp[1]= cp[2]= 0;
if (ibuf->rect_float) {
float val;
float *cp;
if(ibuf->depth==24) { /* put alpha at 1.0 */
cp= ibuf->rect_float;;
for(y=0; y<ibuf->y; y++) {
for(x=0; x<ibuf->x; x++, cp+=4) {
cp[3]= 1.0;
}
}
else if(cp[3]!=255) {
val= cp[3];
cp[0]= (cp[0]*val)>>8;
cp[1]= (cp[1]*val)>>8;
cp[2]= (cp[2]*val)>>8;
} else {
cp= ibuf->rect_float;
for(y=0; y<ibuf->y; y++) {
for(x=0; x<ibuf->x; x++, cp+=4) {
val= cp[3];
cp[0]= cp[0]*val;
cp[1]= cp[1]*val;
cp[2]= cp[2]*val;
}
}
}
}
@ -378,20 +396,27 @@ Image *BKE_add_image_file(const char *name)
return ima;
}
static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid, float color[4])
static ImBuf *add_ibuf_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4])
{
ImBuf *ibuf;
float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b;
unsigned char *rect;
float *rect_float;
int x, y;
int checkerwidth=21, dark=1;
ibuf= IMB_allocImBuf(width, height, 24, IB_rect, 0);
if (floatbuf) {
ibuf= IMB_allocImBuf(width, height, 24, IB_rectfloat, 0);
rect_float= (float*)ibuf->rect_float;
}
else {
ibuf= IMB_allocImBuf(width, height, 24, IB_rect, 0);
rect= (unsigned char*)ibuf->rect;
}
strcpy(ibuf->name, "Untitled");
ibuf->userflags |= IB_BITMAPDIRTY;
rect= (unsigned char*)ibuf->rect;
if (uvtestgrid) {
/* these two passes could be combined into one, but it's more readable and
* easy to tweak like this, speed isn't really that much of an issue in this situation... */
@ -400,26 +425,40 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid,
for(y=0; y<ibuf->y; y++) {
dark = pow(-1, floor(y / checkerwidth));
for(x=0; x<ibuf->x; x++, rect+=4) {
for(x=0; x<ibuf->x; x++) {
if (x % checkerwidth == 0) dark *= -1;
if (dark > 0) {
rect[0] = rect[1] = rect[2] = 64;
rect[3] = 255;
} else {
rect[0] = rect[1] = rect[2] = 150;
rect[3] = 255;
if (floatbuf) {
if (dark > 0) {
rect_float[0] = rect_float[1] = rect_float[2] = 0.25;
rect_float[3] = 1.0;
} else {
rect_float[0] = rect_float[1] = rect_float[2] = 0.58;
rect_float[3] = 1.0;
}
rect_float+=4;
}
else {
if (dark > 0) {
rect[0] = rect[1] = rect[2] = 64;
rect[3] = 255;
} else {
rect[0] = rect[1] = rect[2] = 150;
rect[3] = 255;
}
rect += 4;
}
}
}
/* 2nd pass, colored + */
rect= (unsigned char*)ibuf->rect;
if (floatbuf) rect_float= (float*)ibuf->rect_float;
else rect= (unsigned char*)ibuf->rect;
for(y=0; y<ibuf->y; y++) {
hoffs = 0.125 * floor(y / checkerwidth);
for(x=0; x<ibuf->x; x++, rect+=4) {
for(x=0; x<ibuf->x; x++) {
h = 0.125 * floor(x / checkerwidth);
if ((fabs((x % checkerwidth) - (checkerwidth / 2)) < 4) &&
@ -431,10 +470,20 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid,
hue = fmod(fabs(h-hoffs), 1.0);
hsv_to_rgb(hue, s, v, &r, &g, &b);
rect[0]= (char)(r * 255.0);
rect[1]= (char)(g * 255.0);
rect[2]= (char)(b * 255.0);
rect[3]= 255;
if (floatbuf) {
rect_float[0]= r;
rect_float[1]= g;
rect_float[2]= b;
rect_float[3]= 1.0;
rect_float+=4;
}
else {
rect[0]= (char)(r * 255.0);
rect[1]= (char)(g * 255.0);
rect[2]= (char)(b * 255.0);
rect[3]= 255;
rect+=4;
}
}
}
@ -442,11 +491,21 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid,
}
} else { /* blank image */
for(y=0; y<ibuf->y; y++) {
for(x=0; x<ibuf->x; x++, rect+=4) {
rect[0]= (char)(color[0] * 255.0);
rect[1]= (char)(color[1] * 255.0);
rect[2]= (char)(color[2] * 255.0);
rect[3]= (char)(color[3] * 255.0);
for(x=0; x<ibuf->x; x++) {
if (floatbuf) {
rect_float[0]= color[0];
rect_float[1]= color[1];
rect_float[2]= color[2];
rect_float[3]= color[3];
rect_float+=4;
}
else {
rect[0]= (char)(color[0] * 255.0);
rect[1]= (char)(color[1] * 255.0);
rect[2]= (char)(color[2] * 255.0);
rect[3]= (char)(color[3] * 255.0);
rect+=4;
}
}
}
}
@ -454,7 +513,7 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, short uvtestgrid,
}
/* adds new image block, creates ImBuf and initializes color */
Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid, float color[4])
Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short uvtestgrid, float color[4])
{
Image *ima;
@ -469,7 +528,7 @@ Image *BKE_add_image_size(int width, int height, char *name, short uvtestgrid, f
ima->gen_y= height;
ima->gen_type= uvtestgrid;
ibuf= add_ibuf_size(width, height, name, uvtestgrid, color);
ibuf= add_ibuf_size(width, height, name, floatbuf, uvtestgrid, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok= IMA_OK_LOADED;
@ -812,8 +871,8 @@ static void stampdata(StampData *stamp_data, int do_prefix)
}
if (G.scene->r.stamp & R_STAMP_NOTE) {
if (do_prefix) sprintf(stamp_data->note, "Note %s", G.scene->r.stamp_udata);
else sprintf(stamp_data->note, "%s", G.scene->r.stamp_udata);
/* Never do prefix for Note */
sprintf(stamp_data->note, "%s", G.scene->r.stamp_udata);
} else {
stamp_data->note[0] = '\0';
}
@ -1678,6 +1737,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser)
{
ImBuf *ibuf= NULL;
float color[] = {0, 0, 0, 1};
int floatbuf;
/* quick reject tests */
if(ima==NULL)
@ -1755,7 +1815,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser)
/* UV testgrid or black or solid etc */
if(ima->gen_x==0) ima->gen_x= 256;
if(ima->gen_y==0) ima->gen_y= 256;
ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, ima->gen_type, color);
ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, floatbuf, ima->gen_type, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok= IMA_OK_LOADED;
}

@ -2161,7 +2161,7 @@ void do_ob_ipodrivers(Object *ob, Ipo *ipo, float ctime)
}
}
void do_seq_ipo(Sequence *seq)
void do_seq_ipo(Sequence *seq, int cfra)
{
float ctime, div;
@ -2169,11 +2169,10 @@ void do_seq_ipo(Sequence *seq)
if(seq->ipo) {
if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
ctime = frame_to_float(G.scene->r.cfra);
ctime = frame_to_float(cfra);
div = 1.0;
} else {
ctime= frame_to_float(G.scene->r.cfra
- seq->startdisp);
ctime= frame_to_float(cfra - seq->startdisp);
div= (seq->enddisp - seq->startdisp)/100.0f;
if(div==0.0) return;
}
@ -2291,7 +2290,7 @@ void do_all_data_ipos()
|| seq->type == SEQ_HD_SOUND) && (seq->ipo) &&
(seq->startdisp<=G.scene->r.cfra+2) &&
(seq->enddisp>G.scene->r.cfra))
do_seq_ipo(seq);
do_seq_ipo(seq, G.scene->r.cfra);
seq= seq->next;
}
}

@ -55,14 +55,13 @@
#include "DNA_meshdata_types.h"
#include "DNA_ipo_types.h"
#include "BDR_sculptmode.h"
#include "BKE_customdata.h"
#include "BKE_depsgraph.h"
#include "BKE_main.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BKE_subsurf.h"
#include "BKE_displist.h"
#include "BKE_library.h"
@ -83,8 +82,6 @@
#include "BLI_editVert.h"
#include "BLI_arithb.h"
#include "multires.h"
int update_realtime_texture(MTFace *tface, double time)
{
Image *ima;
@ -489,21 +486,12 @@ float *get_mesh_orco_verts(Object *ob)
vcos= mesh_getRefKeyCos(me, &totvert);
}
else {
MultiresLevel *lvl = NULL;
MVert *mvert = NULL;
if(me->mr) {
lvl = multires_level_n(me->mr, me->mr->pinlvl);
vcos = MEM_callocN(sizeof(*vcos)*lvl->totvert, "orco mr mesh");
mvert = me->mr->verts;
totvert = lvl->totvert;
}
else {
Mesh *tme = me->texcomesh?me->texcomesh:me;
vcos = MEM_callocN(sizeof(*vcos)*me->totvert, "orco mesh");
mvert = tme->mvert;
totvert = MIN2(tme->totvert, me->totvert);
}
MVert *mvert = NULL;
Mesh *tme = me->texcomesh?me->texcomesh:me;
vcos = MEM_callocN(sizeof(*vcos)*me->totvert, "orco mesh");
mvert = tme->mvert;
totvert = MIN2(tme->totvert, me->totvert);
for(a=0; a<totvert; a++, mvert++) {
vcos[a][0]= mvert->co[0];
@ -1240,3 +1228,70 @@ void free_uv_vert_map(UvVertMap *vmap)
}
}
/* Partial Mesh Visibility */
PartialVisibility *mesh_pmv_copy(PartialVisibility *pmv)
{
PartialVisibility *n= MEM_dupallocN(pmv);
n->vert_map= MEM_dupallocN(pmv->vert_map);
n->edge_map= MEM_dupallocN(pmv->edge_map);
n->old_edges= MEM_dupallocN(pmv->old_edges);
n->old_faces= MEM_dupallocN(pmv->old_faces);
return n;
}
void mesh_pmv_free(PartialVisibility *pv)
{
MEM_freeN(pv->vert_map);
MEM_freeN(pv->edge_map);
MEM_freeN(pv->old_faces);
MEM_freeN(pv->old_edges);
MEM_freeN(pv);
}
void mesh_pmv_revert(Object *ob, Mesh *me)
{
if(me->pv) {
unsigned i;
MVert *nve, *old_verts;
/* Reorder vertices */
nve= me->mvert;
old_verts = MEM_mallocN(sizeof(MVert)*me->pv->totvert,"PMV revert verts");
for(i=0; i<me->pv->totvert; ++i)
old_verts[i]= nve[me->pv->vert_map[i]];
/* Restore verts, edges and faces */
CustomData_free_layer_active(&me->vdata, CD_MVERT, me->totvert);
CustomData_free_layer_active(&me->edata, CD_MEDGE, me->totedge);
CustomData_free_layer_active(&me->fdata, CD_MFACE, me->totface);
CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, old_verts, me->pv->totvert);
CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->pv->old_edges, me->pv->totedge);
CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->pv->old_faces, me->pv->totface);
mesh_update_customdata_pointers(me);
me->totvert= me->pv->totvert;
me->totedge= me->pv->totedge;
me->totface= me->pv->totface;
me->pv->old_edges= NULL;
me->pv->old_faces= NULL;
/* Free maps */
MEM_freeN(me->pv->edge_map);
me->pv->edge_map= NULL;
MEM_freeN(me->pv->vert_map);
me->pv->vert_map= NULL;
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
}
}
void mesh_pmv_off(Object *ob, Mesh *me)
{
if(ob && me->pv) {
mesh_pmv_revert(ob, me);
MEM_freeN(me->pv);
me->pv= NULL;
}
}

@ -43,13 +43,13 @@
#include "BKE_customdata.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BLI_editVert.h"
#include "MEM_guardedalloc.h"
#include "blendef.h"
#include "multires.h"
#include <string.h>
@ -392,7 +392,6 @@ void multires_delete_layer(Mesh *me, CustomData *cd, const int type, int n)
}
}
MultiresLevel *current_level(Multires *mr);
void multires_add_layer(Mesh *me, CustomData *cd, const int type, const int n)
{
if(me && me->mr && cd) {

File diff suppressed because it is too large Load Diff

@ -483,6 +483,20 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree)
BLI_addtail(&ngroup->nodes, node);
node->locx-= 0.5f*(min[0]+max[0]);
node->locy-= 0.5f*(min[1]+max[1]);
/* set selin and selout of the nodetree */
for(sock= node->inputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) {
ngroup->selin= sock;
break;
}
}
for(sock= node->outputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) {
ngroup->selout= sock;
break;
}
}
}
}
@ -653,7 +667,8 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup)
}
}
static void find_node_with_socket(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex)
/* finds a node based on given socket */
int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex)
{
bNode *node;
bNodeSocket *tsock;
@ -671,13 +686,15 @@ static void find_node_with_socket(bNodeTree *ntree, bNodeSocket *sock, bNode **n
if(tsock)
break;
}
if(node) {
*nodep= node;
*sockindex= index;
}
else {
*nodep= NULL;
if(sockindex) *sockindex= index;
return 1;
}
*nodep= NULL;
return 0;
}
/* returns 1 if its OK */
@ -717,7 +734,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode)
for(link= ntree->links.first; link; link= link->next) {
if(link->tonode==gnode) {
/* link->tosock->tosock is on the node we look for */
find_node_with_socket(ngroup, link->tosock->tosock, &nextn, &index);
nodeFindNode(ngroup, link->tosock->tosock, &nextn, &index);
if(nextn==NULL) printf("wrong stuff!\n");
else if(nextn->new_node==NULL) printf("wrong stuff too!\n");
else {
@ -727,7 +744,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode)
}
else if(link->fromnode==gnode) {
/* link->fromsock->tosock is on the node we look for */
find_node_with_socket(ngroup, link->fromsock->tosock, &nextn, &index);
nodeFindNode(ngroup, link->fromsock->tosock, &nextn, &index);
if(nextn==NULL) printf("1 wrong stuff!\n");
else if(nextn->new_node==NULL) printf("1 wrong stuff too!\n");
else {
@ -898,6 +915,28 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
nnode->flag |= NODE_SELECT;
}
node->flag &= ~NODE_ACTIVE;
/* deselect original sockets */
for(sock= node->inputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) sock->flag&= ~SOCK_SEL;
}
for(sock= node->outputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) sock->flag&= ~SOCK_SEL;
}
/* set tree selin and selout to new sockets */
for(sock= nnode->inputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) {
ntree->selin= sock;
break;
}
}
for(sock= nnode->outputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) {
ntree->selout= sock;
break;
}
}
}
if(node==last) break;
}
@ -941,7 +980,7 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
/* ************** Free stuff ********** */
/* goes over entire tree */
static void node_unlink_node(bNodeTree *ntree, bNode *node)
void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
{
bNodeLink *link, *next;
bNodeSocket *sock;
@ -985,7 +1024,7 @@ static void composit_free_node_cache(bNode *node)
void nodeFreeNode(bNodeTree *ntree, bNode *node)
{
node_unlink_node(ntree, node);
nodeUnlinkNode(ntree, node);
BLI_remlink(&ntree->nodes, node);
/* since it is called while free database, node->id is undefined */
@ -2335,6 +2374,8 @@ static void registerCompositNodes(ListBase *ntypelist)
nodeRegisterType(ntypelist, &cmp_node_filter);
nodeRegisterType(ntypelist, &cmp_node_blur);
nodeRegisterType(ntypelist, &cmp_node_dblur);
nodeRegisterType(ntypelist, &cmp_node_bilateralblur);
nodeRegisterType(ntypelist, &cmp_node_vecblur);
nodeRegisterType(ntypelist, &cmp_node_dilateerode);
nodeRegisterType(ntypelist, &cmp_node_defocus);

@ -225,6 +225,7 @@ void free_object(Object *ob)
ob->path= 0;
if(ob->ipo) ob->ipo->id.us--;
if(ob->action) ob->action->id.us--;
if(ob->poselib) ob->poselib->id.us--;
if(ob->dup_group) ob->dup_group->id.us--;
if(ob->defbase.first)
BLI_freelistN(&ob->defbase);

@ -257,8 +257,8 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys)
return 0;
psmd= psys_get_modifier(ob, psys);
if(G.rendering) {
if(!psys->renderdata || !(psmd->modifier.mode & eModifierMode_Render))
if(psys->renderdata) {
if(!(psmd->modifier.mode & eModifierMode_Render))
return 0;
}
else if(!(psmd->modifier.mode & eModifierMode_Realtime))
@ -295,7 +295,6 @@ void free_keyed_keys(ParticleSystem *psys)
}
void free_child_path_cache(ParticleSystem *psys)
{
if(psys->childcache){
if(psys->childcache[0])
MEM_freeN(psys->childcache[0]);
@ -363,28 +362,98 @@ void psys_free(Object *ob, ParticleSystem * psys)
}
}
/* these two functions move away particle data and bring it back after
/* these functions move away particle data and bring it back after
* rendering, to make different render settings possible without
* removing the previous data. this should be solved properly once */
typedef struct ParticleRenderDataup {
typedef struct ParticleRenderElem {
int curchild, totchild;
float lambda, t, scalemin, scalemax;
} ParticleRenderElem;
typedef struct ParticleRenderData {
ChildParticle *child;
ParticleCacheKey **pathcache;
ParticleCacheKey **childcache;
int totchild, totcached, totchildcache;
DerivedMesh *dm;
int totdmvert, totdmedge, totdmface;
} ParticleRenderDataup;
void psys_particles_to_render_backup(Object *ob, ParticleSystem *psys)
float mat[4][4];
float viewmat[4][4], winmat[4][4];
int winx, winy;
int dosimplify;
ParticleRenderElem *elems;
int *origindex;
} ParticleRenderData;
static float psys_render_viewport_falloff(double rate, float dist, float width)
{
ParticleRenderDataup *data;
return pow(rate, dist/width);
}
static float psys_render_projected_area(ParticleSystem *psys, float *center, float area, double vprate, float *viewport)
{
ParticleRenderData *data= psys->renderdata;
float co[3], view[3], ortho1[3], ortho2[2], w, dx, dy, radius;
/* transform to view space */
VECCOPY(co, center);
co[3]= 1.0f;
Mat4MulVec4fl(data->viewmat, co);
/* compute two vectors orthogonal to view vector */
VECCOPY(view, co);
Normalize(view);
VecOrthoBasisf(view, ortho1, ortho2);
/* compute on screen minification */
w= co[2]*data->winmat[2][3] + data->winmat[3][3];
dx= data->winx*ortho2[0]*data->winmat[0][0];
dy= data->winy*ortho2[1]*data->winmat[1][1];
w= sqrt(dx*dx + dy*dy)/w;
/* w squared because we are working with area */
area= area*w*w;
/* viewport of the screen test */
/* project point on screen */
Mat4MulVec4fl(data->winmat, co);
if(co[3] != 0.0f) {
co[0]= 0.5f*data->winx*(1.0f + co[0]/co[3]);
co[1]= 0.5f*data->winy*(1.0f + co[1]/co[3]);
}
/* screen space radius */
radius= sqrt(area/M_PI);
/* make smaller using fallof once over screen edge */
*viewport= 1.0f;
if(co[0]+radius < 0.0f)
*viewport *= psys_render_viewport_falloff(vprate, -(co[0]+radius), data->winx);
else if(co[0]-radius > data->winx)
*viewport *= psys_render_viewport_falloff(vprate, (co[0]-radius) - data->winx, data->winx);
if(co[1]+radius < 0.0f)
*viewport *= psys_render_viewport_falloff(vprate, -(co[1]+radius), data->winy);
else if(co[1]-radius > data->winy)
*viewport *= psys_render_viewport_falloff(vprate, (co[1]-radius) - data->winy, data->winy);
return area;
}
void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float winmat[][4], int winx, int winy)
{
ParticleRenderData*data;
ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
if(!G.rendering)
return;
data= MEM_callocN(sizeof(ParticleRenderDataup), "ParticleRenderDataup");
data= MEM_callocN(sizeof(ParticleRenderData), "ParticleRenderData");
data->child= psys->child;
data->totchild= psys->totchild;
@ -404,17 +473,26 @@ void psys_particles_to_render_backup(Object *ob, ParticleSystem *psys)
psys->childcache= NULL;
psys->totchild= psys->totcached= psys->totchildcache= 0;
Mat4CpyMat4(data->winmat, winmat);
Mat4MulMat4(data->viewmat, ob->obmat, viewmat);
Mat4MulMat4(data->mat, data->viewmat, winmat);
data->winx= winx;
data->winy= winy;
psys->renderdata= data;
}
void psys_render_backup_to_particles(Object *ob, ParticleSystem *psys)
void psys_render_restore(Object *ob, ParticleSystem *psys)
{
ParticleRenderDataup *data;
ParticleRenderData*data;
ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
data= psys->renderdata;
if(!data)
return;
if(data->elems)
MEM_freeN(data->elems);
if(psmd->dm) {
psmd->dm->needsFree= 1;
@ -428,7 +506,7 @@ void psys_render_backup_to_particles(Object *ob, ParticleSystem *psys)
psys->child= 0;
psys->totchild= 0;
}
psys->child= data->child;
psys->totchild= data->totchild;
psys->pathcache= data->pathcache;
@ -449,6 +527,211 @@ void psys_render_backup_to_particles(Object *ob, ParticleSystem *psys)
psys->renderdata= NULL;
}
int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
{
DerivedMesh *dm= ctx->dm;
Mesh *me= (Mesh*)(ctx->ob->data);
MFace *mf, *mface;
MVert *mvert;
ParticleRenderData *data;
ParticleRenderElem *elems, *elem;
ParticleSettings *part= ctx->psys->part;
float *facearea, (*facecenter)[3], size[3], fac, powrate;
float co1[3], co2[3], co3[3], co4[3], lambda, arearatio, t, area, viewport;
double vprate;
int *origindex, *facetotvert;
int a, b, totorigface, totface, newtot, skipped;
if(part->draw_as!=PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND))
return tot;
if(!ctx->psys->renderdata || !(part->simplify_flag & PART_SIMPLIFY_ENABLE))
return tot;
mvert= dm->getVertArray(dm);
mface= dm->getFaceArray(dm);
origindex= dm->getFaceDataArray(dm, CD_ORIGINDEX);
totface= dm->getNumFaces(dm);
totorigface= me->totface;
if(totface == 0 || totorigface == 0 || origindex == NULL)
return tot;
facearea= MEM_callocN(sizeof(float)*totorigface, "SimplifyFaceArea");
facecenter= MEM_callocN(sizeof(float[3])*totorigface, "SimplifyFaceCenter");
facetotvert= MEM_callocN(sizeof(int)*totorigface, "SimplifyFaceArea");
elems= MEM_callocN(sizeof(ParticleRenderElem)*totorigface, "SimplifyFaceElem");
data= ctx->psys->renderdata;
data->dosimplify= 1;
data->elems= elems;
data->origindex= origindex;
/* compute number of children per original face */
for(a=0; a<tot; a++) {
b= origindex[ctx->index[a]];
if(b != -1)
elems[b].totchild++;
}
/* compute areas and centers of original faces */
for(mf=mface, a=0; a<totface; a++, mf++) {
b= origindex[a];
if(b != -1) {
VECCOPY(co1, mvert[mf->v1].co);
VECCOPY(co2, mvert[mf->v2].co);
VECCOPY(co3, mvert[mf->v3].co);
VECADD(facecenter[b], facecenter[b], co1);
VECADD(facecenter[b], facecenter[b], co2);
VECADD(facecenter[b], facecenter[b], co3);
if(mf->v4) {
VECCOPY(co4, mvert[mf->v4].co);
VECADD(facecenter[b], facecenter[b], co4);
facearea[b] += AreaQ3Dfl(co1, co2, co3, co4);
facetotvert[b] += 4;
}
else {
facearea[b] += AreaT3Dfl(co1, co2, co3);
facetotvert[b] += 3;
}
}
}
for(a=0; a<totorigface; a++)
if(facetotvert[a] > 0)
VecMulf(facecenter[a], 1.0f/facetotvert[a]);
/* for conversion from BU area / pixel area to reference screen size */
mesh_get_texspace(me, 0, 0, size);
fac= ((size[0] + size[1] + size[2])/3.0f)/part->simplify_refsize;
fac= fac*fac;
powrate= log(0.5f)/log(part->simplify_rate*0.5f);
if(part->simplify_flag & PART_SIMPLIFY_VIEWPORT)
vprate= pow(1.0 - part->simplify_viewport, 5.0);
else
vprate= 1.0;
/* set simplification parameters per original face */
for(a=0, elem=elems; a<totorigface; a++, elem++) {
area = psys_render_projected_area(ctx->psys, facecenter[a], facearea[a], vprate, &viewport);
arearatio= fac*area/facearea[a];
if(arearatio < 1.0f || viewport < 1.0f) {
/* lambda is percentage of elements to keep */
lambda= (arearatio < 1.0f)? pow(arearatio, powrate): 1.0f;
lambda *= viewport;
/* compute transition region */
t= part->simplify_transition;
elem->t= (lambda-t < 0.0f)? lambda: (lambda+t > 1.0f)? 1.0f-lambda: t;
/* scale at end and beginning of the transition region */
elem->scalemax= (lambda+t < 1.0f)? 1.0f/lambda: 1.0f/(1.0f - elem->t*elem->t/t);
elem->scalemin= (lambda+t < 1.0f)? 0.0f: elem->scalemax*(1.0f-elem->t/t);
/* extend lambda to include transition */
lambda= lambda + elem->t;
if(lambda > 1.0f)
lambda= 1.0f;
}
else {
lambda= arearatio;
elem->scalemax= 1.0f; //sqrt(lambda);
elem->scalemin= 1.0f; //sqrt(lambda);
}
elem->lambda= lambda;
elem->scalemin= sqrt(elem->scalemin);
elem->scalemax= sqrt(elem->scalemax);
elem->curchild= 0;
}
MEM_freeN(facearea);
MEM_freeN(facecenter);
MEM_freeN(facetotvert);
/* move indices and set random number skipping */
ctx->skip= MEM_callocN(sizeof(int)*tot, "SimplificationSkip");
skipped= 0;
for(a=0, newtot=0; a<tot; a++) {
b= origindex[ctx->index[a]];
if(b != -1) {
if(elems[b].curchild++ < ceil(elems[b].lambda*elems[b].totchild)) {
ctx->index[newtot]= ctx->index[a];
ctx->skip[newtot]= skipped;
skipped= 0;
newtot++;
}
else skipped++;
}
else skipped++;
}
for(a=0, elem=elems; a<totorigface; a++, elem++)
elem->curchild= 0;
return newtot;
}
int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float *params)
{
ParticleRenderData *data;
ParticleRenderElem *elem;
float x, w, scale, alpha, lambda, t, scalemin, scalemax;
int b;
if(!(psys->renderdata && (psys->part->simplify_flag & PART_SIMPLIFY_ENABLE)))
return 0;
data= psys->renderdata;
if(!data->dosimplify)
return 0;
b= data->origindex[cpa->num];
if(b == -1)
return 0;
elem= &data->elems[b];
lambda= elem->lambda;
t= elem->t;
scalemin= elem->scalemin;
scalemax= elem->scalemax;
if(lambda >= 1.0f) {
scale= scalemin;
alpha= 1.0f;
}
else {
x= (elem->curchild+0.5f)/elem->totchild;
if(x < lambda-t) {
scale= scalemax;
alpha= 1.0f;
}
else if(x >= lambda+t) {
scale= scalemin;
alpha= 0.0f;
}
else {
w= (lambda+t - x)/(2.0f*t);
scale= scalemin + (scalemax - scalemin)*w;
alpha= w;
}
}
params[0]= scale;
params[1]= alpha;
elem->curchild++;
return 1;
}
/************************************************/
/* Interpolated Particles */
/************************************************/
@ -2512,7 +2795,6 @@ static void default_particle_settings(ParticleSettings *part)
part->disp=100;
part->from= PART_FROM_FACE;
part->length= 1.0;
part->rotfac= 1.0;
part->nbetween= 4;
part->boidneighbours= 5;
@ -2550,6 +2832,11 @@ static void default_particle_settings(ParticleSettings *part)
}
part->ipo = NULL;
part->simplify_refsize= 1920;
part->simplify_rate= 1.0f;
part->simplify_transition= 0.1f;
part->simplify_viewport= 0.8;
}

@ -105,13 +105,13 @@ static int get_current_display_percentage(ParticleSystem *psys)
return psys->part->disp;
}
static void alloc_particles(ParticleSystem *psys, int new_totpart)
static void alloc_particles(Object *ob, ParticleSystem *psys, int new_totpart)
{
ParticleData *newpars = 0, *pa;
int i, child_nbr, totpart, totsaved = 0;
int i, totpart, totsaved = 0;
if(new_totpart<0){
if(psys->part->distr==PART_DISTR_GRID){
if(new_totpart<0) {
if(psys->part->distr==PART_DISTR_GRID) {
totpart= psys->part->grid_res;
totpart*=totpart*totpart;
}
@ -123,7 +123,7 @@ static void alloc_particles(ParticleSystem *psys, int new_totpart)
if(totpart)
newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles");
if(psys->particles){
if(psys->particles) {
totsaved=MIN2(psys->totpart,totpart);
/*save old pars*/
if(totsaved)
@ -136,16 +136,7 @@ static void alloc_particles(ParticleSystem *psys, int new_totpart)
}
psys->particles=newpars;
child_nbr= (psys->renderdata)? psys->part->ren_child_nbr: psys->part->child_nbr;
if(child_nbr && psys->part->childtype){
if(psys->child)
MEM_freeN(psys->child);
psys->child = NULL;
if(totpart)
psys->child= MEM_callocN(totpart*child_nbr*sizeof(ChildParticle), "child_particles");
psys->totchild=totpart*child_nbr;
}
else if(psys->child){
if(psys->child) {
MEM_freeN(psys->child);
psys->child=0;
psys->totchild=0;
@ -154,6 +145,32 @@ static void alloc_particles(ParticleSystem *psys, int new_totpart)
psys->totpart=totpart;
}
static int get_alloc_child_particles_tot(ParticleSystem *psys)
{
int child_nbr;
if(!psys->part->childtype)
return 0;
child_nbr= (psys->renderdata)? psys->part->ren_child_nbr: psys->part->child_nbr;
return psys->totpart*child_nbr;
}
static void alloc_child_particles(ParticleSystem *psys, int tot)
{
if(psys->child){
MEM_freeN(psys->child);
psys->child=0;
psys->totchild=0;
}
if(psys->part->childtype) {
psys->totchild= tot;
if(psys->totchild)
psys->child= MEM_callocN(psys->totchild*sizeof(ChildParticle), "child_particles");
}
}
/* only run this if from == PART_FROM_FACE */
void psys_calc_dmfaces(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
{
@ -607,7 +624,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
}
mf= dm->getFaceData(dm, ctx->index[p], CD_MFACE);
//switch(distr){
// case PART_DISTR_JIT:
// i=index[p];
@ -741,12 +758,16 @@ void *exec_distribution(void *data)
if(thread->ctx->from == PART_FROM_CHILD) {
totpart= psys->totchild;
cpa= psys->child + thread->num;
cpa= psys->child;
rng_skip(thread->rng, 5*thread->num);
for(p=thread->num; p<totpart; p+=thread->tot, cpa+=thread->tot) {
psys_thread_distribute_particle(thread, NULL, cpa, p);
rng_skip(thread->rng, 5*(thread->tot-1));
for(p=0; p<totpart; p++, cpa++) {
if(thread->ctx->skip) /* simplification skip */
rng_skip(thread->rng, 5*thread->ctx->skip[p]);
if((p+thread->num) % thread->tot == 0)
psys_thread_distribute_particle(thread, NULL, cpa, p);
else /* thread skip */
rng_skip(thread->rng, 5);
}
}
else {
@ -757,7 +778,7 @@ void *exec_distribution(void *data)
}
return 0;
}
}
/* creates a distribution of coordinates on a DerivedMesh */
/* */
@ -813,7 +834,6 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
if(from==PART_FROM_CHILD){
distr=PART_DISTR_RAND;
cpa=psys->child;
if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){
dm= finaldm;
children=1;
@ -828,7 +848,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
BLI_kdtree_balance(tree);
totpart=psys->totchild;
totpart=get_alloc_child_particles_tot(psys);
cfrom=from=PART_FROM_FACE;
if(part->flag&PART_CHILD_SEAMS){
@ -879,6 +899,9 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
/* no need to figure out distribution */
int child_nbr= (psys->renderdata)? part->ren_child_nbr: part->child_nbr;
totpart= get_alloc_child_particles_tot(psys);
alloc_child_particles(psys, totpart);
cpa=psys->child;
for(i=0; i<child_nbr; i++){
for(p=0; p<psys->totpart; p++,cpa++){
float length=2.0;
@ -1100,8 +1123,8 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
sum[0]= 0.0f;
for(i=0;i<tot; i++)
sum[i+1]= sum[i]+weight[i]*totweight;
if(part->flag&PART_TRAND){
if((part->flag&PART_TRAND) || (part->simplify_flag&PART_SIMPLIFY_ENABLE)) {
float pos;
for(p=0; p<totpart; p++) {
@ -1156,9 +1179,6 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
}
/* 5. */
if(children)
from=PART_FROM_CHILD;
ctx->tree= tree;
ctx->seams= seams;
ctx->totseam= totseam;
@ -1169,17 +1189,21 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
ctx->jitoff= jitoff;
ctx->weight= weight;
ctx->maxweight= maxweight;
ctx->from= from;
ctx->from= (children)? PART_FROM_CHILD: from;
ctx->cfrom= cfrom;
ctx->distr= distr;
ctx->dm= dm;
ctx->tpars= tpars;
seed= 31415926 + ctx->psys->seed;
if(children) {
totpart= psys_render_simplify_distribution(ctx, totpart);
alloc_child_particles(psys, totpart);
}
if(from!=PART_FROM_CHILD || psys->totchild < 10000)
if(!children || psys->totchild < 10000)
totthread= 1;
seed= 31415926 + ctx->psys->seed;
for(i=0; i<totthread; i++) {
threads[i].rng= rng_new(seed);
threads[i].tot= totthread;
@ -1323,6 +1347,7 @@ void psys_threads_free(ParticleThread *threads)
if(ctx->jitoff) MEM_freeN(ctx->jitoff);
if(ctx->weight) MEM_freeN(ctx->weight);
if(ctx->index) MEM_freeN(ctx->index);
if(ctx->skip) MEM_freeN(ctx->skip);
if(ctx->seams) MEM_freeN(ctx->seams);
//if(ctx->vertpart) MEM_freeN(ctx->vertpart);
BLI_kdtree_free(ctx->tree);
@ -1508,10 +1533,9 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi
ParticleTexture ptex;
ParticleKey state;
IpoCurve *icu=0;
float fac, nor[3]={0,0,0},loc[3],tloc[3],vel[3]={0.0,0.0,0.0},rot[4],*q2=0;
float fac, rotfac, phasefac, nor[3]={0,0,0},loc[3],tloc[3],vel[3]={0.0,0.0,0.0},rot[4],*q2=0;
float r_vel[3],r_ave[3],r_rot[4],p_vel[3]={0.0,0.0,0.0};
float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0};
float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0};
float q_one[4]={1.0,0.0,0.0,0.0}, q_phase[4];
part=psys->part;
@ -1612,7 +1636,7 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi
}
/* -rotation */
if(part->rotmode==PART_ROT_RAND){
if(part->randrotfac != 0.0f){
QUATCOPY(r_rot,pa->r_rot);
Mat4ToQuat(ob->obmat,rot);
QuatMul(r_rot,r_rot,rot);
@ -1663,34 +1687,49 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi
pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0.0;
if(part->rotmode){
/* create vector into which rotation is aligned */
switch(part->rotmode){
case PART_ROT_NOR:
VecMulf(nor,-1.0);
q2= vectoquat(nor, OB_POSX, OB_POSZ);
VecMulf(nor,-1.0);
VecCopyf(rot_vec, nor);
break;
case PART_ROT_VEL:
VecMulf(vel,-1.0);
q2= vectoquat(vel, OB_POSX, OB_POSZ);
VecMulf(vel,-1.0);
VecCopyf(rot_vec, vel);
break;
case PART_ROT_RAND:
q2= r_rot;
case PART_ROT_GLOB_X:
case PART_ROT_GLOB_Y:
case PART_ROT_GLOB_Z:
rot_vec[part->rotmode - PART_ROT_GLOB_X] = 1.0f;
break;
case PART_ROT_OB_X:
case PART_ROT_OB_Y:
case PART_ROT_OB_Z:
VecCopyf(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
break;
}
/* how much to rotate from rest position */
QuatInterpol(rot,q_one,q2,part->rotfac);
/* create rotation quat */
VecMulf(rot_vec,-1.0);
q2= vectoquat(rot_vec, OB_POSX, OB_POSZ);
/* phase */
VecRotToQuat(x_vec,part->phasefac*(float)M_PI,q_phase);
/* randomize rotation quat */
if(part->randrotfac!=0.0f)
QuatInterpol(rot, q2, r_rot, part->randrotfac);
else
QuatCopy(rot,q2);
/* combine amount & phase */
QuatMul(pa->state.rot,rot,q_phase);
/* rotation phase */
phasefac = part->phasefac;
if(part->randphasefac != 0.0f) /* abuse r_ave[0] as a random number */
phasefac += part->randphasefac * pa->r_ave[0];
VecRotToQuat(x_vec, phasefac*(float)M_PI, q_phase);
/* combine base rotation & phase */
QuatMul(pa->state.rot, rot, q_phase);
}
/* -angular velocity */
pa->state.ave[0]=pa->state.ave[1]=pa->state.ave[2]=0.0;
pa->state.ave[0] = pa->state.ave[1] = pa->state.ave[2] = 0.0;
if(part->avemode){
switch(part->avemode){
@ -1711,15 +1750,15 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi
}
}
pa->dietime=pa->time+pa->lifetime;
pa->dietime = pa->time + pa->lifetime;
if(pa->time >= cfra)
pa->alive=PARS_UNBORN;
pa->alive = PARS_UNBORN;
pa->state.time=cfra;
pa->state.time = cfra;
pa->stick_ob=0;
pa->flag&=~PARS_STICKY;
pa->stick_ob = 0;
pa->flag &= ~PARS_STICKY;
}
static void reset_all_particles(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float dtime, float cfra, int from)
{
@ -4188,13 +4227,16 @@ static void psys_update_path_cache(Object *ob, ParticleSystemModifierData *psmd,
if(distr){
if(alloc)
alloc_particles(psys,psys->totpart);
alloc_particles(ob,psys,psys->totpart);
if(psys->totchild && part->childtype){
distribute_particles(ob,psys,PART_FROM_CHILD);
if(get_alloc_child_particles_tot(psys)) {
/* don't generate children while computing the hair keys */
if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
distribute_particles(ob,psys,PART_FROM_CHILD);
if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES && part->parents!=0.0)
psys_find_parents(ob,psmd,psys);
if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES && part->parents!=0.0)
psys_find_parents(ob,psmd,psys);
}
}
}
@ -4353,10 +4395,10 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
return;
}
}
else {
if(psys->recalc)
else if(part->phystype != PART_PHYS_NO) { /* cache shouldn't be used for none physics */
if(psys->recalc && (psys->flag & PSYS_PROTECT_CACHE) == 0)
clear_particles_from_cache(ob,psys,(int)cfra);
else if(get_particles_from_cache(ob, psys, (int)cfra)){
else if(get_particles_from_cache(ob, psys, (int)cfra)) {
cached_step(ob,psmd,psys,cfra,vg_size);
psys->cfra=cfra;
psys->recalc = 0;
@ -4413,11 +4455,11 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
if(init) {
if(distr) {
if(alloc)
alloc_particles(psys, totpart);
alloc_particles(ob, psys, totpart);
distribute_particles(ob, psys, part->from);
if(psys->totchild && part->childtype)
if(get_alloc_child_particles_tot(psys))
distribute_particles(ob, psys, PART_FROM_CHILD);
}
initialize_all_particles(ob, psys, psmd);

@ -47,6 +47,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_armature_types.h"
#include "DNA_color_types.h"
#include "DNA_constraint_types.h"
#include "DNA_curve_types.h"
#include "DNA_group_types.h"
@ -63,6 +64,7 @@
#include "BKE_anim.h"
#include "BKE_armature.h"
#include "BKE_bad_level_calls.h"
#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
@ -75,11 +77,11 @@
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_sculpt.h"
#include "BKE_world.h"
#include "BKE_utildefines.h"
#include "BIF_previewrender.h"
#include "BDR_sculptmode.h"
#include "BPY_extern.h"
#include "BLI_arithb.h"
@ -168,7 +170,7 @@ void free_scene(Scene *sce)
MEM_freeN(sce->nodetree);
}
sculptmode_free_all(sce);
sculptdata_free(sce);
}
Scene *add_scene(char *name)
@ -259,7 +261,7 @@ Scene *add_scene(char *name)
BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
sce->r.osa= 8;
sculptmode_init(sce);
sculptdata_init(sce);
/* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
scene_add_render_layer(sce);
@ -578,3 +580,127 @@ void scene_add_render_layer(Scene *sce)
srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z;
}
/* Initialize 'permanent' sculpt data that is saved with file kept after
switching out of sculptmode. */
void sculptdata_init(Scene *sce)
{
SculptData *sd;
if(!sce)
return;
sd= &sce->sculptdata;
if(sd->cumap)
curvemapping_free(sd->cumap);
memset(sd, 0, sizeof(SculptData));
sd->drawbrush.size = sd->smoothbrush.size = sd->pinchbrush.size =
sd->inflatebrush.size = sd->grabbrush.size =
sd->layerbrush.size = sd->flattenbrush.size = 50;
sd->drawbrush.strength = sd->smoothbrush.strength =
sd->pinchbrush.strength = sd->inflatebrush.strength =
sd->grabbrush.strength = sd->layerbrush.strength =
sd->flattenbrush.strength = 25;
sd->drawbrush.dir = sd->pinchbrush.dir = sd->inflatebrush.dir = sd->layerbrush.dir= 1;
sd->drawbrush.airbrush = sd->smoothbrush.airbrush =
sd->pinchbrush.airbrush = sd->inflatebrush.airbrush =
sd->layerbrush.airbrush = sd->flattenbrush.airbrush = 0;
sd->drawbrush.view= 0;
sd->brush_type= DRAW_BRUSH;
sd->texact= -1;
sd->texfade= 1;
sd->averaging= 1;
sd->texsep= 0;
sd->texrept= SCULPTREPT_DRAG;
sd->flags= SCULPT_DRAW_BRUSH;
sd->tablet_size=3;
sd->tablet_strength=10;
sd->rake=0;
sculpt_reset_curve(sd);
}
void sculptdata_free(Scene *sce)
{
SculptData *sd= &sce->sculptdata;
int a;
sculptsession_free(sce);
for(a=0; a<MAX_MTEX; a++) {
MTex *mtex= sd->mtex[a];
if(mtex) {
if(mtex->tex) mtex->tex->id.us--;
MEM_freeN(mtex);
}
}
curvemapping_free(sd->cumap);
sd->cumap = NULL;
}
void sculpt_vertexusers_free(SculptSession *ss)
{
if(ss && ss->vertex_users){
MEM_freeN(ss->vertex_users);
MEM_freeN(ss->vertex_users_mem);
ss->vertex_users= NULL;
ss->vertex_users_mem= NULL;
ss->vertex_users_size= 0;
}
}
void sculptsession_free(Scene *sce)
{
SculptSession *ss= sce->sculptdata.session;
if(ss) {
if(ss->projverts)
MEM_freeN(ss->projverts);
if(ss->mats)
MEM_freeN(ss->mats);
if(ss->propset) {
if(ss->propset->texdata)
MEM_freeN(ss->propset->texdata);
if(ss->propset->num)
MEM_freeN(ss->propset->num);
MEM_freeN(ss->propset);
}
sculpt_vertexusers_free(ss);
if(ss->texcache)
MEM_freeN(ss->texcache);
MEM_freeN(ss);
sce->sculptdata.session= NULL;
}
}
/* Default curve approximates 0.5 * (cos(pi * x) + 1), with 0 <= x <= 1 */
void sculpt_reset_curve(SculptData *sd)
{
CurveMap *cm = NULL;
if(!sd->cumap)
sd->cumap = curvemapping_add(1, 0, 0, 1, 1);
cm = sd->cumap->cm;
if(cm->curve)
MEM_freeN(cm->curve);
cm->curve= MEM_callocN(6*sizeof(CurveMapPoint), "curve points");
cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
cm->totpoint= 6;
cm->curve[0].x= 0;
cm->curve[0].y= 1;
cm->curve[1].x= 0.1;
cm->curve[1].y= 0.97553;
cm->curve[2].x= 0.3;
cm->curve[2].y= 0.79389;
cm->curve[3].x= 0.9;
cm->curve[3].y= 0.02447;
cm->curve[4].x= 0.7;
cm->curve[4].y= 0.20611;
cm->curve[5].x= 1;
cm->curve[5].y= 0;
}

@ -2307,9 +2307,8 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow)
}
if (( (sb->totpoint-a) == bs->v1) ){
actspringlen= VecLenf( (bproot+bs->v2)->pos, bp->pos);
VecSubf(sd,(bproot+bs->v2)->pos, bp->pos);
Normalize(sd);
actspringlen=Normalize(sd);
/* friction stuff V1 */
VecSubf(velgoal,bp->vec,(bproot+bs->v2)->vec);
@ -2330,9 +2329,8 @@ static void softbody_calc_forces(Object *ob, float forcetime, float timenow)
}
if (( (sb->totpoint-a) == bs->v2) ){
actspringlen= VecLenf( (bproot+bs->v1)->pos, bp->pos);
VecSubf(sd,bp->pos,(bproot+bs->v1)->pos);
Normalize(sd);
actspringlen=Normalize(sd);
/* friction stuff V2 */
VecSubf(velgoal,bp->vec,(bproot+bs->v1)->vec);

@ -135,7 +135,8 @@ void BLI_dlist_reinit(struct DynamicList *dlist);
* converts it to a regular full path.
* Also removes garbage from directory paths, like /../ or double slashes etc
*/
void BLI_cleanup_dir(const char *relabase, char *dir);
void BLI_cleanup_file(const char *relabase, char *dir);
void BLI_cleanup_dir(const char *relabase, char *dir); /* same as above but adds a trailing slash */
/**
* Blender's path code replacement function.

@ -28,10 +28,7 @@
* Contributor(s): Campbell Barton
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*
* The old math stuff from Ton. These will slowly phase out in favour
* of MTC calls. (or even MoTO :) )
* */
*/
/* Box Packer */

@ -0,0 +1,60 @@
/**
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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): Campbell Barton
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/* Based on ghash, difference is ghash is not a fixed size,
* so for BPath we dont need to malloc */
struct BPathIterator {
char* path;
char* lib;
char* name;
void* data;
int len;
int type;
};
void BLI_bpathIterator_init (struct BPathIterator *bpi);
char* BLI_bpathIterator_getPath (struct BPathIterator *bpi);
char* BLI_bpathIterator_getLib (struct BPathIterator *bpi);
char* BLI_bpathIterator_getName (struct BPathIterator *bpi);
int BLI_bpathIterator_getType (struct BPathIterator *bpi);
int BLI_bpathIterator_getPathMaxLen(struct BPathIterator *bpi);
void BLI_bpathIterator_step (struct BPathIterator *bpi);
int BLI_bpathIterator_isDone (struct BPathIterator *bpi);
void BLI_bpathIterator_copyPathExpanded( struct BPathIterator *bpi, char *path_expanded);
/* high level funcs */
/* creates a text file with missing files if there are any */
void checkMissingFiles(char *txtname );
void makeFilesRelative(char *txtname, int *tot, int *changed, int *failed, int *linked);
void makeFilesAbsolute(char *txtname, int *tot, int *changed, int *failed, int *linked);
void findMissingFiles(char *str);

@ -117,14 +117,16 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val) {
}
}
void* BLI_ghash_lookup(GHash *gh, void *key) {
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
for (e= gh->buckets[hash]; e; e= e->next)
if (gh->cmpfp(key, e->key)==0)
return e->val;
void* BLI_ghash_lookup(GHash *gh, void *key)
{
if(gh) {
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
for (e= gh->buckets[hash]; e; e= e->next)
if (gh->cmpfp(key, e->key)==0)
return e->val;
}
return NULL;
}

@ -0,0 +1,561 @@
/**
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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): Campbell barton
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#include "BLI_bpath.h"
#include "BKE_global.h"
#include "DNA_ID.h" /* Library */
#include "DNA_vfont_types.h"
#include "DNA_image_types.h"
#include "DNA_sound_types.h"
#include "DNA_scene_types.h" /* to get the current frame */
#include <stdlib.h>
#include <string.h>
#include "BKE_main.h" /* so we can access G.main->*.first */
#include "BKE_image.h" /* so we can check the image's type */
#include "blendef.h"
#include "BKE_utildefines.h"
/* for writing to a textblock */
#include "BKE_text.h"
#include "BLI_blenlib.h"
#include "DNA_text_types.h"
/* path/file handeling stuff */
#ifndef WIN32
#include <dirent.h>
#include <unistd.h>
#else
#include "BLI_winstuff.h"
#include <io.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define FILE_MAX 240
/* TODO - BPATH_PLUGIN, BPATH_SEQ */
enum BPathTypes {
BPATH_IMAGE = 0,
BPATH_SOUND,
BPATH_FONT,
BPATH_LIB,
BPATH_DONE
};
void BLI_bpathIterator_init( struct BPathIterator *bpi ) {
bpi->type = BPATH_IMAGE;
bpi->data = NULL;
BLI_bpathIterator_step(bpi);
}
char* BLI_bpathIterator_getPath( struct BPathIterator *bpi) {
return bpi->path;
}
void BLI_bpathIterator_copyPathExpanded( struct BPathIterator *bpi, char *path_expanded) {
char *filepath, *libpath;
filepath = BLI_bpathIterator_getPath(bpi);
libpath = BLI_bpathIterator_getLib(bpi);
BLI_strncpy(path_expanded, filepath, FILE_MAXDIR*2);
if (libpath) { /* check the files location relative to its library path */
BLI_convertstringcode(path_expanded, libpath, G.scene->r.cfra);
} else { /* local data, use the blend files path */
BLI_convertstringcode(path_expanded, G.sce, G.scene->r.cfra);
}
}
char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) {
return bpi->lib;
}
char* BLI_bpathIterator_getName( struct BPathIterator *bpi) {
return bpi->name;
}
int BLI_bpathIterator_getType( struct BPathIterator *bpi) {
return bpi->type;
}
int BLI_bpathIterator_getPathMaxLen( struct BPathIterator *bpi) {
return bpi->len;
}
/* gets the first or the next image that has a path - not a viewer node or generated image */
static struct Image *ima_getpath__internal(struct Image *ima, int step_next) {
if (ima==NULL)
return NULL;
if (step_next)
ima = ima->id.next;
while (ima) {
if (ima->packedfile==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
break;
/* image is not a image with a path, skip it */
ima = ima->id.next;
}
return ima;
}
static struct VFont *vf_getpath__internal(struct VFont *vf, int step_next) {
if (vf==NULL)
return NULL;
if (step_next)
vf = vf->id.next;
while (vf) {
if (vf->packedfile==NULL && BLI_streq(vf->name, "<builtin>")==0) {
break;
}
/* font with no path, skip it */
vf = vf->id.next;
}
return vf;
}
static struct bSound *snd_getpath__internal(struct bSound *snd, int step_next) {
if (snd==NULL)
return NULL;
if (step_next)
snd = snd->id.next;
while (snd) {
if (snd->packedfile==NULL) {
break;
}
/* font with no path, skip it */
snd = snd->id.next;
}
return snd;
}
void BLI_bpathIterator_step( struct BPathIterator *bpi) {
while (bpi->type != BPATH_DONE) {
if ((bpi->type) == BPATH_IMAGE) {
/*if (bpi->data) bpi->data = ((ID *)bpi->data)->next;*/
if (bpi->data) bpi->data = ima_getpath__internal( (Image *)bpi->data, 1 ); /* must skip images that have no path */
else bpi->data = ima_getpath__internal(G.main->image.first, 0);
if (bpi->data) {
/* get the path info from this datatype */
Image *ima = (Image *)bpi->data;
bpi->lib = ima->id.lib ? ima->id.lib->filename : NULL;
bpi->path = ima->name;
bpi->name = ima->id.name+2;
bpi->len = sizeof(ima->name);
/* we are done, advancing to the next item, this type worked fine */
break;
} else {
bpi->type+=1; /* advance to the next type */
}
} else if ((bpi->type) == BPATH_SOUND) {
if (bpi->data) bpi->data = snd_getpath__internal( (bSound *)bpi->data, 1 ); /* must skip images that have no path */
else bpi->data = snd_getpath__internal(G.main->sound.first, 0);
if (bpi->data) {
/* get the path info from this datatype */
bSound *snd = (bSound *)bpi->data;
bpi->lib = snd->id.lib ? snd->id.lib->filename : NULL;
bpi->path = snd->sample->name;
bpi->name = snd->id.name+2;
bpi->len = sizeof(snd->sample->name);
/* we are done, advancing to the next item, this type worked fine */
break;
} else {
bpi->type+=1; /* advance to the next type */
}
} else if ((bpi->type) == BPATH_FONT) {
if (bpi->data) bpi->data = vf_getpath__internal( (VFont *)bpi->data, 1 );
else bpi->data = vf_getpath__internal( G.main->vfont.first, 0 );
if (bpi->data) {
/* get the path info from this datatype */
VFont *vf = (VFont *)bpi->data;
bpi->lib = vf->id.lib ? vf->id.lib->filename : NULL;
bpi->path = vf->name;
bpi->name = vf->id.name+2;
bpi->len = sizeof(vf->name);
/* we are done, advancing to the next item, this type worked fine */
break;
} else {
bpi->type+=1; /* advance to the next type */
}
} else if ((bpi->type) == BPATH_LIB) {
if (bpi->data) bpi->data = ((ID *)bpi->data)->next;
else bpi->data = G.main->library.first;
if (bpi->data) {
/* get the path info from this datatype */
Library *lib = (Library *)bpi->data;
bpi->lib = NULL;
bpi->path = lib->name;
bpi->name = NULL;
bpi->len = sizeof(lib->name);
/* we are done, advancing to the next item, this type worked fine */
break;
} else {
bpi->type+=1; /* advance to the next type */
}
}
}
}
int BLI_bpathIterator_isDone( struct BPathIterator *bpi) {
return bpi->type==BPATH_DONE;
}
/* include the path argument */
static void bpathToText(Text *btxt, struct BPathIterator *bpi)
{
char *name;
char path_expanded[FILE_MAXDIR*2];
switch(BLI_bpathIterator_getType(bpi)) {
case BPATH_IMAGE:
txt_insert_buf( btxt, "Image \"" );
break;
case BPATH_SOUND:
txt_insert_buf( btxt, "Sound \"" );
break;
case BPATH_FONT:
txt_insert_buf( btxt, "Font \"" );
break;
case BPATH_LIB:
txt_insert_buf( btxt, "Library \"" );
break;
default:
txt_insert_buf( btxt, "Unknown \"" );
break;
}
name = BLI_bpathIterator_getName(bpi);
if (name) {
txt_insert_buf( btxt, name );
}
txt_insert_buf( btxt, "\" " );
BLI_bpathIterator_copyPathExpanded(bpi, path_expanded);
txt_insert_buf( btxt, path_expanded );
txt_insert_buf( btxt, "\n" );
txt_move_eof( btxt, 0 );
}
/* high level function */
void checkMissingFiles( char *txtname ) {
Text *btxt = NULL;
struct BPathIterator bpi;
/* be sure there is low chance of the path being too short */
char filepath_expanded[FILE_MAXDIR*2];
char *filepath, *libpath;
int files_missing = 0;
BLI_bpathIterator_init(&bpi);
while (!BLI_bpathIterator_isDone(&bpi)) {
filepath = BLI_bpathIterator_getPath(&bpi);
libpath = BLI_bpathIterator_getLib(&bpi);
BLI_bpathIterator_copyPathExpanded( &bpi, filepath_expanded );
if (!BLI_exists(filepath_expanded)) {
if (!btxt) {
btxt = add_empty_text( "missing_files.log" );
if (txtname) {
BLI_strncpy(txtname, btxt->id.name+2, 24);
}
}
bpathToText(btxt, &bpi);
files_missing = 1;
}
BLI_bpathIterator_step(&bpi);
}
}
/* dont log any errors at the moment, should probably do this */
void makeFilesRelative(char *txtname, int *tot, int *changed, int *failed, int *linked) {
struct BPathIterator bpi;
char *filepath, *libpath;
/* be sure there is low chance of the path being too short */
char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
Text *btxt = NULL;
*tot = *changed = *failed = *linked = 0;
BLI_bpathIterator_init(&bpi);
while (!BLI_bpathIterator_isDone(&bpi)) {
filepath = BLI_bpathIterator_getPath(&bpi);
libpath = BLI_bpathIterator_getLib(&bpi);
if(strncmp(filepath, "//", 2)) {
if (libpath) { /* cant make relative if we are library - TODO, LOG THIS */
(*linked)++;
} else { /* local data, use the blend files path */
BLI_strncpy(filepath_relative, filepath, sizeof(filepath_relative));
/* Important BLI_cleanup_dir runs before the path is made relative
* because it wont work for paths that start with "//../" */
BLI_cleanup_file(G.sce, filepath_relative); /* fix any /foo/../foo/ */
BLI_makestringcode(G.sce, filepath_relative);
/* be safe and check the length */
if (BLI_bpathIterator_getPathMaxLen(&bpi) <= strlen(filepath_relative)) {
if (!btxt) {
btxt = add_empty_text( "missing_no_rel.log" );
if (txtname) {
BLI_strncpy(txtname, btxt->id.name+2, 24);
}
}
bpathToText(btxt, &bpi);
(*failed)++;
} else {
if(strncmp(filepath_relative, "//", 2)==0) {
strcpy(filepath, filepath_relative);
(*changed)++;
} else {
if (!btxt) {
btxt = add_empty_text( "missing_no_rel.log" );
if (txtname) {
BLI_strncpy(txtname, btxt->id.name+2, 24);
}
}
bpathToText(btxt, &bpi);
(*failed)++;
}
}
}
}
BLI_bpathIterator_step(&bpi);
(*tot)++;
}
}
/* dont log any errors at the moment, should probably do this -
* Verry similar to makeFilesRelative - keep in sync! */
void makeFilesAbsolute(char *txtname, int *tot, int *changed, int *failed, int *linked) {
struct BPathIterator bpi;
char *filepath, *libpath;
/* be sure there is low chance of the path being too short */
char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
Text *btxt = NULL;
*tot = *changed = *failed = *linked = 0;
BLI_bpathIterator_init(&bpi);
while (!BLI_bpathIterator_isDone(&bpi)) {
filepath = BLI_bpathIterator_getPath(&bpi);
libpath = BLI_bpathIterator_getLib(&bpi);
if(strncmp(filepath, "//", 2)==0) {
if (libpath) { /* cant make absolute if we are library - TODO, LOG THIS */
(*linked)++;
} else { /* get the expanded path and check it is relative or too long */
BLI_bpathIterator_copyPathExpanded( &bpi, filepath_absolute );
BLI_cleanup_file(G.sce, filepath_absolute); /* fix any /foo/../foo/ */
/* to be safe, check the length */
if (BLI_bpathIterator_getPathMaxLen(&bpi) <= strlen(filepath_absolute)) {
if (!btxt) {
btxt = add_empty_text( "missing_no_abs.log" );
if (txtname) {
BLI_strncpy(txtname, btxt->id.name+2, 24);
}
}
bpathToText(btxt, &bpi);
(*failed)++;
} else {
if(strncmp(filepath_absolute, "//", 2)) {
strcpy(filepath, filepath_absolute);
(*changed)++;
} else {
if (!btxt) {
btxt = add_empty_text( "missing_no_abs.log" );
if (txtname) {
BLI_strncpy(txtname, btxt->id.name+2, 24);
}
}
bpathToText(btxt, &bpi);
(*failed)++;
}
}
}
}
BLI_bpathIterator_step(&bpi);
(*tot)++;
}
}
/* find this file recursively, use the biggest file so thumbnails dont get used by mistake
- dir: subdir to search
- filename: set this filename
- filesize: filesize for the file
*/
#define MAX_RECUR 16
static int findFileRecursive(char *filename_new, const char *dirname, const char *filename, int *filesize, int *recur_depth)
{
/* file searching stuff */
DIR *dir;
int file = 0;
struct dirent *de;
struct stat status;
char path[FILE_MAX];
int size;
dir = opendir(dirname);
if (dir==0)
return 0;
if (*filesize == -1)
*filesize = 0; /* dir opened fine */
while ((de = readdir(dir)) != NULL) {
if (strncmp(".", de->d_name, 2)==0 || strncmp("..", de->d_name, 3)==0)
continue;
BLI_join_dirfile(path, dirname, de->d_name);
if (stat(path, &status) != 0)
continue; /* cant stat, dont bother with this file, could print debug info here */
if (S_ISREG(status.st_mode)) { /* is file */
if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */
/* open the file to read its size */
file = open(path, O_BINARY|O_RDONLY);
if (file >=0 ) {
size = BLI_filesize(file);
if (size > *filesize) { /* find the biggest file */
*filesize = size;
BLI_strncpy(filename_new, path, FILE_MAX);
}
close(file);
}
}
} else if (S_ISDIR(status.st_mode)) { /* is subdir */
if (*recur_depth <= MAX_RECUR) {
(*recur_depth)++;
findFileRecursive(filename_new, path, filename, filesize, recur_depth);
(*recur_depth)--;
}
}
}
closedir(dir);
return 1;
}
/* high level function - call from fileselector */
void findMissingFiles(char *str) {
struct BPathIterator bpi;
/* be sure there is low chance of the path being too short */
char filepath_expanded[FILE_MAXDIR*2];
char *filepath, *libpath;
int filesize, recur_depth;
char dirname[FILE_MAX], filename[FILE_MAX], filename_new[FILE_MAX], dummyname[FILE_MAX];
BLI_split_dirfile(str, dirname, dummyname);
BLI_bpathIterator_init(&bpi);
while (!BLI_bpathIterator_isDone(&bpi)) {
filepath = BLI_bpathIterator_getPath(&bpi);
libpath = BLI_bpathIterator_getLib(&bpi);
if (libpath==NULL) {
BLI_bpathIterator_copyPathExpanded( &bpi, filepath_expanded );
if (!BLI_exists(filepath_expanded)) {
/* can the dir be opened? */
filesize = -1;
recur_depth = 0;
BLI_split_dirfile(filepath, dummyname, filename); /* the file to find */
findFileRecursive(filename_new, dirname, filename, &filesize, &recur_depth);
if (filesize == -1) { /* could not open dir */
printf("Could not open dir \"%s\"\n", dirname);
return;
}
if (filesize > 0) {
if (BLI_bpathIterator_getPathMaxLen( &bpi ) < strlen(filename_new)) {
printf("cannot set path \"%s\" too long!", filename_new);
} else {
/* copy the found path into the old one */
if (G.relbase_valid)
BLI_makestringcode(G.sce, filename_new);
strcpy( BLI_bpathIterator_getPath( &bpi ), filename_new );
}
}
}
}
BLI_bpathIterator_step(&bpi);
}
}

@ -776,6 +776,16 @@ int BLI_strcaseeq(char *a, char *b) {
*/
void BLI_cleanup_dir(const char *relabase, char *dir)
{
BLI_cleanup_file(relabase, dir);
#ifdef WIN32
strcat(dir, "\\");
#else
strcat(dir, "/");
#endif
}
void BLI_cleanup_file(const char *relabase, char *dir)
{
short a;
char *start, *eind;
@ -814,9 +824,7 @@ void BLI_cleanup_dir(const char *relabase, char *dir)
dir[a] = 0;
}
}
strcat(dir, "\\");
#else
#else
if(dir[0]=='.') { /* happens, for example in FILE_MAIN */
dir[0]= '/';
dir[1]= 0;
@ -850,8 +858,6 @@ void BLI_cleanup_dir(const char *relabase, char *dir)
if (a<=0) break;
}
}
strcat(dir, "/");
#endif
}

@ -138,6 +138,7 @@
#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
#include "BKE_softbody.h" // sbNew()
#include "BKE_sculpt.h"
#include "BKE_texture.h" // for open_plugin_tex
#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
#include "BKE_idprop.h"
@ -149,8 +150,6 @@
#include "BLO_undofile.h"
#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
#include "multires.h"
#include "readfile.h"
#include "genfile.h"
@ -1527,6 +1526,22 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
link->tosock= newdataadr(fd, link->tosock);
}
/* set selin and selout */
for(node= ntree->nodes.first; node; node= node->next) {
for(sock= node->inputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) {
ntree->selin= sock;
break;
}
}
for(sock= node->outputs.first; sock; sock= sock->next) {
if(sock->flag & SOCK_SEL) {
ntree->selout= sock;
break;
}
}
}
/* type verification is in lib-link */
}
@ -1818,12 +1833,12 @@ static void lib_link_action(FileData *fd, Main *main)
while(act) {
if(act->id.flag & LIB_NEEDLINK) {
act->id.flag -= LIB_NEEDLINK;
for (chan=act->chanbase.first; chan; chan=chan->next) {
chan->ipo= newlibadr_us(fd, act->id.lib, chan->ipo);
lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels);
}
}
act= act->id.next;
}
@ -1848,10 +1863,10 @@ static void direct_link_action(FileData *fd, bAction *act)
bActionChannel *achan;
link_list(fd, &act->chanbase);
link_list(fd, &act->markers);
for (achan = act->chanbase.first; achan; achan=achan->next)
link_list(fd, &achan->constraintChannels);
}
static void direct_link_armature(FileData *fd, bArmature *arm)
@ -2771,6 +2786,7 @@ static void lib_link_object(FileData *fd, Main *main)
ob->track= newlibadr(fd, ob->id.lib, ob->track);
ob->ipo= newlibadr_us(fd, ob->id.lib, ob->ipo);
ob->action = newlibadr_us(fd, ob->id.lib, ob->action);
ob->poselib= newlibadr_us(fd, ob->id.lib, ob->poselib);
ob->dup_group= newlibadr_us(fd, ob->id.lib, ob->dup_group);
ob->proxy= newlibadr_us(fd, ob->id.lib, ob->proxy);
@ -2946,7 +2962,6 @@ static void direct_link_pose(FileData *fd, bPose *pose) {
pchan->iktree.first= pchan->iktree.last= NULL;
pchan->path= NULL;
}
}
static void direct_link_modifiers(FileData *fd, ListBase *lb)
@ -3345,6 +3360,12 @@ static void direct_link_scene(FileData *fd, Scene *sce)
/* SculptData textures */
for(a=0; a<MAX_MTEX; ++a)
sce->sculptdata.mtex[a]= newdataadr(fd,sce->sculptdata.mtex[a]);
/* Sculpt intensity curve */
sce->sculptdata.cumap= newdataadr(fd, sce->sculptdata.cumap);
if(sce->sculptdata.cumap)
direct_link_curvemapping(fd, sce->sculptdata.cumap);
else
sculpt_reset_curve(&sce->sculptdata);
if(sce->ed) {
ListBase *old_seqbasep= &((Editing *)sce->ed)->seqbase;
@ -3382,6 +3403,24 @@ static void direct_link_scene(FileData *fd, Scene *sce)
} else {
seq->strip->stripdata = 0;
}
if (seq->flag & SEQ_USE_CROP) {
seq->strip->crop = newdataadr(
fd, seq->strip->crop);
} else {
seq->strip->crop = 0;
}
if (seq->flag & SEQ_USE_TRANSFORM) {
seq->strip->transform = newdataadr(
fd, seq->strip->transform);
} else {
seq->strip->transform = 0;
}
if (seq->flag & SEQ_USE_PROXY) {
seq->strip->proxy = newdataadr(
fd, seq->strip->proxy);
} else {
seq->strip->proxy = 0;
}
}
}
END_SEQ
@ -6848,7 +6887,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
for(ma=main->mat.first; ma; ma= ma->id.next) {
if (ma->samp_gloss_mir == 0) {
if(ma->samp_gloss_mir == 0) {
ma->gloss_mir = ma->gloss_tra= 1.0;
ma->aniso_gloss_mir = 1.0;
ma->samp_gloss_mir = ma->samp_gloss_tra= 18;
@ -6856,11 +6895,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
ma->dist_mir = 0.0;
ma->fadeto_mir = MA_RAYMIR_FADETOSKY;
}
if(ma->strand_min == 0.0f)
ma->strand_min= 1.0f;
}
for(part=main->particle.first; part; part=part->id.next)
for(part=main->particle.first; part; part=part->id.next) {
if(part->ren_child_nbr==0)
part->ren_child_nbr= part->child_nbr;
if(part->simplify_refsize==0) {
part->simplify_refsize= 1920;
part->simplify_rate= 1.0f;
part->simplify_transition= 0.1f;
part->simplify_viewport= 0.8f;
}
}
if (main->versionfile < 245 || main->subversionfile < 12)
{
/* initialize skeleton generation toolsettings */
@ -7864,6 +7915,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
expand_doit(fd, mainvar, ob->data);
expand_doit(fd, mainvar, ob->ipo);
expand_doit(fd, mainvar, ob->action);
expand_doit(fd, mainvar, ob->poselib);
for (md=ob->modifiers.first; md; md=md->next) {
expand_modifier(fd, mainvar, md);

@ -558,7 +558,7 @@ static void write_particlesystems(WriteData *wd, ListBase *particles)
ParticleData *pa = psys->particles;
for(a=0; a<psys->totpart; a++, pa++)
writedata(wd, DATA, MEM_allocN_len(pa->hair),pa->hair);
writestruct(wd, DATA, "HairKey", pa->totkey, pa->hair);
}
}
if(psys->child) writestruct(wd, DATA, "ChildParticle", psys->totchild ,psys->child);
@ -1429,6 +1429,8 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
for(a=0; a<MAX_MTEX; ++a)
writestruct(wd, DATA, "MTex", 1, sce->sculptdata.mtex[a]);
if(sce->sculptdata.cumap)
write_curvemapping(wd, sce->sculptdata.cumap);
ed= sce->ed;
if(ed) {
@ -1468,7 +1470,15 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
strip= seq->strip;
writestruct(wd, DATA, "Strip", 1, strip);
if(seq->flag & SEQ_USE_CROP && strip->crop) {
writestruct(wd, DATA, "StripCrop", 1, strip->crop);
}
if(seq->flag & SEQ_USE_TRANSFORM && strip->transform) {
writestruct(wd, DATA, "StripTransform", 1, strip->transform);
}
if(seq->flag & SEQ_USE_PROXY && strip->proxy) {
writestruct(wd, DATA, "StripProxy", 1, strip->proxy);
}
if(seq->type==SEQ_IMAGE)
writestruct(wd, DATA, "StripElem", strip->len, strip->stripdata);
else if(seq->type==SEQ_MOVIE || seq->type==SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND)
@ -1735,16 +1745,21 @@ static void write_actions(WriteData *wd, ListBase *idbase)
{
bAction *act;
bActionChannel *chan;
TimeMarker *marker;
for(act=idbase->first; act; act= act->id.next) {
if (act->id.us>0 || wd->current) {
writestruct(wd, ID_AC, "bAction", 1, act);
if (act->id.properties) IDP_WriteProperty(act->id.properties, wd);
for (chan=act->chanbase.first; chan; chan=chan->next) {
writestruct(wd, DATA, "bActionChannel", 1, chan);
write_constraint_channels(wd, &chan->constraintChannels);
}
for (marker=act->markers.first; marker; marker=marker->next) {
writestruct(wd, DATA, "TimeMarker", 1, marker);
}
}
}
}

@ -720,6 +720,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
uint8_t* dst2[4]= {
dst[0] + (anim->y - 1)*dstStride[0],
0, 0, 0 };
int i;
unsigned char* r;
sws_scale(anim->img_convert_ctx,
anim->pFrame->data,
@ -728,6 +730,15 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) {
anim->pCodecCtx->height,
dst2,
dstStride2);
/* workaround: sws_scale sets alpha = 0... */
r = (unsigned char*) ibuf->rect;
for (i = 0; i < ibuf->x * ibuf->y; i++) {
r[3] = 0xff;
r+=4;
}
av_free_packet(&packet);
break;

@ -64,7 +64,7 @@
BlockDXT1
----------------------------------------------------------------------------*/
unsigned int BlockDXT1::evaluatePalette(Color32 color_array[4]) const
uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
{
// Does bit expansion before interpolation.
color_array[0].b = (col0.b << 3) | (col0.b >> 2);
@ -179,9 +179,9 @@ void BlockDXT1::decodeBlock(ColorBlock * block) const
evaluatePalette(color_array);
// Write color block.
for( unsigned int j = 0; j < 4; j++ ) {
for( unsigned int i = 0; i < 4; i++ ) {
unsigned int idx = (row[j] >> (2 * i)) & 3;
for( uint j = 0; j < 4; j++ ) {
for( uint i = 0; i < 4; i++ ) {
uint idx = (row[j] >> (2 * i)) & 3;
block->color(i, j) = color_array[idx];
}
}
@ -190,7 +190,7 @@ void BlockDXT1::decodeBlock(ColorBlock * block) const
void BlockDXT1::setIndices(int * idx)
{
indices = 0;
for(unsigned int i = 0; i < 16; i++) {
for(uint i = 0; i < 16; i++) {
indices |= (idx[i] & 3) << (2 * i);
}
}
@ -199,16 +199,14 @@ void BlockDXT1::setIndices(int * idx)
/// Flip DXT1 block vertically.
inline void BlockDXT1::flip4()
{
unsigned char tmp;
swap(row[0], row[3], tmp);
swap(row[1], row[2], tmp);
swap(row[0], row[3]);
swap(row[1], row[2]);
}
/// Flip half DXT1 block vertically.
inline void BlockDXT1::flip2()
{
unsigned char tmp;
swap(row[0], row[1], tmp);
swap(row[0], row[1]);
}
@ -248,16 +246,14 @@ void AlphaBlockDXT3::decodeBlock(ColorBlock * block) const
/// Flip DXT3 alpha block vertically.
void AlphaBlockDXT3::flip4()
{
unsigned short tmp;
swap(row[0], row[3], tmp);
swap(row[1], row[2], tmp);
swap(row[0], row[3]);
swap(row[1], row[2]);
}
/// Flip half DXT3 alpha block vertically.
void AlphaBlockDXT3::flip2()
{
unsigned short tmp;
swap(row[0], row[1], tmp);
swap(row[0], row[1]);
}
/// Flip DXT3 block vertically.
@ -279,7 +275,7 @@ void BlockDXT3::flip2()
BlockDXT5
----------------------------------------------------------------------------*/
void AlphaBlockDXT5::evaluatePalette(unsigned char alpha[8]) const
void AlphaBlockDXT5::evaluatePalette(uint8 alpha[8]) const
{
if (alpha0 > alpha1) {
evaluatePalette8(alpha);
@ -289,35 +285,35 @@ void AlphaBlockDXT5::evaluatePalette(unsigned char alpha[8]) const
}
}
void AlphaBlockDXT5::evaluatePalette8(unsigned char alpha[8]) const
void AlphaBlockDXT5::evaluatePalette8(uint8 alpha[8]) const
{
// 8-alpha block: derive the other six alphas.
// Bit code 000 = alpha0, 001 = alpha1, others are interpolated.
alpha[0] = alpha0;
alpha[1] = alpha1;
alpha[2] = (6 * alpha0 + 1 * alpha1) / 7; // bit code 010
alpha[3] = (5 * alpha0 + 2 * alpha1) / 7; // bit code 011
alpha[4] = (4 * alpha0 + 3 * alpha1) / 7; // bit code 100
alpha[5] = (3 * alpha0 + 4 * alpha1) / 7; // bit code 101
alpha[6] = (2 * alpha0 + 5 * alpha1) / 7; // bit code 110
alpha[7] = (1 * alpha0 + 6 * alpha1) / 7; // bit code 111
alpha[2] = (6 * alpha[0] + 1 * alpha[1]) / 7; // bit code 010
alpha[3] = (5 * alpha[0] + 2 * alpha[1]) / 7; // bit code 011
alpha[4] = (4 * alpha[0] + 3 * alpha[1]) / 7; // bit code 100
alpha[5] = (3 * alpha[0] + 4 * alpha[1]) / 7; // bit code 101
alpha[6] = (2 * alpha[0] + 5 * alpha[1]) / 7; // bit code 110
alpha[7] = (1 * alpha[0] + 6 * alpha[1]) / 7; // bit code 111
}
void AlphaBlockDXT5::evaluatePalette6(unsigned char alpha[8]) const
void AlphaBlockDXT5::evaluatePalette6(uint8 alpha[8]) const
{
// 6-alpha block.
// Bit code 000 = alpha0, 001 = alpha1, others are interpolated.
alpha[0] = alpha0;
alpha[1] = alpha1;
alpha[2] = (4 * alpha0 + 1 * alpha1) / 5; // Bit code 010
alpha[3] = (3 * alpha0 + 2 * alpha1) / 5; // Bit code 011
alpha[4] = (2 * alpha0 + 3 * alpha1) / 5; // Bit code 100
alpha[5] = (1 * alpha0 + 4 * alpha1) / 5; // Bit code 101
alpha[2] = (4 * alpha[0] + 1 * alpha[1]) / 5; // Bit code 010
alpha[3] = (3 * alpha[0] + 2 * alpha[1]) / 5; // Bit code 011
alpha[4] = (2 * alpha[0] + 3 * alpha[1]) / 5; // Bit code 100
alpha[5] = (1 * alpha[0] + 4 * alpha[1]) / 5; // Bit code 101
alpha[6] = 0x00; // Bit code 110
alpha[7] = 0xFF; // Bit code 111
}
void AlphaBlockDXT5::indices(unsigned char index_array[16]) const
void AlphaBlockDXT5::indices(uint8 index_array[16]) const
{
index_array[0x0] = bits0;
index_array[0x1] = bits1;
@ -337,52 +333,52 @@ void AlphaBlockDXT5::indices(unsigned char index_array[16]) const
index_array[0xF] = bitsF;
}
unsigned int AlphaBlockDXT5::index(unsigned int index) const
uint AlphaBlockDXT5::index(uint index) const
{
int offset = (3 * index + 16);
return (this->u >> offset) & 0x7;
return uint((this->u >> offset) & 0x7);
}
void AlphaBlockDXT5::setIndex(unsigned int index, unsigned int value)
void AlphaBlockDXT5::setIndex(uint index, uint value)
{
int offset = (3 * index + 16);
unsigned long long mask = ((unsigned long long)(0x7)) << offset;
this->u = (this->u & ~mask) | (((unsigned long long)(value)) << offset);
uint64 mask = uint64(0x7) << offset;
this->u = (this->u & ~mask) | (uint64(value) << offset);
}
void AlphaBlockDXT5::decodeBlock(ColorBlock * block) const
{
unsigned char alpha_array[8];
uint8 alpha_array[8];
evaluatePalette(alpha_array);
unsigned char index_array[16];
uint8 index_array[16];
indices(index_array);
for(unsigned int i = 0; i < 16; i++) {
for(uint i = 0; i < 16; i++) {
block->color(i).a = alpha_array[index_array[i]];
}
}
void AlphaBlockDXT5::flip4()
{
unsigned long long * b = (unsigned long long *)this;
uint64 * b = (uint64 *)this;
// @@ The masks might have to be byte swapped.
unsigned long long tmp = (*b & (unsigned long long)(0x000000000000FFFFLL));
tmp |= (*b & (unsigned long long)(0x000000000FFF0000LL)) << 36;
tmp |= (*b & (unsigned long long)(0x000000FFF0000000LL)) << 12;
tmp |= (*b & (unsigned long long)(0x000FFF0000000000LL)) >> 12;
tmp |= (*b & (unsigned long long)(0xFFF0000000000000LL)) >> 36;
uint64 tmp = (*b & (uint64)(0x000000000000FFFFLL));
tmp |= (*b & (uint64)(0x000000000FFF0000LL)) << 36;
tmp |= (*b & (uint64)(0x000000FFF0000000LL)) << 12;
tmp |= (*b & (uint64)(0x000FFF0000000000LL)) >> 12;
tmp |= (*b & (uint64)(0xFFF0000000000000LL)) >> 36;
*b = tmp;
}
void AlphaBlockDXT5::flip2()
{
unsigned int * b = (unsigned int *)this;
uint * b = (uint *)this;
// @@ The masks might have to be byte swapped.
unsigned int tmp = (*b & 0xFF000000);
uint tmp = (*b & 0xFF000000);
tmp |= (*b & 0x00000FFF) << 12;
tmp |= (*b & 0x00FFF000) >> 12;
@ -396,6 +392,7 @@ void BlockDXT5::decodeBlock(ColorBlock * block) const
// Decode alpha.
alpha.decodeBlock(block);
}
/// Flip DXT5 block vertically.
@ -416,13 +413,13 @@ void BlockDXT5::flip2()
/// Decode ATI1 block.
void BlockATI1::decodeBlock(ColorBlock * block) const
{
unsigned char alpha_array[8];
uint8 alpha_array[8];
alpha.evaluatePalette(alpha_array);
unsigned char index_array[16];
uint8 index_array[16];
alpha.indices(index_array);
for(unsigned int i = 0; i < 16; i++) {
for(uint i = 0; i < 16; i++) {
Color32 & c = block->color(i);
c.b = c.g = c.r = alpha_array[index_array[i]];
c.a = 255;
@ -445,13 +442,13 @@ void BlockATI1::flip2()
/// Decode ATI2 block.
void BlockATI2::decodeBlock(ColorBlock * block) const
{
unsigned char alpha_array[8];
unsigned char index_array[16];
uint8 alpha_array[8];
uint8 index_array[16];
x.evaluatePalette(alpha_array);
x.indices(index_array);
for(unsigned int i = 0; i < 16; i++) {
for(uint i = 0; i < 16; i++) {
Color32 & c = block->color(i);
c.r = alpha_array[index_array[i]];
}
@ -459,7 +456,7 @@ void BlockATI2::decodeBlock(ColorBlock * block) const
y.evaluatePalette(alpha_array);
y.indices(index_array);
for(unsigned int i = 0; i < 16; i++) {
for(uint i = 0; i < 16; i++) {
Color32 & c = block->color(i);
c.g = alpha_array[index_array[i]];
c.b = 0;
@ -481,6 +478,68 @@ void BlockATI2::flip2()
y.flip2();
}
void BlockCTX1::evaluatePalette(Color32 color_array[4]) const
{
// Does bit expansion before interpolation.
color_array[0].b = 0x00;
color_array[0].g = col0[1];
color_array[0].r = col0[0];
color_array[0].a = 0xFF;
color_array[1].r = 0x00;
color_array[1].g = col0[1];
color_array[1].b = col1[0];
color_array[1].a = 0xFF;
color_array[2].r = 0x00;
color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3;
color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3;
color_array[2].a = 0xFF;
color_array[3].r = 0x00;
color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3;
color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3;
color_array[3].a = 0xFF;
}
void BlockCTX1::decodeBlock(ColorBlock * block) const
{
// Decode color block.
Color32 color_array[4];
evaluatePalette(color_array);
// Write color block.
for( uint j = 0; j < 4; j++ ) {
for( uint i = 0; i < 4; i++ ) {
uint idx = (row[j] >> (2 * i)) & 3;
block->color(i, j) = color_array[idx];
}
}
}
void BlockCTX1::setIndices(int * idx)
{
indices = 0;
for(uint i = 0; i < 16; i++) {
indices |= (idx[i] & 3) << (2 * i);
}
}
/// Flip CTX1 block vertically.
inline void BlockCTX1::flip4()
{
swap(row[0], row[3]);
swap(row[1], row[2]);
}
/// Flip half CTX1 block vertically.
inline void BlockCTX1::flip2()
{
swap(row[0], row[1]);
}
void mem_read(Stream & mem, BlockDXT1 & block)
{
mem_read(mem, block.col0.u);
@ -521,3 +580,12 @@ void mem_read(Stream & mem, BlockATI2 & block)
mem_read(mem, block.y);
}
void mem_read(Stream & mem, BlockCTX1 & block)
{
mem_read(mem, block.col0[0]);
mem_read(mem, block.col0[1]);
mem_read(mem, block.col1[0]);
mem_read(mem, block.col1[1]);
mem_read(mem, block.indices);
}

@ -58,6 +58,7 @@
#ifndef _DDS_BLOCKDXT_H
#define _DDS_BLOCKDXT_H
#include <Common.h>
#include <Color.h>
#include <ColorBlock.h>
#include <Stream.h>
@ -68,14 +69,14 @@ struct BlockDXT1
Color16 col0;
Color16 col1;
union {
unsigned char row[4];
unsigned int indices;
uint8 row[4];
uint indices;
};
bool isFourColorMode() const;
unsigned int evaluatePalette(Color32 color_array[4]) const;
unsigned int evaluatePaletteFast(Color32 color_array[4]) const;
uint evaluatePalette(Color32 color_array[4]) const;
uint evaluatePaletteFast(Color32 color_array[4]) const;
void evaluatePalette3(Color32 color_array[4]) const;
void evaluatePalette4(Color32 color_array[4]) const;
@ -90,7 +91,7 @@ struct BlockDXT1
/// Return true if the block uses four color mode, false otherwise.
inline bool BlockDXT1::isFourColorMode() const
{
return col0.u >= col1.u; // @@ > or >= ?
return col0.u > col1.u;
}
@ -99,24 +100,24 @@ struct AlphaBlockDXT3
{
union {
struct {
unsigned int alpha0 : 4;
unsigned int alpha1 : 4;
unsigned int alpha2 : 4;
unsigned int alpha3 : 4;
unsigned int alpha4 : 4;
unsigned int alpha5 : 4;
unsigned int alpha6 : 4;
unsigned int alpha7 : 4;
unsigned int alpha8 : 4;
unsigned int alpha9 : 4;
unsigned int alphaA : 4;
unsigned int alphaB : 4;
unsigned int alphaC : 4;
unsigned int alphaD : 4;
unsigned int alphaE : 4;
unsigned int alphaF : 4;
uint alpha0 : 4;
uint alpha1 : 4;
uint alpha2 : 4;
uint alpha3 : 4;
uint alpha4 : 4;
uint alpha5 : 4;
uint alpha6 : 4;
uint alpha7 : 4;
uint alpha8 : 4;
uint alpha9 : 4;
uint alphaA : 4;
uint alphaB : 4;
uint alphaC : 4;
uint alphaD : 4;
uint alphaE : 4;
uint alphaF : 4;
};
unsigned short row[4];
uint16 row[4];
};
void decodeBlock(ColorBlock * block) const;
@ -163,16 +164,16 @@ struct AlphaBlockDXT5
unsigned int bitsE : 3; // 45 - 61
unsigned int bitsF : 3; // 48 - 64
};
unsigned long long u;
uint64 u;
};
void evaluatePalette(unsigned char alpha[8]) const;
void evaluatePalette8(unsigned char alpha[8]) const;
void evaluatePalette6(unsigned char alpha[8]) const;
void indices(unsigned char index_array[16]) const;
void evaluatePalette(uint8 alpha[8]) const;
void evaluatePalette8(uint8 alpha[8]) const;
void evaluatePalette6(uint8 alpha[8]) const;
void indices(uint8 index_array[16]) const;
unsigned int index(unsigned int index) const;
void setIndex(unsigned int index, unsigned int value);
uint index(uint index) const;
void setIndex(uint index, uint value);
void decodeBlock(ColorBlock * block) const;
@ -216,6 +217,25 @@ struct BlockATI2
void flip2();
};
/// CTX1 block.
struct BlockCTX1
{
uint8 col0[2];
uint8 col1[2];
union {
uint8 row[4];
uint indices;
};
void evaluatePalette(Color32 color_array[4]) const;
void setIndices(int * idx);
void decodeBlock(ColorBlock * block) const;
void flip4();
void flip2();
};
void mem_read(Stream & mem, BlockDXT1 & block);
void mem_read(Stream & mem, AlphaBlockDXT3 & block);
void mem_read(Stream & mem, BlockDXT3 & block);
@ -223,5 +243,6 @@ void mem_read(Stream & mem, AlphaBlockDXT5 & block);
void mem_read(Stream & mem, BlockDXT5 & block);
void mem_read(Stream & mem, BlockATI1 & block);
void mem_read(Stream & mem, BlockATI2 & block);
void mem_read(Stream & mem, BlockCTX1 & block);
#endif // _DDS_BLOCKDXT_H

@ -39,13 +39,13 @@
#include <Common.h>
// Get approximate luminance.
inline static unsigned int colorLuminance(Color32 c)
inline static uint colorLuminance(Color32 c)
{
return c.r + c.g + c.b;
}
// Get the euclidean distance between the given colors.
inline static unsigned int colorDistance(Color32 c0, Color32 c1)
inline static uint colorDistance(Color32 c0, Color32 c1)
{
return (c0.r - c1.r) * (c0.r - c1.r) + (c0.g - c1.g) * (c0.g - c1.g) + (c0.b - c1.b) * (c0.b - c1.b);
}
@ -59,22 +59,22 @@ ColorBlock::ColorBlock()
/// Init the color block with the contents of the given block.
ColorBlock::ColorBlock(const ColorBlock & block)
{
for(unsigned int i = 0; i < 16; i++) {
for(uint i = 0; i < 16; i++) {
color(i) = block.color(i);
}
}
/// Initialize this color block.
ColorBlock::ColorBlock(const Image * img, unsigned int x, unsigned int y)
ColorBlock::ColorBlock(const Image * img, uint x, uint y)
{
init(img, x, y);
}
void ColorBlock::init(const Image * img, unsigned int x, unsigned int y)
void ColorBlock::init(const Image * img, uint x, uint y)
{
const unsigned int bw = min(img->width() - x, 4U);
const unsigned int bh = min(img->height() - y, 4U);
const uint bw = min(img->width() - x, 4U);
const uint bh = min(img->height() - y, 4U);
static int remainder[] = {
0, 0, 0, 0,
@ -86,10 +86,10 @@ void ColorBlock::init(const Image * img, unsigned int x, unsigned int y)
// Blocks that are smaller than 4x4 are handled by repeating the pixels.
// @@ Thats only correct when block size is 1, 2 or 4, but not with 3. :(
for(unsigned int i = 0; i < 4; i++) {
for(uint i = 0; i < 4; i++) {
//const int by = i % bh;
const int by = remainder[(bh - 1) * 4 + i];
for(unsigned int e = 0; e < 4; e++) {
for(uint e = 0; e < 4; e++) {
//const int bx = e % bw;
const int bx = remainder[(bw - 1) * 4 + e];
color(e, i) = img->pixel(x + bx, y + by);
@ -111,7 +111,7 @@ void ColorBlock::splatX()
{
for(int i = 0; i < 16; i++)
{
unsigned char x = m_color[i].r;
uint8 x = m_color[i].r;
m_color[i] = Color32(x, x, x, x);
}
}
@ -120,16 +120,16 @@ void ColorBlock::splatY()
{
for(int i = 0; i < 16; i++)
{
unsigned char y = m_color[i].g;
uint8 y = m_color[i].g;
m_color[i] = Color32(y, y, y, y);
}
}
/// Count number of unique colors in this color block.
unsigned int ColorBlock::countUniqueColors() const
uint ColorBlock::countUniqueColors() const
{
unsigned int count = 0;
uint count = 0;
// @@ This does not have to be o(n^2)
for(int i = 0; i < 16; i++)
@ -152,17 +152,27 @@ unsigned int ColorBlock::countUniqueColors() const
/// Get average color of the block.
Color32 ColorBlock::averageColor() const
{
unsigned int r, g, b, a;
uint r, g, b, a;
r = g = b = a = 0;
for(unsigned int i = 0; i < 16; i++) {
for(uint i = 0; i < 16; i++) {
r += m_color[i].r;
g += m_color[i].g;
b += m_color[i].b;
a += m_color[i].a;
}
return Color32((unsigned char)(r / 16), (unsigned char)(g / 16), (unsigned char)(b / 16), (unsigned char)(a / 16));
return Color32(uint8(r / 16), uint8(g / 16), uint8(b / 16), uint8(a / 16));
}
/// Return true if the block is not fully opaque.
bool ColorBlock::hasAlpha() const
{
for (uint i = 0; i < 16; i++)
{
if (m_color[i].a != 255) return true;
}
return false;
}
@ -170,11 +180,11 @@ Color32 ColorBlock::averageColor() const
void ColorBlock::diameterRange(Color32 * start, Color32 * end) const
{
Color32 c0, c1;
unsigned int best_dist = 0;
uint best_dist = 0;
for(int i = 0; i < 16; i++) {
for (int j = i+1; j < 16; j++) {
unsigned int dist = colorDistance(m_color[i], m_color[j]);
uint dist = colorDistance(m_color[i], m_color[j]);
if( dist > best_dist ) {
best_dist = dist;
c0 = m_color[i];
@ -191,13 +201,13 @@ void ColorBlock::diameterRange(Color32 * start, Color32 * end) const
void ColorBlock::luminanceRange(Color32 * start, Color32 * end) const
{
Color32 minColor, maxColor;
unsigned int minLuminance, maxLuminance;
uint minLuminance, maxLuminance;
maxLuminance = minLuminance = colorLuminance(m_color[0]);
for(unsigned int i = 1; i < 16; i++)
for(uint i = 1; i < 16; i++)
{
unsigned int luminance = colorLuminance(m_color[i]);
uint luminance = colorLuminance(m_color[i]);
if (luminance > maxLuminance) {
maxLuminance = luminance;
@ -219,7 +229,7 @@ void ColorBlock::boundsRange(Color32 * start, Color32 * end) const
Color32 minColor(255, 255, 255);
Color32 maxColor(0, 0, 0);
for(unsigned int i = 0; i < 16; i++)
for(uint i = 0; i < 16; i++)
{
if (m_color[i].r < minColor.r) { minColor.r = m_color[i].r; }
if (m_color[i].g < minColor.g) { minColor.g = m_color[i].g; }
@ -253,7 +263,7 @@ void ColorBlock::boundsRangeAlpha(Color32 * start, Color32 * end) const
Color32 minColor(255, 255, 255, 255);
Color32 maxColor(0, 0, 0, 0);
for(unsigned int i = 0; i < 16; i++)
for(uint i = 0; i < 16; i++)
{
if (m_color[i].r < minColor.r) { minColor.r = m_color[i].r; }
if (m_color[i].g < minColor.g) { minColor.g = m_color[i].g; }
@ -290,11 +300,11 @@ void ColorBlock::boundsRangeAlpha(Color32 * start, Color32 * end) const
void ColorBlock::sortColorsByAbsoluteValue()
{
// Dummy selection sort.
for( unsigned int a = 0; a < 16; a++ ) {
unsigned int max = a;
for( uint a = 0; a < 16; a++ ) {
uint max = a;
Color16 cmax(m_color[a]);
for( unsigned int b = a+1; b < 16; b++ ) {
for( uint b = a+1; b < 16; b++ ) {
Color16 cb(m_color[b]);
if( cb.u > cmax.u ) {
@ -302,9 +312,6 @@ void ColorBlock::sortColorsByAbsoluteValue()
cmax = cb;
}
}
Color32 tmp;
swap( m_color[a], m_color[max], tmp );
swap( m_color[a], m_color[max] );
}
}

@ -45,16 +45,17 @@ struct ColorBlock
{
ColorBlock();
ColorBlock(const ColorBlock & block);
ColorBlock(const Image * img, unsigned int x, unsigned int y);
ColorBlock(const Image * img, uint x, uint y);
void init(const Image * img, unsigned int x, unsigned int y);
void init(const Image * img, uint x, uint y);
void swizzleDXT5n();
void splatX();
void splatY();
unsigned int countUniqueColors() const;
uint countUniqueColors() const;
Color32 averageColor() const;
bool hasAlpha() const;
void diameterRange(Color32 * start, Color32 * end) const;
void luminanceRange(Color32 * start, Color32 * end) const;
@ -69,11 +70,11 @@ struct ColorBlock
// Accessors
const Color32 * colors() const;
Color32 color(unsigned int i) const;
Color32 & color(unsigned int i);
Color32 color(uint i) const;
Color32 & color(uint i);
Color32 color(unsigned int x, unsigned int y) const;
Color32 & color(unsigned int x, unsigned int y);
Color32 color(uint x, uint y) const;
Color32 & color(uint x, uint y);
private:
@ -89,25 +90,25 @@ inline const Color32 * ColorBlock::colors() const
}
/// Get block color.
inline Color32 ColorBlock::color(unsigned int i) const
inline Color32 ColorBlock::color(uint i) const
{
return m_color[i];
}
/// Get block color.
inline Color32 & ColorBlock::color(unsigned int i)
inline Color32 & ColorBlock::color(uint i)
{
return m_color[i];
}
/// Get block color.
inline Color32 ColorBlock::color(unsigned int x, unsigned int y) const
inline Color32 ColorBlock::color(uint x, uint y) const
{
return m_color[y * 4 + x];
}
/// Get block color.
inline Color32 & ColorBlock::color(unsigned int x, unsigned int y)
inline Color32 & ColorBlock::color(uint x, uint y)
{
return m_color[y * 4 + x];
}

@ -37,8 +37,20 @@
#ifndef clamp
#define clamp(x,a,b) min(max((x), (a)), (b))
#endif
#ifndef swap
#define swap(a,b,tmp) tmp=a; a=b; b=tmp;
#endif
template<typename T>
inline void
swap(T & a, T & b)
{
T tmp = a;
a = b;
b = tmp;
}
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#endif

@ -55,9 +55,9 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#include <Common.h>
#include <DirectDrawSurface.h>
#include <BlockDXT.h>
#include <PixelFormat.h>
#include <stdio.h> // printf
#include <math.h> // sqrt
@ -66,92 +66,220 @@
#if !defined(MAKEFOURCC)
# define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((unsigned int)((unsigned char)(ch0)) | \
((unsigned int)((unsigned char)(ch1)) << 8) | \
((unsigned int)((unsigned char)(ch2)) << 16) | \
((unsigned int)((unsigned char)(ch3)) << 24 ))
((uint)((unsigned char)(ch0)) | \
((uint)((unsigned char)(ch1)) << 8) | \
((uint)((unsigned char)(ch2)) << 16) | \
((uint)((unsigned char)(ch3)) << 24 ))
#endif
static const unsigned int FOURCC_DDS = MAKEFOURCC('D', 'D', 'S', ' ');
static const unsigned int FOURCC_DXT1 = MAKEFOURCC('D', 'X', 'T', '1');
static const unsigned int FOURCC_DXT2 = MAKEFOURCC('D', 'X', 'T', '2');
static const unsigned int FOURCC_DXT3 = MAKEFOURCC('D', 'X', 'T', '3');
static const unsigned int FOURCC_DXT4 = MAKEFOURCC('D', 'X', 'T', '4');
static const unsigned int FOURCC_DXT5 = MAKEFOURCC('D', 'X', 'T', '5');
static const unsigned int FOURCC_RXGB = MAKEFOURCC('R', 'X', 'G', 'B');
static const unsigned int FOURCC_ATI1 = MAKEFOURCC('A', 'T', 'I', '1');
static const unsigned int FOURCC_ATI2 = MAKEFOURCC('A', 'T', 'I', '2');
static const uint FOURCC_DDS = MAKEFOURCC('D', 'D', 'S', ' ');
static const uint FOURCC_DXT1 = MAKEFOURCC('D', 'X', 'T', '1');
static const uint FOURCC_DXT2 = MAKEFOURCC('D', 'X', 'T', '2');
static const uint FOURCC_DXT3 = MAKEFOURCC('D', 'X', 'T', '3');
static const uint FOURCC_DXT4 = MAKEFOURCC('D', 'X', 'T', '4');
static const uint FOURCC_DXT5 = MAKEFOURCC('D', 'X', 'T', '5');
static const uint FOURCC_RXGB = MAKEFOURCC('R', 'X', 'G', 'B');
static const uint FOURCC_ATI1 = MAKEFOURCC('A', 'T', 'I', '1');
static const uint FOURCC_ATI2 = MAKEFOURCC('A', 'T', 'I', '2');
// RGB formats.
static const unsigned int D3DFMT_R8G8B8 = 20;
static const unsigned int D3DFMT_A8R8G8B8 = 21;
static const unsigned int D3DFMT_X8R8G8B8 = 22;
static const unsigned int D3DFMT_R5G6B5 = 23;
static const unsigned int D3DFMT_X1R5G5B5 = 24;
static const unsigned int D3DFMT_A1R5G5B5 = 25;
static const unsigned int D3DFMT_A4R4G4B4 = 26;
static const unsigned int D3DFMT_R3G3B2 = 27;
static const unsigned int D3DFMT_A8 = 28;
static const unsigned int D3DFMT_A8R3G3B2 = 29;
static const unsigned int D3DFMT_X4R4G4B4 = 30;
static const unsigned int D3DFMT_A2B10G10R10 = 31;
static const unsigned int D3DFMT_A8B8G8R8 = 32;
static const unsigned int D3DFMT_X8B8G8R8 = 33;
static const unsigned int D3DFMT_G16R16 = 34;
static const unsigned int D3DFMT_A2R10G10B10 = 35;
static const unsigned int D3DFMT_A16B16G16R16 = 36;
// 32 bit RGB formats.
static const uint D3DFMT_R8G8B8 = 20;
static const uint D3DFMT_A8R8G8B8 = 21;
static const uint D3DFMT_X8R8G8B8 = 22;
static const uint D3DFMT_R5G6B5 = 23;
static const uint D3DFMT_X1R5G5B5 = 24;
static const uint D3DFMT_A1R5G5B5 = 25;
static const uint D3DFMT_A4R4G4B4 = 26;
static const uint D3DFMT_R3G3B2 = 27;
static const uint D3DFMT_A8 = 28;
static const uint D3DFMT_A8R3G3B2 = 29;
static const uint D3DFMT_X4R4G4B4 = 30;
static const uint D3DFMT_A2B10G10R10 = 31;
static const uint D3DFMT_A8B8G8R8 = 32;
static const uint D3DFMT_X8B8G8R8 = 33;
static const uint D3DFMT_G16R16 = 34;
static const uint D3DFMT_A2R10G10B10 = 35;
static const uint D3DFMT_A16B16G16R16 = 36;
// Palette formats.
static const unsigned int D3DFMT_A8P8 = 40;
static const unsigned int D3DFMT_P8 = 41;
static const uint D3DFMT_A8P8 = 40;
static const uint D3DFMT_P8 = 41;
// Luminance formats.
static const unsigned int D3DFMT_L8 = 50;
static const unsigned int D3DFMT_A8L8 = 51;
static const unsigned int D3DFMT_A4L4 = 52;
static const uint D3DFMT_L8 = 50;
static const uint D3DFMT_A8L8 = 51;
static const uint D3DFMT_A4L4 = 52;
static const uint D3DFMT_L16 = 81;
// Floating point formats
static const unsigned int D3DFMT_R16F = 111;
static const unsigned int D3DFMT_G16R16F = 112;
static const unsigned int D3DFMT_A16B16G16R16F = 113;
static const unsigned int D3DFMT_R32F = 114;
static const unsigned int D3DFMT_G32R32F = 115;
static const unsigned int D3DFMT_A32B32G32R32F = 116;
static const uint D3DFMT_R16F = 111;
static const uint D3DFMT_G16R16F = 112;
static const uint D3DFMT_A16B16G16R16F = 113;
static const uint D3DFMT_R32F = 114;
static const uint D3DFMT_G32R32F = 115;
static const uint D3DFMT_A32B32G32R32F = 116;
static const unsigned int DDSD_CAPS = 0x00000001U;
static const unsigned int DDSD_PIXELFORMAT = 0x00001000U;
static const unsigned int DDSD_WIDTH = 0x00000004U;
static const unsigned int DDSD_HEIGHT = 0x00000002U;
static const unsigned int DDSD_PITCH = 0x00000008U;
static const unsigned int DDSD_MIPMAPCOUNT = 0x00020000U;
static const unsigned int DDSD_LINEARSIZE = 0x00080000U;
static const unsigned int DDSD_DEPTH = 0x00800000U;
static const uint DDSD_CAPS = 0x00000001U;
static const uint DDSD_PIXELFORMAT = 0x00001000U;
static const uint DDSD_WIDTH = 0x00000004U;
static const uint DDSD_HEIGHT = 0x00000002U;
static const uint DDSD_PITCH = 0x00000008U;
static const uint DDSD_MIPMAPCOUNT = 0x00020000U;
static const uint DDSD_LINEARSIZE = 0x00080000U;
static const uint DDSD_DEPTH = 0x00800000U;
static const unsigned int DDSCAPS_COMPLEX = 0x00000008U;
static const unsigned int DDSCAPS_TEXTURE = 0x00001000U;
static const unsigned int DDSCAPS_MIPMAP = 0x00400000U;
static const unsigned int DDSCAPS2_VOLUME = 0x00200000U;
static const unsigned int DDSCAPS2_CUBEMAP = 0x00000200U;
static const uint DDSCAPS_COMPLEX = 0x00000008U;
static const uint DDSCAPS_TEXTURE = 0x00001000U;
static const uint DDSCAPS_MIPMAP = 0x00400000U;
static const uint DDSCAPS2_VOLUME = 0x00200000U;
static const uint DDSCAPS2_CUBEMAP = 0x00000200U;
static const unsigned int DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400U;
static const unsigned int DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800U;
static const unsigned int DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000U;
static const unsigned int DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000U;
static const unsigned int DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000U;
static const unsigned int DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000U;
static const unsigned int DDSCAPS2_CUBEMAP_ALL_FACES = 0x0000FC00U;
static const uint DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400U;
static const uint DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800U;
static const uint DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000U;
static const uint DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000U;
static const uint DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000U;
static const uint DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000U;
static const uint DDSCAPS2_CUBEMAP_ALL_FACES = 0x0000FC00U;
static const unsigned int DDPF_ALPHAPIXELS = 0x00000001U;
static const unsigned int DDPF_ALPHA = 0x00000002U;
static const unsigned int DDPF_FOURCC = 0x00000004U;
static const unsigned int DDPF_RGB = 0x00000040U;
static const unsigned int DDPF_PALETTEINDEXED1 = 0x00000800U;
static const unsigned int DDPF_PALETTEINDEXED2 = 0x00001000U;
static const unsigned int DDPF_PALETTEINDEXED4 = 0x00000008U;
static const unsigned int DDPF_PALETTEINDEXED8 = 0x00000020U;
static const unsigned int DDPF_LUMINANCE = 0x00020000U;
static const unsigned int DDPF_ALPHAPREMULT = 0x00008000U;
static const unsigned int DDPF_NORMAL = 0x80000000U; // @@ Custom nv flag.
static const uint DDPF_ALPHAPIXELS = 0x00000001U;
static const uint DDPF_ALPHA = 0x00000002U;
static const uint DDPF_FOURCC = 0x00000004U;
static const uint DDPF_RGB = 0x00000040U;
static const uint DDPF_PALETTEINDEXED1 = 0x00000800U;
static const uint DDPF_PALETTEINDEXED2 = 0x00001000U;
static const uint DDPF_PALETTEINDEXED4 = 0x00000008U;
static const uint DDPF_PALETTEINDEXED8 = 0x00000020U;
static const uint DDPF_LUMINANCE = 0x00020000U;
static const uint DDPF_ALPHAPREMULT = 0x00008000U;
static const uint DDPF_NORMAL = 0x80000000U; // @@ Custom nv flag.
// DX10 formats.
enum DXGI_FORMAT
{
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
};
enum D3D10_RESOURCE_DIMENSION
{
D3D10_RESOURCE_DIMENSION_UNKNOWN = 0,
D3D10_RESOURCE_DIMENSION_BUFFER = 1,
D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2,
D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3,
D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4,
};
/*** implementation ***/
@ -175,6 +303,15 @@ void mem_read(Stream & mem, DDSCaps & caps)
mem_read(mem, caps.caps4);
}
void mem_read(Stream & mem, DDSHeader10 & header)
{
mem_read(mem, header.dxgiFormat);
mem_read(mem, header.resourceDimension);
mem_read(mem, header.miscFlag);
mem_read(mem, header.arraySize);
mem_read(mem, header.reserved);
}
void mem_read(Stream & mem, DDSHeader & header)
{
mem_read(mem, header.fourcc);
@ -185,12 +322,19 @@ void mem_read(Stream & mem, DDSHeader & header)
mem_read(mem, header.pitch);
mem_read(mem, header.depth);
mem_read(mem, header.mipmapcount);
for (unsigned int i = 0; i < 11; i++) mem_read(mem, header.reserved[i]);
for (uint i = 0; i < 11; i++) mem_read(mem, header.reserved[i]);
mem_read(mem, header.pf);
mem_read(mem, header.caps);
mem_read(mem, header.notused);
if (header.hasDX10Header())
{
mem_read(mem, header.header10);
}
}
DDSHeader::DDSHeader()
{
this->fourcc = FOURCC_DDS;
@ -201,11 +345,11 @@ DDSHeader::DDSHeader()
this->pitch = 0;
this->depth = 0;
this->mipmapcount = 0;
for (unsigned int i = 0; i < 11; i++) this->reserved[i] = 0;
for (uint i = 0; i < 11; i++) this->reserved[i] = 0;
// Store version information on the reserved header attributes.
this->reserved[9] = MAKEFOURCC('N', 'V', 'T', 'T');
this->reserved[10] = (0 << 16) | (9 << 8) | (3); // major.minor.revision
this->reserved[10] = (0 << 16) | (9 << 8) | (5); // major.minor.revision
this->pf.size = 32;
this->pf.flags = 0;
@ -220,29 +364,35 @@ DDSHeader::DDSHeader()
this->caps.caps3 = 0;
this->caps.caps4 = 0;
this->notused = 0;
this->header10.dxgiFormat = DXGI_FORMAT_UNKNOWN;
this->header10.resourceDimension = D3D10_RESOURCE_DIMENSION_UNKNOWN;
this->header10.miscFlag = 0;
this->header10.arraySize = 0;
this->header10.reserved = 0;
}
void DDSHeader::setWidth(unsigned int w)
void DDSHeader::setWidth(uint w)
{
this->flags |= DDSD_WIDTH;
this->width = w;
}
void DDSHeader::setHeight(unsigned int h)
void DDSHeader::setHeight(uint h)
{
this->flags |= DDSD_HEIGHT;
this->height = h;
}
void DDSHeader::setDepth(unsigned int d)
void DDSHeader::setDepth(uint d)
{
this->flags |= DDSD_DEPTH;
this->height = d;
}
void DDSHeader::setMipmapCount(unsigned int count)
void DDSHeader::setMipmapCount(uint count)
{
if (count == 0)
if (count == 0 || count == 1)
{
this->flags &= ~DDSD_MIPMAPCOUNT;
this->mipmapcount = 0;
@ -265,35 +415,40 @@ void DDSHeader::setMipmapCount(unsigned int count)
void DDSHeader::setTexture2D()
{
// nothing to do here.
this->header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE2D;
}
void DDSHeader::setTexture3D()
{
this->caps.caps2 = DDSCAPS2_VOLUME;
this->header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE3D;
}
void DDSHeader::setTextureCube()
{
this->caps.caps1 |= DDSCAPS_COMPLEX;
this->caps.caps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_ALL_FACES;
this->header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE2D;
this->header10.arraySize = 6;
}
void DDSHeader::setLinearSize(unsigned int size)
void DDSHeader::setLinearSize(uint size)
{
this->flags &= ~DDSD_PITCH;
this->flags |= DDSD_LINEARSIZE;
this->pitch = size;
}
void DDSHeader::setPitch(unsigned int pitch)
void DDSHeader::setPitch(uint pitch)
{
this->flags &= ~DDSD_LINEARSIZE;
this->flags |= DDSD_PITCH;
this->pitch = pitch;
}
void DDSHeader::setFourCC(unsigned char c0, unsigned char c1, unsigned char c2, unsigned char c3)
void DDSHeader::setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3)
{
// set fourcc pixel format.
this->pf.flags = DDPF_FOURCC;
@ -305,7 +460,7 @@ void DDSHeader::setFourCC(unsigned char c0, unsigned char c1, unsigned char c2,
this->pf.amask = 0;
}
void DDSHeader::setPixelFormat(unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask)
void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask)
{
// Make sure the masks are correct.
if ((rmask & gmask) || \
@ -327,15 +482,25 @@ void DDSHeader::setPixelFormat(unsigned int bitcount, unsigned int rmask, unsign
if (bitcount == 0)
{
// Compute bit count from the masks.
unsigned int total = rmask | gmask | bmask | amask;
uint total = rmask | gmask | bmask | amask;
while(total != 0) {
bitcount++;
total >>= 1;
}
// @@ Align to 8?
}
this->pf.fourcc = 0;
if (!(bitcount > 0 && bitcount <= 32)) {
printf("DDS: bad bit count, pixel format not set\n");
return;
}
// Align to 8.
if (bitcount < 8) bitcount = 8;
else if (bitcount < 16) bitcount = 16;
else if (bitcount < 24) bitcount = 24;
else bitcount = 32;
this->pf.fourcc = 0; //findD3D9Format(bitcount, rmask, gmask, bmask, amask);
this->pf.bitcount = bitcount;
this->pf.rmask = rmask;
this->pf.gmask = gmask;
@ -343,46 +508,24 @@ void DDSHeader::setPixelFormat(unsigned int bitcount, unsigned int rmask, unsign
this->pf.amask = amask;
}
void DDSHeader::setDX10Format(uint format)
{
this->pf.flags = 0;
this->header10.dxgiFormat = format;
}
void DDSHeader::setNormalFlag(bool b)
{
if (b) this->pf.flags |= DDPF_NORMAL;
else this->pf.flags &= ~DDPF_NORMAL;
}
/*
void DDSHeader::swapBytes()
bool DDSHeader::hasDX10Header() const
{
this->fourcc = POSH_LittleU32(this->fourcc);
this->size = POSH_LittleU32(this->size);
this->flags = POSH_LittleU32(this->flags);
this->height = POSH_LittleU32(this->height);
this->width = POSH_LittleU32(this->width);
this->pitch = POSH_LittleU32(this->pitch);
this->depth = POSH_LittleU32(this->depth);
this->mipmapcount = POSH_LittleU32(this->mipmapcount);
for(int i = 0; i < 11; i++) {
this->reserved[i] = POSH_LittleU32(this->reserved[i]);
}
this->pf.size = POSH_LittleU32(this->pf.size);
this->pf.flags = POSH_LittleU32(this->pf.flags);
this->pf.fourcc = POSH_LittleU32(this->pf.fourcc);
this->pf.bitcount = POSH_LittleU32(this->pf.bitcount);
this->pf.rmask = POSH_LittleU32(this->pf.rmask);
this->pf.gmask = POSH_LittleU32(this->pf.gmask);
this->pf.bmask = POSH_LittleU32(this->pf.bmask);
this->pf.amask = POSH_LittleU32(this->pf.amask);
this->caps.caps1 = POSH_LittleU32(this->caps.caps1);
this->caps.caps2 = POSH_LittleU32(this->caps.caps2);
this->caps.caps3 = POSH_LittleU32(this->caps.caps3);
this->caps.caps4 = POSH_LittleU32(this->caps.caps4);
this->notused = POSH_LittleU32(this->notused);
return this->pf.flags == 0;
}
*/
DirectDrawSurface::DirectDrawSurface(unsigned char *mem, unsigned int size) : stream(mem, size), header()
DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header()
{
mem_read(stream, header);
}
@ -398,7 +541,7 @@ bool DirectDrawSurface::isValid() const
return false;
}
const unsigned int required = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS|DDSD_PIXELFORMAT);
const uint required = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS|DDSD_PIXELFORMAT);
if( (header.flags & required) != required ) {
return false;
}
@ -436,19 +579,7 @@ bool DirectDrawSurface::isSupported() const
}
else if (header.pf.flags & DDPF_RGB)
{
if (header.pf.bitcount == 24)
{
return true;
}
else if (header.pf.bitcount == 32)
{
return true;
}
else
{
// Unsupported pixel format.
return false;
}
// All RGB formats are supported now.
}
else
{
@ -471,26 +602,26 @@ bool DirectDrawSurface::isSupported() const
}
unsigned int DirectDrawSurface::mipmapCount() const
uint DirectDrawSurface::mipmapCount() const
{
if (header.flags & DDSD_MIPMAPCOUNT) return header.mipmapcount;
else return 0;
}
unsigned int DirectDrawSurface::width() const
uint DirectDrawSurface::width() const
{
if (header.flags & DDSD_WIDTH) return header.width;
else return 1;
}
unsigned int DirectDrawSurface::height() const
uint DirectDrawSurface::height() const
{
if (header.flags & DDSD_HEIGHT) return header.height;
else return 1;
}
unsigned int DirectDrawSurface::depth() const
uint DirectDrawSurface::depth() const
{
if (header.flags & DDSD_DEPTH) return header.depth;
else return 1;
@ -527,18 +658,18 @@ bool DirectDrawSurface::isTextureCube() const
return (header.caps.caps2 & DDSCAPS2_CUBEMAP) != 0;
}
void DirectDrawSurface::mipmap(Image * img, unsigned int face, unsigned int mipmap)
void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap)
{
stream.seek(offset(face, mipmap));
unsigned int w = width();
unsigned int h = height();
uint w = width();
uint h = height();
// Compute width and height.
for (unsigned int m = 0; m < mipmap; m++)
for (uint m = 0; m < mipmap; m++)
{
w = max(w/2, 1U);
h = max(h/2, 1U);
w = max(1U, w / 2);
h = max(1U, h / 2);
}
img->allocate(w, h);
@ -553,73 +684,30 @@ void DirectDrawSurface::mipmap(Image * img, unsigned int face, unsigned int mipm
}
}
/* helper function for readLinearImage */
void maskShiftAndSize(unsigned int mask, unsigned int * shift, unsigned int * size)
{
if (!mask)
{
*shift = 0;
*size = 0;
return;
}
*shift = 0;
while((mask & 1) == 0) {
++(*shift);
mask >>= 1;
}
*size = 0;
while((mask & 1) == 1) {
++(*size);
mask >>= 1;
}
}
/* helper function for readLinearImage */
unsigned int convert(unsigned int c, unsigned int inbits, unsigned int outbits)
{
if (inbits == 0) {
return 0;
}
else if (inbits == outbits)
{
return c;
}
else if (inbits > outbits)
{
// truncate
return c >> (inbits - outbits);
}
else
{
// bitexpand
return (c << (outbits - inbits)) | convert(c, inbits, outbits - inbits);
}
}
void DirectDrawSurface::readLinearImage(Image * img)
{
const unsigned int w = img->width();
const unsigned int h = img->height();
const uint w = img->width();
const uint h = img->height();
uint rshift, rsize;
PixelFormat::maskShiftAndSize(header.pf.rmask, &rshift, &rsize);
uint gshift, gsize;
PixelFormat::maskShiftAndSize(header.pf.gmask, &gshift, &gsize);
uint bshift, bsize;
PixelFormat::maskShiftAndSize(header.pf.bmask, &bshift, &bsize);
uint ashift, asize;
PixelFormat::maskShiftAndSize(header.pf.amask, &ashift, &asize);
unsigned int rshift, rsize;
maskShiftAndSize(header.pf.rmask, &rshift, &rsize);
unsigned int gshift, gsize;
maskShiftAndSize(header.pf.gmask, &gshift, &gsize);
unsigned int bshift, bsize;
maskShiftAndSize(header.pf.bmask, &bshift, &bsize);
unsigned int ashift, asize;
maskShiftAndSize(header.pf.amask, &ashift, &asize);
uint byteCount = (header.pf.bitcount + 7) / 8;
unsigned int byteCount = (header.pf.bitcount + 7) / 8;
if (byteCount > 4)
{
/* just in case... we could have segfaults later on if byteCount > 4 */
printf("DDS: bitcount too large (file corrupt?)");
printf("DDS: bitcount too large");
return;
}
@ -629,18 +717,18 @@ void DirectDrawSurface::readLinearImage(Image * img)
}
// Read linear RGB images.
for (unsigned int y = 0; y < h; y++)
for (uint y = 0; y < h; y++)
{
for (unsigned int x = 0; x < w; x++)
for (uint x = 0; x < w; x++)
{
unsigned int c = 0;
uint c = 0;
mem_read(stream, (unsigned char *)(&c), byteCount);
Color32 pixel(0, 0, 0, 0xFF);
pixel.r = convert(c >> rshift, rsize, 8);
pixel.g = convert(c >> gshift, gsize, 8);
pixel.b = convert(c >> bshift, bsize, 8);
pixel.a = convert(c >> ashift, asize, 8);
pixel.r = PixelFormat::convert(c >> rshift, rsize, 8);
pixel.g = PixelFormat::convert(c >> gshift, gsize, 8);
pixel.b = PixelFormat::convert(c >> bshift, bsize, 8);
pixel.a = PixelFormat::convert(c >> ashift, asize, 8);
img->pixel(x, y) = pixel;
}
@ -649,15 +737,15 @@ void DirectDrawSurface::readLinearImage(Image * img)
void DirectDrawSurface::readBlockImage(Image * img)
{
const unsigned int w = img->width();
const unsigned int h = img->height();
const uint w = img->width();
const uint h = img->height();
const unsigned int bw = (w + 3) / 4;
const unsigned int bh = (h + 3) / 4;
const uint bw = (w + 3) / 4;
const uint bh = (h + 3) / 4;
for (unsigned int by = 0; by < bh; by++)
for (uint by = 0; by < bh; by++)
{
for (unsigned int bx = 0; bx < bw; bx++)
for (uint bx = 0; bx < bw; bx++)
{
ColorBlock block;
@ -665,9 +753,9 @@ void DirectDrawSurface::readBlockImage(Image * img)
readBlock(&block);
// Write color block.
for (unsigned int y = 0; y < min(4U, h-4*by); y++)
for (uint y = 0; y < min(4U, h-4*by); y++)
{
for (unsigned int x = 0; x < min(4U, w-4*bx); x++)
for (uint x = 0; x < min(4U, w-4*bx); x++)
{
img->pixel(4*bx+x, 4*by+y) = block.color(x, y);
}
@ -676,12 +764,13 @@ void DirectDrawSurface::readBlockImage(Image * img)
}
}
static Color32 buildNormal(unsigned char x, unsigned char y)
static Color32 buildNormal(uint8 x, uint8 y)
{
float nx = 2 * (x / 255) - 1;
float ny = 2 * (x / 255) - 1;
float nz = sqrt(1 - nx*nx - ny*ny);
unsigned char z = clamp(int(255 * (nz + 1) / 2), 0, 255);
float nx = 2 * (x / 255.0f) - 1;
float ny = 2 * (y / 255.0f) - 1;
float nz = 0.0f;
if (1 - nx*nx - ny*ny > 0) nz = sqrtf(1 - nx*nx - ny*ny);
uint8 z = clamp(int(255.0f * (nz + 1) / 2.0f), 0, 255);
return Color32(x, y, z);
}
@ -716,7 +805,7 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba)
for (int i = 0; i < 16; i++)
{
Color32 & c = rgba->color(i);
unsigned int tmp = c.r;
uint tmp = c.r;
c.r = c.a;
c.a = tmp;
}
@ -751,14 +840,14 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba)
for (int i = 0; i < 16; i++)
{
Color32 & c = rgba->color(i);
c = buildNormal(c.g, c.a);
c = buildNormal(c.a, c.g);
}
}
}
}
unsigned int DirectDrawSurface::blockSize() const
uint DirectDrawSurface::blockSize() const
{
switch(header.pf.fourcc)
{
@ -778,13 +867,13 @@ unsigned int DirectDrawSurface::blockSize() const
return 0;
}
unsigned int DirectDrawSurface::mipmapSize(unsigned int mipmap) const
uint DirectDrawSurface::mipmapSize(uint mipmap) const
{
unsigned int w = width();
unsigned int h = height();
unsigned int d = depth();
uint w = width();
uint h = height();
uint d = depth();
for (unsigned int m = 0; m < mipmap; m++)
for (uint m = 0; m < mipmap; m++)
{
w = max(1U, w / 2);
h = max(1U, h / 2);
@ -801,10 +890,10 @@ unsigned int DirectDrawSurface::mipmapSize(unsigned int mipmap) const
else if (header.pf.flags & DDPF_RGB)
{
// Align pixels to bytes.
unsigned int byteCount = (header.pf.bitcount + 7) / 8;
uint byteCount = (header.pf.bitcount + 7) / 8;
// Align pitch to 4 bytes.
unsigned int pitch = 4 * ((w * byteCount + 3) / 4);
uint pitch = 4 * ((w * byteCount + 3) / 4);
return pitch * h * d;
}
@ -814,12 +903,12 @@ unsigned int DirectDrawSurface::mipmapSize(unsigned int mipmap) const
};
}
unsigned int DirectDrawSurface::faceSize() const
uint DirectDrawSurface::faceSize() const
{
const unsigned int count = mipmapCount();
unsigned int size = 0;
const uint count = mipmapCount();
uint size = 0;
for (unsigned int m = 0; m < count; m++)
for (uint m = 0; m < count; m++)
{
size += mipmapSize(m);
}
@ -827,16 +916,16 @@ unsigned int DirectDrawSurface::faceSize() const
return size;
}
unsigned int DirectDrawSurface::offset(const unsigned int face, const unsigned int mipmap)
uint DirectDrawSurface::offset(const uint face, const uint mipmap)
{
unsigned int size = sizeof(DDSHeader);
uint size = 128; //sizeof(DDSHeader);
if (face != 0)
{
size += face * faceSize();
}
for (unsigned int m = 0; m < mipmap; m++)
for (uint m = 0; m < mipmap; m++)
{
size += mipmapSize(m);
}
@ -911,6 +1000,15 @@ void DirectDrawSurface::printInfo() const
printf("\tCaps 3: 0x%.8X\n", header.caps.caps3);
printf("\tCaps 4: 0x%.8X\n", header.caps.caps4);
if (header.pf.flags == 0)
{
printf("DX10 Header:\n");
printf("\tDXGI Format: %u\n", header.header10.dxgiFormat);
printf("\tResource dimension: %u\n", header.header10.resourceDimension);
printf("\tMisc flag: %u\n", header.header10.miscFlag);
printf("\tArray size: %u\n", header.header10.arraySize);
}
if (header.reserved[9] == MAKEFOURCC('N', 'V', 'T', 'T'))
{
int major = (header.reserved[10] >> 16) & 0xFF;

@ -58,92 +58,110 @@
#ifndef _DDS_DIRECTDRAWSURFACE_H
#define _DDS_DIRECTDRAWSURFACE_H
#include <Common.h>
#include <Stream.h>
#include <ColorBlock.h>
#include <Image.h>
struct DDSPixelFormat {
unsigned int size;
unsigned int flags;
unsigned int fourcc;
unsigned int bitcount;
unsigned int rmask;
unsigned int gmask;
unsigned int bmask;
unsigned int amask;
struct DDSPixelFormat
{
uint size;
uint flags;
uint fourcc;
uint bitcount;
uint rmask;
uint gmask;
uint bmask;
uint amask;
};
struct DDSCaps {
unsigned int caps1;
unsigned int caps2;
unsigned int caps3;
unsigned int caps4;
struct DDSCaps
{
uint caps1;
uint caps2;
uint caps3;
uint caps4;
};
/// DDS file header for DX10.
struct DDSHeader10
{
uint dxgiFormat;
uint resourceDimension;
uint miscFlag;
uint arraySize;
uint reserved;
};
/// DDS file header.
struct DDSHeader {
unsigned int fourcc;
unsigned int size;
unsigned int flags;
unsigned int height;
unsigned int width;
unsigned int pitch;
unsigned int depth;
unsigned int mipmapcount;
unsigned int reserved[11];
struct DDSHeader
{
uint fourcc;
uint size;
uint flags;
uint height;
uint width;
uint pitch;
uint depth;
uint mipmapcount;
uint reserved[11];
DDSPixelFormat pf;
DDSCaps caps;
unsigned int notused;
uint notused;
DDSHeader10 header10;
// Helper methods.
DDSHeader();
void setWidth(unsigned int w);
void setHeight(unsigned int h);
void setDepth(unsigned int d);
void setMipmapCount(unsigned int count);
void setWidth(uint w);
void setHeight(uint h);
void setDepth(uint d);
void setMipmapCount(uint count);
void setTexture2D();
void setTexture3D();
void setTextureCube();
void setLinearSize(unsigned int size);
void setPitch(unsigned int pitch);
void setFourCC(unsigned char c0, unsigned char c1, unsigned char c2, unsigned char c3);
void setPixelFormat(unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask);
void setLinearSize(uint size);
void setPitch(uint pitch);
void setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3);
void setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask);
void setDX10Format(uint format);
void setNormalFlag(bool b);
/* void swapBytes(); */
bool hasDX10Header() const;
};
/// DirectDraw Surface. (DDS)
class DirectDrawSurface
{
public:
DirectDrawSurface(unsigned char *mem, unsigned int size);
DirectDrawSurface(unsigned char *mem, uint size);
~DirectDrawSurface();
bool isValid() const;
bool isSupported() const;
unsigned int mipmapCount() const;
unsigned int width() const;
unsigned int height() const;
unsigned int depth() const;
uint mipmapCount() const;
uint width() const;
uint height() const;
uint depth() const;
bool isTexture2D() const;
bool isTexture3D() const;
bool isTextureCube() const;
bool hasAlpha() const; /* false for DXT1, true for all others */
bool hasAlpha() const; /* false for DXT1, true for all other DXTs */
void mipmap(Image * img, unsigned int f, unsigned int m);
void mipmap(Image * img, uint f, uint m);
// void mipmap(FloatImage * img, uint f, uint m);
void printInfo() const;
private:
unsigned int blockSize() const;
unsigned int faceSize() const;
unsigned int mipmapSize(unsigned int m) const;
uint blockSize() const;
uint faceSize() const;
uint mipmapSize(uint m) const;
unsigned int offset(unsigned int f, unsigned int m);
uint offset(uint f, uint m);
void readLinearImage(Image * img);
void readBlockImage(Image * img);
@ -158,5 +176,6 @@ private:
void mem_read(Stream & mem, DDSPixelFormat & pf);
void mem_read(Stream & mem, DDSCaps & caps);
void mem_read(Stream & mem, DDSHeader & header);
void mem_read(Stream & mem, DDSHeader10 & header);
#endif // _DDS_DIRECTDRAWSURFACE_H

@ -48,7 +48,7 @@ Image::~Image()
free();
}
void Image::allocate(unsigned int w, unsigned int h)
void Image::allocate(uint w, uint h)
{
free();
m_width = w;
@ -63,17 +63,17 @@ void Image::free()
}
unsigned int Image::width() const
uint Image::width() const
{
return m_width;
}
unsigned int Image::height() const
uint Image::height() const
{
return m_height;
}
const Color32 * Image::scanline(unsigned int h) const
const Color32 * Image::scanline(uint h) const
{
if (h >= m_height) {
printf("DDS: scanline beyond dimensions of image");
@ -82,7 +82,7 @@ const Color32 * Image::scanline(unsigned int h) const
return m_data + h * m_width;
}
Color32 * Image::scanline(unsigned int h)
Color32 * Image::scanline(uint h)
{
if (h >= m_height) {
printf("DDS: scanline beyond dimensions of image");
@ -101,7 +101,7 @@ Color32 * Image::pixels()
return m_data;
}
const Color32 & Image::pixel(unsigned int idx) const
const Color32 & Image::pixel(uint idx) const
{
if (idx >= m_width * m_height) {
printf("DDS: pixel beyond dimensions of image");
@ -110,7 +110,7 @@ const Color32 & Image::pixel(unsigned int idx) const
return m_data[idx];
}
Color32 & Image::pixel(unsigned int idx)
Color32 & Image::pixel(uint idx)
{
if (idx >= m_width * m_height) {
printf("DDS: pixel beyond dimensions of image");

@ -37,6 +37,7 @@
#ifndef _DDS_IMAGE_H
#define _DDS_IMAGE_H
#include <Common.h>
#include <Color.h>
/// 32 bit RGBA image.
@ -53,28 +54,28 @@ public:
Image();
~Image();
void allocate(unsigned int w, unsigned int h);
void allocate(uint w, uint h);
/*
bool load(const char * name);
void wrap(void * data, unsigned int w, unsigned int h);
void wrap(void * data, uint w, uint h);
void unwrap();
*/
unsigned int width() const;
unsigned int height() const;
uint width() const;
uint height() const;
const Color32 * scanline(unsigned int h) const;
Color32 * scanline(unsigned int h);
const Color32 * scanline(uint h) const;
Color32 * scanline(uint h);
const Color32 * pixels() const;
Color32 * pixels();
const Color32 & pixel(unsigned int idx) const;
Color32 & pixel(unsigned int idx);
const Color32 & pixel(uint idx) const;
Color32 & pixel(uint idx);
const Color32 & pixel(unsigned int x, unsigned int y) const;
Color32 & pixel(unsigned int x, unsigned int y);
const Color32 & pixel(uint x, uint y) const;
Color32 & pixel(uint x, uint y);
Format format() const;
void setFormat(Format f);
@ -83,19 +84,19 @@ private:
void free();
private:
unsigned int m_width;
unsigned int m_height;
uint m_width;
uint m_height;
Format m_format;
Color32 * m_data;
};
inline const Color32 & Image::pixel(unsigned int x, unsigned int y) const
inline const Color32 & Image::pixel(uint x, uint y) const
{
return pixel(y * width() + x);
}
inline Color32 & Image::pixel(unsigned int x, unsigned int y)
inline Color32 & Image::pixel(uint x, uint y)
{
return pixel(y * width() + x);
}

@ -0,0 +1,110 @@
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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.
*
* Contributors: Amorilia (amorilia@gamebox.net)
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/*
* This file is based on a similar file from the NVIDIA texture tools
* (http://nvidia-texture-tools.googlecode.com/)
*
* Original license from NVIDIA follows.
*/
// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#ifndef _DDS_PIXELFORMAT_H
#define _DDS_PIXELFORMAT_H
#include <Common.h>
namespace PixelFormat
{
// Convert component @a c having @a inbits to the returned value having @a outbits.
inline uint convert(uint c, uint inbits, uint outbits)
{
if (inbits == 0)
{
return 0;
}
else if (inbits >= outbits)
{
// truncate
return c >> (inbits - outbits);
}
else
{
// bitexpand
return (c << (outbits - inbits)) | convert(c, inbits, outbits - inbits);
}
}
// Get pixel component shift and size given its mask.
inline void maskShiftAndSize(uint mask, uint * shift, uint * size)
{
if (!mask)
{
*shift = 0;
*size = 0;
return;
}
*shift = 0;
while((mask & 1) == 0) {
++(*shift);
mask >>= 1;
}
*size = 0;
while((mask & 1) == 1) {
++(*size);
mask >>= 1;
}
}
} // PixelFormat namespace
#endif // _DDS_IMAGE_PIXELFORMAT_H

@ -242,7 +242,7 @@ void IMB_filter(struct ImBuf *ibuf)
#define EXTEND_PIXEL(a, w) if((a)[3]) {r+= w*(a)[0]; g+= w*(a)[1]; b+= w*(a)[2]; tot+=w;}
/* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 255 */
/* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0 */
void IMB_filter_extend(struct ImBuf *ibuf)
{
register char *row1, *row2, *row3;
@ -251,7 +251,57 @@ void IMB_filter_extend(struct ImBuf *ibuf)
rowlen= ibuf->x;
if(ibuf->rect) {
if (ibuf->rect_float) {
float *temprect;
float *row1f, *row2f, *row3f;
float *fp;
int pixlen = 4;
temprect= MEM_dupallocN(ibuf->rect_float);
for(y=1; y<=ibuf->y; y++) {
/* setup rows */
row1f= (float *)(temprect + (y-2)*rowlen*4);
row2f= row1f + 4*rowlen;
row3f= row2f + 4*rowlen;
if(y==1)
row1f= row2f;
else if(y==ibuf->y)
row3f= row2f;
fp= (float *)(ibuf->rect_float + (y-1)*rowlen*4);
for(x=0; x<rowlen; x++) {
if(fp[3]==0.0f) {
int tot= 0;
float r=0.0f, g=0.0f, b=0.0f;
EXTEND_PIXEL(row1f, 1);
EXTEND_PIXEL(row2f, 2);
EXTEND_PIXEL(row3f, 1);
EXTEND_PIXEL(row1f+4, 2);
EXTEND_PIXEL(row3f+4, 2);
if(x!=rowlen-1) {
EXTEND_PIXEL(row1f+8, 1);
EXTEND_PIXEL(row2f+8, 2);
EXTEND_PIXEL(row3f+8, 1);
}
if(tot) {
fp[0]= r/tot;
fp[1]= g/tot;
fp[2]= b/tot;
fp[3]= 1.0;
}
}
fp+=4;
if(x!=0) {
row1f+=4; row2f+=4; row3f+=4;
}
}
}
}
else if(ibuf->rect) {
int *temprect;
/* make a copy, to prevent flooding */

@ -41,6 +41,7 @@
#include "imbuf_patch.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_imginfo.h"
#include "IMB_jpeg.h"
#include "jpeglib.h"
@ -244,11 +245,14 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f
int x, y, depth, r, g, b, k;
struct ImBuf * ibuf = 0;
uchar * rect;
jpeg_saved_marker_ptr marker;
char *str, *key, *value;
/* install own app1 handler */
ibuf_ftype = 0;
jpeg_set_marker_processor(cinfo, 0xe1, handle_app1);
cinfo->dct_method = JDCT_FLOAT;
jpeg_save_markers(cinfo, JPEG_COM, 0xffff);
if (jpeg_read_header(cinfo, FALSE) == JPEG_HEADER_OK) {
x = cinfo->image_width;
@ -335,6 +339,64 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f
}
}
}
marker= cinfo->marker_list;
while(marker) {
if(marker->marker != JPEG_COM)
goto next_stamp_marker;
/*
* Because JPEG format don't support the
* pair "key/value" like PNG, we store the
* stampinfo in a single "encode" string:
* "Blender:key:value"
*
* That is why we need split it to the
* common key/value here.
*/
if(strncmp((char *) marker->data, "Blender", 7)) {
/*
* Maybe the file have text that
* we don't know "what it's", in that
* case we keep the text (with a
* key "None").
* This is only for don't "lose"
* the information when we write
* it back to disk.
*/
IMB_imginfo_add_field(ibuf, "None", (char *) marker->data);
ibuf->flags |= IB_imginfo;
goto next_stamp_marker;
}
str = BLI_strdup ((char *) marker->data);
key = strchr (str, ':');
/*
* A little paranoid, but the file maybe
* is broken... and a "extra" check is better
* that a segfaul ;)
*/
if (!key) {
MEM_freeN(str);
goto next_stamp_marker;
}
key++;
value = strchr (key, ':');
if (!value) {
MEM_freeN(str);
goto next_stamp_marker;
}
*value = '\0'; /* need finish the key string */
value++;
IMB_imginfo_add_field(ibuf, key, value);
ibuf->flags |= IB_imginfo;
MEM_freeN(str);
next_stamp_marker:
marker= marker->next;
}
jpeg_finish_decompress(cinfo);
}
@ -391,7 +453,8 @@ static void write_jpeg(struct jpeg_compress_struct * cinfo, struct ImBuf * ibuf)
uchar * rect;
int x, y;
char neogeo[128];
ImgInfo *iptr;
char *text;
jpeg_start_compress(cinfo, TRUE);
@ -401,6 +464,33 @@ static void write_jpeg(struct jpeg_compress_struct * cinfo, struct ImBuf * ibuf)
memcpy(neogeo + 6, &ibuf_ftype, 4);
jpeg_write_marker(cinfo, 0xe1, (JOCTET*) neogeo, 10);
if(ibuf->img_info) {
/* key + max value + "Blender" */
text= MEM_mallocN(530, "stamp info read");
iptr= ibuf->img_info;
while(iptr) {
if (!strcmp (iptr->key, "None")) {
jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) iptr->value, strlen (iptr->value) + 1);
goto next_stamp_info;
}
/*
* The JPEG format don't support a pair "key/value"
* like PNG, so we "encode" the stamp in a
* single string:
* "Blender:key:value"
*
* The first "Blender" is a simple identify to help
* in the read process.
*/
sprintf (text, "Blender:%s:%s", iptr->key, iptr->value);
jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) text, strlen (text)+1);
next_stamp_info:
iptr = iptr->next;
}
MEM_freeN(text);
}
row_pointer[0] =
mallocstruct(JSAMPLE,
cinfo->input_components *

@ -43,48 +43,55 @@
void IMB_flipy(struct ImBuf * ibuf)
{
short x, y;
unsigned int *top, *bottom, do_float=0, *line;
float *topf=NULL, *bottomf=NULL, *linef=NULL;
int x, y;
if (ibuf == NULL) return;
if (ibuf->rect == NULL) return;
if (ibuf->rect_float) do_float =1;
x = ibuf->x;
y = ibuf->y;
if (ibuf->rect) {
unsigned int *top, *bottom, *line;
top = ibuf->rect;
bottom = top + ((y-1) * x);
line= MEM_mallocN(x*sizeof(int), "linebuf");
x = ibuf->x;
y = ibuf->y;
top = ibuf->rect;
bottom = top + ((y-1) * x);
line= MEM_mallocN(x*sizeof(int), "linebuf");
if (do_float) {
y >>= 1;
for(;y>0;y--) {
memcpy(line, top, x*sizeof(int));
memcpy(top, bottom, x*sizeof(int));
memcpy(bottom, line, x*sizeof(int));
bottom -= x;
top+= x;
}
MEM_freeN(line);
}
if (ibuf->rect_float) {
float *topf=NULL, *bottomf=NULL, *linef=NULL;
x = ibuf->x;
y = ibuf->y;
topf= ibuf->rect_float;
bottomf = topf + 4*((y-1) * x);
linef= MEM_mallocN(4*x*sizeof(float), "linebuff");
}
y >>= 1;
for(;y>0;y--) {
memcpy(line, top, x*sizeof(int));
memcpy(top, bottom, x*sizeof(int));
memcpy(bottom, line, x*sizeof(int));
bottom -= x;
top+= x;
if(do_float) {
y >>= 1;
for(;y>0;y--) {
memcpy(linef, topf, 4*x*sizeof(float));
memcpy(topf, bottomf, 4*x*sizeof(float));
memcpy(bottomf, linef, 4*x*sizeof(float));
bottomf -= 4*x;
topf+= 4*x;
}
MEM_freeN(linef);
}
MEM_freeN(line);
if(linef) MEM_freeN(linef);
}
void IMB_flipx(struct ImBuf * ibuf)

@ -27,8 +27,9 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include "BKE_global.h"
#include "BKE_utildefines.h"
/* also defined in BKE_utildefines, repeated here to avoid dependency */
#define FILE_MAX 240
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
@ -76,18 +77,17 @@ static int get_thumb_dir( char* dir , ThumbSize size)
#endif
switch(size) {
case THB_NORMAL:
strcat(dir, "/.thumbnails/normal");
strcat(dir, "/.thumbnails/normal/");
break;
case THB_LARGE:
strcat(dir, "/.thumbnails/large");
strcat(dir, "/.thumbnails/large/");
break;
case THB_FAIL:
strcat(dir, "/.thumbnails/fail/blender");
strcat(dir, "/.thumbnails/fail/blender/");
break;
default:
return 0; /* unknown size */
}
BLI_cleanup_dir(G.sce, dir);
return 1;
}

@ -43,7 +43,6 @@
* used to compress images.
*/
#include <assert.h>
#include <string.h>
#include "imbuf.h"
@ -108,7 +107,6 @@ int imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
*
* @return: Number of bytes actually read.
* 0 = EOF.
* -1 = Error (never returned).
*/
tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
{
@ -118,8 +116,10 @@ tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
/* get the pointer to the in-memory file */
mfile = IMB_TIFF_GET_MEMFILE(handle);
assert(mfile != NULL);
assert(mfile->mem != NULL);
if (!mfile || !mfile->mem) {
fprintf(stderr, "imb_tiff_ReadProc: !mfile || !mfile->mem!\n");
return 0;
}
/* find the actual number of bytes to read (copy) */
nCopy = n;
@ -136,7 +136,6 @@ tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
return (0);
/* all set -> do the read (copy) */
assert(sizeof(unsigned char) == 1);
srcAddr = (void*)(&(mfile->mem[mfile->offset]));
memcpy((void*)data, srcAddr, nCopy);
mfile->offset += nCopy; /* advance file ptr by copied bytes */
@ -180,8 +179,10 @@ toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence)
/* get the pointer to the in-memory file */
mfile = IMB_TIFF_GET_MEMFILE(handle);
assert(mfile != NULL);
assert(mfile->mem != NULL);
if (!mfile || !mfile->mem) {
fprintf(stderr, "imb_tiff_SeekProc: !mfile || !mfile->mem!\n");
return (-1);
}
/* find the location we plan to seek to */
switch (whence) {
@ -193,7 +194,9 @@ toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence)
break;
default:
/* no other types are supported - return an error */
printf("Unsupported TIFF SEEK type.\n");
fprintf(stderr,
"imb_tiff_SeekProc: "
"Unsupported TIFF SEEK type.\n");
return (-1);
}
@ -222,8 +225,10 @@ int imb_tiff_CloseProc(thandle_t handle)
/* get the pointer to the in-memory file */
mfile = IMB_TIFF_GET_MEMFILE(handle);
assert(mfile != NULL);
assert(mfile->mem != NULL); /* the file has not been closed yet */
if (!mfile || !mfile->mem) {
fprintf(stderr,"imb_tiff_CloseProc: !mfile || !mfile->mem!\n");
return (0);
}
/* virtually close the file */
mfile->mem = NULL;
@ -246,8 +251,10 @@ toff_t imb_tiff_SizeProc(thandle_t handle)
/* get the pointer to the in-memory file */
mfile = IMB_TIFF_GET_MEMFILE(handle);
assert(mfile != NULL);
assert(mfile->mem != NULL);
if (!mfile || !mfile->mem) {
fprintf(stderr,"imb_tiff_SizeProc: !mfile || !mfile->mem!\n");
return (0);
}
/* return the size */
return (toff_t)(mfile->size);
@ -317,7 +324,10 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
memFile.size = size;
/* check whether or not we have a TIFF file */
assert(size >= IMB_TIFF_NCB);
if (size < IMB_TIFF_NCB) {
fprintf(stderr, "imb_loadtiff: size < IMB_TIFF_NCB\n");
return NULL;
}
if (imb_is_a_tiff(mem) == 0)
return NULL;
@ -340,7 +350,8 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
if (ibuf) {
ibuf->ftype = TIF;
} else {
printf("imb_loadtiff: could not allocate memory for TIFF " \
fprintf(stderr,
"imb_loadtiff: could not allocate memory for TIFF " \
"image.\n");
libtiff_TIFFClose(image);
return NULL;
@ -362,7 +373,8 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
success = libtiff_TIFFReadRGBAImage(
image, width, height, raster, 0);
if (!success) {
printf("imb_loadtiff: This TIFF format is not " \
fprintf(stderr,
"imb_loadtiff: This TIFF format is not "
"currently supported by Blender.\n");
libtiff__TIFFfree(raster);
libtiff_TIFFClose(image);
@ -378,7 +390,8 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
/* this may not be entirely necessary, but is put here
* in case sizeof(unsigned int) is not a 32-bit
* quantity */
printf("imb_loadtiff: using (slower) component-wise " \
fprintf(stderr,
"imb_loadtiff: using (slower) component-wise "
"buffer copy.\n");
to = (unsigned char*)ibuf->rect;
for (pixel_i=0; pixel_i < width*height; pixel_i++)
@ -437,7 +450,8 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags)
* to gray, RGB, RGBA respectively. */
samplesperpixel = (uint16)((ibuf->depth + 7) >> 3);
if ((samplesperpixel > 4) || (samplesperpixel == 2)) {
printf("imb_savetiff: unsupported number of bytes per " \
fprintf(stderr,
"imb_savetiff: unsupported number of bytes per "
"pixel: %d\n", samplesperpixel);
return (0);
}
@ -445,7 +459,8 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags)
/* open TIFF file for writing */
if (flags & IB_mem) {
/* bork at the creation of a TIFF in memory */
printf("imb_savetiff: creation of in-memory TIFF files is " \
fprintf(stderr,
"imb_savetiff: creation of in-memory TIFF files is "
"not yet supported.\n");
return (0);
} else {
@ -453,7 +468,8 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags)
image = libtiff_TIFFOpen(name, "w");
}
if (image == NULL) {
printf("imb_savetiff: could not open TIFF for writing.\n");
fprintf(stderr,
"imb_savetiff: could not open TIFF for writing.\n");
return (0);
}
@ -462,7 +478,8 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags)
pixels = (unsigned char*)libtiff__TIFFmalloc(npixels *
samplesperpixel * sizeof(unsigned char));
if (pixels == NULL) {
printf("imb_savetiff: could not allocate pixels array.\n");
fprintf(stderr,
"imb_savetiff: could not allocate pixels array.\n");
libtiff_TIFFClose(image);
return (0);
}
@ -533,7 +550,8 @@ short imb_savetiff(struct ImBuf *ibuf, char *name, int flags)
libtiff_TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
if (libtiff_TIFFWriteEncodedStrip(image, 0, pixels,
ibuf->x*ibuf->y*samplesperpixel) == -1) {
printf("imb_savetiff: Could not write encoded TIFF.\n");
fprintf(stderr,
"imb_savetiff: Could not write encoded TIFF.\n");
libtiff_TIFFClose(image);
libtiff__TIFFfree(pixels);
return (1);

@ -79,6 +79,8 @@ void link_to_scene(unsigned short nr);
void make_links_menu(void);
void make_links(short event);
void make_duplilist_real(void);
void apply_objects_locrot(void);
void apply_objects_visual_tx(void);
void apply_object(void);
/* old transform */

@ -32,8 +32,7 @@
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
/* For bglMats */
#include "BIF_glutil.h"
#include "BKE_sculpt.h"
#include "transform.h"
struct uiBlock;
@ -49,62 +48,15 @@ struct ScrArea;
struct SculptData;
struct SculptStroke;
typedef enum PropsetMode {
PropsetNone = 0,
PropsetSize,
PropsetStrength,
PropsetTexRot
} PropsetMode;
typedef struct PropsetData {
PropsetMode mode;
unsigned int tex;
short origloc[2];
float *texdata;
short origsize;
char origstrength;
float origtexrot;
NumInput num;
} PropsetData;
typedef struct SculptSession {
bglMats mats;
/* An array of lists; array is sized as
large as the number of verts in the mesh,
the list for each vert contains the index
for all the faces that use that vertex */
struct ListBase *vertex_users;
struct IndexNode *vertex_users_mem;
int vertex_users_size;
/* Used temporarily per-stroke */
float *vertexcosnos;
ListBase damaged_rects;
ListBase damaged_verts;
/* Used to cache the render of the active texture */
unsigned int texcache_w, texcache_h, *texcache;
PropsetData *propset;
/* For rotating around a pivot point */
vec3f pivot;
struct SculptStroke *stroke;
} SculptSession;
SculptSession *sculpt_session(void);
struct SculptSession *sculpt_session(void);
struct SculptData *sculpt_data(void);
/* Memory */
void sculptmode_init(struct Scene *);
void sculptmode_free_all(struct Scene *);
void sculptmode_correct_state(void);
/* Interface */
void sculptmode_draw_interface_tools(struct uiBlock *block,unsigned short cx, unsigned short cy);
void sculptmode_draw_interface_brush(struct uiBlock *block,unsigned short cx, unsigned short cy);
void sculptmode_draw_interface_textures(struct uiBlock *block,unsigned short cx, unsigned short cy);
void sculptmode_rem_tex(void*,void*);
void sculptmode_propset_init(PropsetMode mode);
@ -133,10 +85,6 @@ void sculpt_stroke_draw();
/* Partial Mesh Visibility */
struct PartialVisibility *sculptmode_copy_pmv(struct PartialVisibility *);
void sculptmode_pmv_free(struct PartialVisibility *);
void sculptmode_revert_pmv(struct Mesh *me);
void sculptmode_pmv_off(struct Mesh *me);
void sculptmode_pmv(int mode);
#endif

@ -86,9 +86,10 @@ extern void validate_editbonebutton_cb(void *bonev, void *namev);
#define TAB_OBJECT_PARTICLE 2
#define TAB_SCENE_RENDER 0
#define TAB_SCENE_WORLD 1
#define TAB_SCENE_WORLD 1
#define TAB_SCENE_ANIM 2
#define TAB_SCENE_SOUND 3
#define TAB_SCENE_SEQUENCER 4
/* buts->scaflag */

@ -47,7 +47,7 @@ void add_text_fs(char *file);
void free_txt_data(void);
void pop_space_text(struct SpaceText *st);
void get_format_string(void);
void get_format_string(struct SpaceText *st);
void do_brackets(void);
#endif

@ -100,6 +100,7 @@ struct Ipo;
struct BWinEvent;
struct Key;
struct ListBase;
struct TimeMarker;
/* Key operations */
void transform_action_keys(int mode, int dummy);
@ -122,7 +123,7 @@ void free_actcopybuf(void);
void copy_actdata(void);
void paste_actdata(void);
/* channel/strip operations */
/* Channel/strip operations */
void up_sel_action(void);
void down_sel_action(void);
void top_sel_action(void);
@ -141,6 +142,12 @@ int select_channel(struct bAction *act, struct bActionChannel *achan, int select
void select_actionchannel_by_name(struct bAction *act, char *name, int select);
void selectkeys_leftright (short leftright, short select_mode);
/* Action Markers */
void action_set_activemarker(struct bAction *act, struct TimeMarker *active, short deselect);
void action_add_localmarker(struct bAction *act, int frame);
void action_rename_localmarker(struct bAction *act);
void action_remove_localmarkers(struct bAction *act);
/* ShapeKey stuff */
struct Key *get_action_mesh_key(void);
int get_nearest_key_num(struct Key *key, short *mval, float *x);

@ -82,6 +82,7 @@ void PE_delete_particle(void);
void PE_remove_doubles(void);
void PE_mirror_x(int tagged);
void PE_selectbrush_menu(void);
void PE_remove_doubles(void);
/* undo */
void PE_undo_push(char *str);

@ -128,8 +128,6 @@ start and end are from the start and fixed length of the sequence.
(seq)->endstill = 0; \
}
*/
/* drawseq.c */
void do_seqbuttons(short);
#endif

@ -0,0 +1,55 @@
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL 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. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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) 2007 Blender Foundation
* All rights reserved.
*
* The Original Code is: this is a new part of Blender
*
* Contributor(s): Joshua Leung
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef BIF_POSELIB_H
#define BIF_POSELIB_H
struct Object;
struct bAction;
struct TimeMarker;
char *poselib_build_poses_menu(struct bAction *act, char title[]);
int poselib_get_free_index(struct bAction *act);
struct TimeMarker *poselib_get_active_pose(struct bAction *act);
struct bAction *poselib_init_new(struct Object *ob);
struct bAction *poselib_validate(struct Object *ob);
void poselib_validate_act(struct bAction *act);
void poselib_remove_pose(struct Object *ob, struct TimeMarker *marker);
void poselib_rename_pose(struct Object *ob);
void poselib_add_current_pose(struct Object *ob, int mode);
void poselib_preview_poses(struct Object *ob, short apply_active);
#endif

@ -73,9 +73,9 @@ typedef enum {
ICON_SMOOTH,
ICON_POTATO,
ICON_MARKER_HLT,
ICON_NORMALVIEW,
ICON_LOCALVIEW,
ICON_UNUSEDVIEW,
ICON_PMARKER_ACT,
ICON_PMARKER_SEL,
ICON_PMARKER,
ICON_VIEWZOOM,
ICON_SORTALPHA,
ICON_SORTTIME,

@ -120,6 +120,7 @@ extern void force_draw_plus(int type, int header);
extern void freespacelist(struct ScrArea *sa);
extern void handle_view3d_around(void);
extern void handle_view3d_lock(void);
extern void handle_view_middlemouse(void);
extern void init_v2d_oops(struct ScrArea *, struct SpaceOops *);
extern void initipo(struct ScrArea *sa);
extern void newspace(struct ScrArea *sa, int type);

@ -72,6 +72,7 @@ void snode_make_group_editable(struct SpaceNode *snode, struct bNode *gnode);
void node_hide(struct SpaceNode *snode);
void node_read_renderlayers(struct SpaceNode *snode);
void clear_scene_in_nodes(struct Scene *sce);
void node_toggle_link(struct SpaceNode *snode);
void node_transform_ext(int mode, int unused);
void node_shader_default(struct Material *ma);

@ -89,6 +89,7 @@ struct SeqEffectHandle {
};
struct SeqEffectHandle get_sequence_effect(struct Sequence * seq);
struct SeqEffectHandle get_sequence_blend(struct Sequence * seq);
int get_sequence_effect_num_inputs(int seq_type);
void sequence_effect_speed_rebuild_map(struct Sequence * seq, int force);

@ -50,12 +50,23 @@ void free_strip(struct Strip *strip);
void new_tstripdata(struct Sequence *seq);
void free_sequence(struct Sequence *seq);
void build_seqar(struct ListBase *seqbase, struct Sequence ***seqar, int *totseq);
#define BUILD_SEQAR_COUNT_NOTHING 0
#define BUILD_SEQAR_COUNT_CURRENT 1
#define BUILD_SEQAR_COUNT_CHILDREN 2
void build_seqar_cb(struct ListBase *seqbase, struct Sequence ***seqar,
int *totseq, int (*test_func)(struct Sequence * seq));
void free_editing(struct Editing *ed);
void calc_sequence(struct Sequence *seq);
void calc_sequence_disp(struct Sequence *seq);
void reload_sequence_new_file(struct Sequence * seq);
void sort_seq(void);
void clear_scene_in_allseqs(struct Scene *sce);
char *give_seqname_by_type(int type);
char *give_seqname(struct Sequence *seq);
int evaluate_seq_frame(int cfra);
struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
struct TStripElem *give_tstripelem(struct Sequence *seq, int cfra);

@ -35,8 +35,14 @@
struct ListBase;
struct View2D;
struct TimeMarker;
/* ******** Markers - General Api ********* */
/* ****** Marker Macros - General API ****** */
/* macro for getting the scene's set of markers */
#define SCE_MARKERS (&(G.scene->markers))
/* ******** Markers - General API ********* */
void add_marker(int frame);
void duplicate_marker(void);
void remove_marker(void);
@ -45,17 +51,25 @@ void transform_markers(int mode, int smode);
void borderselect_markers(void);
void deselect_markers(short test, short sel);
struct TimeMarker *find_nearest_marker(int clip_y);
struct TimeMarker *find_nearest_marker(struct ListBase *markers, int clip_y);
void nextprev_marker(short dir);
void get_minmax_markers(short sel, float *first, float *last);
int find_nearest_marker_time(float dx);
struct TimeMarker *get_frame_marker(int frame);
void add_marker_to_cfra_elem(struct ListBase *lb, struct TimeMarker *marker, short only_sel);
void make_marker_cfra_list(struct ListBase *lb, short only_sel);
void draw_markers_timespace(int lines);
TimeMarker *get_frame_marker(int frame);
/* ********* Markers - Drawing API ********* */
/* flags for drawing markers */
enum {
DRAW_MARKERS_LINES = (1<<0),
DRAW_MARKERS_LOCAL = (1<<1)
};
void draw_markers_timespace(struct ListBase *markers, int flag);
/* ******** Animation - Preview Range ************* */
void anim_previewrange_set(void);

@ -64,6 +64,8 @@ extern void do_render_panels(unsigned short event);
extern void anim_panels(void);
extern void sound_panels(void);
extern void do_soundbuts(unsigned short event);
extern void sequencer_panels(void);
extern void do_sequencer_panels(unsigned short event);
/* object */
extern void object_panels(void);
@ -305,7 +307,8 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_AO_FALLOFF 1506
/* *********************** */
#define B_RENDERBUTS 1700
#define B_RENDERBUTS 1690
#define B_SEQUENCERBUTS 1699
#define B_FS_PIC 1601
#define B_FS_BACKBUF 1602
@ -354,6 +357,13 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_ADD_RENDERLAYER 1645
#define B_SET_PASS 1646
#define B_SEQ_BUT_PLUGIN 1691
#define B_SEQ_BUT_RELOAD 1692
#define B_SEQ_BUT_EFFECT 1693
#define B_SEQ_BUT_RELOAD_ALL 1694
#define B_SEQ_BUT_TRANSFORM 1695
#define B_SEQ_BUT_RELOAD_FILE 1696
/* *********************** */
#define B_ARMATUREBUTS 1800
#define B_POSE 1701
@ -508,6 +518,17 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_ARM_CALCPATHS 2303
#define B_ARM_CLEARPATHS 2304
#define B_POSELIB_VALIDATE 2310
#define B_POSELIB_ADDPOSE 2311
#define B_POSELIB_REPLACEP 2312
#define B_POSELIB_REMOVEP 2313
#define B_POSELIB_APPLYP 2314
/* these shouldn't be here... */
#define B_POSELIB_BROWSE 2320
#define B_POSELIB_ALONE 2321
#define B_POSELIB_DELETE 2322
/* *********************** */
#define B_CAMBUTS 2500

@ -43,39 +43,17 @@ struct uiBlock;
int multires_test();
int multires_level1_test();
struct MultiresLevel *multires_level_n(struct Multires *mr, int n);
void multires_draw_interface(struct uiBlock *block, unsigned short cx, unsigned short cy);
void multires_disp_map(void *, void*);
void multires_make(void *ob, void *me);
void multires_delete(void *ob, void *me);
struct Multires *multires_copy(struct Multires *orig);
void multires_free(struct Multires *mr);
void multires_free_level(struct MultiresLevel *lvl);
void multires_level_to_editmesh(struct Object *ob, struct Mesh *me, const int render);
void multires_finish_mesh_update(struct Object *ob);
void multires_subdivide(void *ob, void *me);
void multires_del_lower(void *ob, void *me);
void multires_del_higher(void *ob, void *me);
void multires_add_level(void *ob, void *me);
void multires_set_level_cb(void *ob, void *me);
void multires_set_level(struct Object *ob, struct Mesh *me, const int render);
void multires_update_levels(struct Mesh *me, const int render);
void multires_level_to_mesh(struct Object *ob, struct Mesh *me, const int render);
void multires_edge_level_update(void *ob, void *me);
void multires_edge_level_update_cb(void *ob, void *me);
int multires_modifier_warning();
/* after adding or removing vcolor layers, run this */
void multires_load_cols(Mesh *me);
/* multires-firstlevel.c */
/* Generic */
void multires_update_first_level(struct Mesh *me, struct EditMesh *em);
void multires_update_customdata(struct MultiresLevel *lvl1, struct CustomData *src,
struct CustomData *dst, const int type);
void multires_customdata_to_mesh(struct Mesh *me, struct EditMesh *em, struct MultiresLevel *lvl,
struct CustomData *src, struct CustomData *dst, const int type);
void multires_del_lower_customdata(struct Multires *mr, struct MultiresLevel *cr_lvl);
void multires_add_layer(struct Mesh *me, struct CustomData *cd, const int type, const int n);
void multires_delete_layer(struct Mesh *me, struct CustomData *cd, const int type, int n);
#endif

@ -303,6 +303,7 @@ void convertVecToDisplayNum(float *vec, float *num);
void convertDisplayNumToVec(float *num, float *vec);
void initWarp(TransInfo *t);
int handleEventWarp(TransInfo *t, unsigned short event, short val);
int Warp(TransInfo *t, short mval[2]);
void initShear(TransInfo *t);

@ -90,7 +90,10 @@ typedef struct bPoseChannel {
*/
typedef struct bPose {
ListBase chanbase; /* list of pose channels */
struct bAction *poselib; /* poselib-action for this pose */
short flag, proxy_layer; /* proxy layer: copy from armature, gets synced */
float ctime; /* local action time of this pose */
float stride_offset[3]; /* applied to object */
float cyclic_offset[3]; /* result of match and cycles, applied in where_is_pose() */
@ -114,7 +117,12 @@ typedef struct bActionChannel {
*/
typedef struct bAction {
ID id;
ListBase chanbase; /* Action Channels in this Action */
ListBase markers; /* TimeMarkers local to this Action for labelling 'poses' */
int active_marker; /* Index of active-marker (first marker = 1) */
int pad;
} bAction;
/* Action Editor Space. This is defined here instead of in DNA_space_types.h */
@ -154,7 +162,9 @@ typedef enum SACTION_FLAG {
/* show sliders (if relevant) */
SACTION_SLIDERS = (1<<1),
/* draw time in seconds instead of time in frames */
SACTION_DRAWTIME = (1<<2)
SACTION_DRAWTIME = (1<<2),
/* don't filter action channels according to visibility */
SACTION_NOHIDE = (1<<3)
} SACTION_FLAG;
/* SpaceAction AutoSnap Settings (also used by SpaceNLA) */

@ -79,12 +79,13 @@ typedef struct Material {
float aniso_gloss_mir;
float dist_mir;
short fadeto_mir;
short pad1;
short shade_flag; /* like Cubic interpolation */
int mode, mode_l; /* mode_l is the or-ed result of all layer modes */
short flarec, starc, linec, ringc;
float hasize, flaresize, subsize, flareboost;
float strand_sta, strand_end, strand_ease, strand_surfnor;
float strand_min, strand_pad;
char strand_uvname[32];
float sbias; /* shadow bias */
@ -200,6 +201,9 @@ typedef struct Material {
#define MA_RAYMIR_FADETOSKY 0
#define MA_RAYMIR_FADETOMAT 1
/* shade_flag */
#define MA_CUBIC 1
/* diff_shader */
#define MA_DIFF_LAMBERT 0
#define MA_DIFF_ORENNAYAR 1

@ -92,7 +92,8 @@ typedef struct bNodeSocket {
#define SOCK_IN_USE 4
/* unavailable is for dynamic sockets */
#define SOCK_UNAVAIL 8
/* flag for selection status */
#define SOCK_SEL 16
#
#
typedef struct bNodePreview {
@ -167,6 +168,10 @@ typedef struct bNodeTree {
ListBase alltypes; /* type definitions */
struct bNodeType *owntype; /* for groups or dynamic trees, no read/write */
/* selected input/output socket */
bNodeSocket *selin;
bNodeSocket *selout;
/* callbacks */
void (*timecursor)(int nr);
void (*stats_draw)(char *str);
@ -198,6 +203,17 @@ typedef struct NodeBlurData {
int pad2;
} NodeBlurData;
typedef struct NodeDBlurData {
float center_x, center_y, distance, angle, spin, zoom;
short iter;
char wrap, pad;
} NodeDBlurData;
typedef struct NodeBilateralBlurData {
float sigma_color, sigma_space;
short iter, pad;
} NodeBilateralBlurData;
typedef struct NodeHueSat {
float hue, sat, val;
} NodeHueSat;

@ -84,6 +84,7 @@ typedef struct Object {
struct Path *path;
struct BoundBox *bb;
struct bAction *action;
struct bAction *poselib;
struct bPose *pose;
void *data;

@ -121,6 +121,11 @@ typedef struct ParticleSettings {
short bb_align, bb_uv_split, bb_anim, bb_split_offset;
float bb_tilt, bb_rand_tilt, bb_offset[2];
/* simplification */
short simplify_flag, simplify_refsize;
float simplify_rate, simplify_transition;
float simplify_viewport;
/* general values */
float sta, end, lifetime, randlife;
float timetweak, jitfac, keyed_time;
@ -128,13 +133,13 @@ typedef struct ParticleSettings {
/* initial velocity factors */
float normfac, obfac, randfac, partfac, tanfac, tanphase, reactfac;
float rotfac, avefac, phasefac;
float avefac, phasefac, randrotfac, randphasefac;
/* physical properties */
float mass, size, randsize, reactshape;
/* global physical properties */
float acc[3], dragfac, brownfac, dampfac;
/* length */
float length, abslength, randlength, pad;
float length, abslength, randlength;
/* children */
int child_nbr, ren_child_nbr;
float parents, childsize, childrandsize;
@ -307,6 +312,10 @@ typedef struct ParticleSystem{
#define PART_DRAW_WHOLE_GR (1<<14)
#define PART_DRAW_REN_STRAND (1<<15)
/* part->simplify_flag */
#define PART_SIMPLIFY_ENABLE 1
#define PART_SIMPLIFY_VIEWPORT 2
/* part->bb_align */
#define PART_BB_X 0
#define PART_BB_Y 1
@ -346,7 +355,12 @@ typedef struct ParticleSystem{
/* part->rotmode */
#define PART_ROT_NOR 1
#define PART_ROT_VEL 2
#define PART_ROT_RAND 3
#define PART_ROT_GLOB_X 3
#define PART_ROT_GLOB_Y 4
#define PART_ROT_GLOB_Z 5
#define PART_ROT_OB_X 6
#define PART_ROT_OB_Y 7
#define PART_ROT_OB_Z 8
/* part->avemode */
#define PART_AVE_SPIN 1

@ -424,6 +424,9 @@ typedef struct SculptData
/* Pointers to all of sculptmodes's textures */
struct MTex *mtex[10];
/* Editable brush shape */
struct CurveMapping *cumap;
/* Settings for each brush */
BrushData drawbrush, smoothbrush, pinchbrush, inflatebrush, grabbrush, layerbrush, flattenbrush;
short brush_type;

@ -50,18 +50,41 @@ typedef struct StripElem {
typedef struct TStripElem {
struct ImBuf *ibuf;
struct ImBuf *ibuf_comp;
struct TStripElem *se1, *se2, *se3;
short ok;
short pad;
int nr;
} TStripElem;
typedef struct StripCrop {
int top;
int bottom;
int left;
int right;
} StripCrop;
typedef struct StripTransform {
int xofs;
int yofs;
} StripTransform;
typedef struct StripProxy {
char dir[160];
int format;
int width;
int height;
} StripProxy;
typedef struct Strip {
struct Strip *next, *prev;
int rt, len, us, done;
StripElem *stripdata;
char dir[160];
int orx, ory;
StripCrop *crop;
StripTransform *transform;
StripProxy *proxy;
TStripElem *tstripdata;
} Strip;
@ -96,7 +119,7 @@ typedef struct Sequence {
void *lib; /* needed (to be like ipo), else it will raise libdata warnings, this should never be used */
char name[24]; /* name, not set by default and dosnt need to be unique as with ID's */
short flag, type; /*flags bitmap (see below) and the type of sequence*/
int flag, type; /*flags bitmap (see below) and the type of sequence*/
int len; /* the length of the contense of this strip - before handles are applied */
int start, startofs, endofs;
int startstill, endstill;
@ -105,6 +128,7 @@ typedef struct Sequence {
float mul, handsize;
/* is sfra needed anymore? - it looks like its only used in one place */
int sfra; /* starting frame according to the timeline of the scene. */
int anim_preseek;
Strip *strip;
@ -128,8 +152,11 @@ typedef struct Sequence {
void *effectdata; /* Struct pointer for effect settings */
int anim_preseek;
int pad;
int anim_startofs; /* only use part of animation file */
int anim_endofs; /* is subtle different to startofs / endofs */
int blend_mode;
float blend_opacity;
} Sequence;
typedef struct MetaStack {
@ -210,6 +237,12 @@ typedef struct SpeedControlVars {
#define SEQ_FLAG_DELETE 1024
#define SEQ_FLIPX 2048
#define SEQ_FLIPY 4096
#define SEQ_MAKE_FLOAT 8192
#define SEQ_LOCK 16384
#define SEQ_USE_PROXY 32768
#define SEQ_USE_TRANSFORM 65536
#define SEQ_USE_CROP 131072
/* seq->type WATCH IT: SEQ_EFFECT BIT is used to determine if this is an effect strip!!! */
#define SEQ_IMAGE 0
@ -235,10 +268,17 @@ typedef struct SpeedControlVars {
#define SEQ_TRANSFORM 27
#define SEQ_COLOR 28
#define SEQ_SPEED 29
#define SEQ_EFFECT_MAX 29
#define STRIPELEM_FAILED 0
#define STRIPELEM_OK 1
#define STRIPELEM_META 2
#define SEQ_BLEND_REPLACE 0
/* all other BLEND_MODEs are simple SEQ_EFFECT ids and therefore identical
to the table above. (Only those effects that handle _exactly_ two inputs,
otherwise, you can't really blend, right :) !)
*/
#endif

@ -248,6 +248,7 @@ typedef struct TexMapping {
#define TEX_CALCALPHA 32
#define TEX_NORMALMAP 2048
#define TEX_GAUSS_MIP 4096
#define TEX_FILTER_MIN 8192
/* imaflag unused, only for version check */
#define TEX_FIELDS_ 8

@ -66,6 +66,8 @@ extern bNodeType cmp_node_normalize;
extern bNodeType cmp_node_filter;
extern bNodeType cmp_node_blur;
extern bNodeType cmp_node_dblur;
extern bNodeType cmp_node_bilateralblur;
extern bNodeType cmp_node_vecblur;
extern bNodeType cmp_node_dilateerode;
extern bNodeType cmp_node_defocus;

@ -0,0 +1,273 @@
/**
*
*
* ***** 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) 2006 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Vilem Novak
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../CMP_util.h"
/* **************** BILATERALBLUR ******************** */
static bNodeSocketType cmp_node_bilateralblur_in[]= {
{ SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 1, "Determinator", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static bNodeSocketType cmp_node_bilateralblur_out[]= {
{ SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
#define INIT_C3\
mean0 = 1; mean1[0] = src[0];mean1[1] = src[1];mean1[2] = src[2];mean1[3] = src[3];
/* finds color distances */
#define COLOR_DISTANCE_C3(c1, c2)\
((c1[0] - c2[0])*(c1[0] - c2[0]) + \
(c1[1] - c2[1])*(c1[1] - c2[1]) + \
(c1[2] - c2[2])*(c1[2] - c2[2]) + \
(c1[3] - c2[3])*(c1[3] - c2[3]))
/* this is the main kernel function for comparing color distances
and adding them weighted to the final color */
#define KERNEL_ELEMENT_C3(k)\
temp_color = src + deltas[k];\
ref_color = ref + deltas[k];\
w = weight_tab[k] + COLOR_DISTANCE_C3(ref, ref_color )*i2sigma_color;\
w = 1./(w*w + 1); \
mean0 += w;\
mean1[0] += temp_color[0]*w; \
mean1[1] += temp_color[1]*w; \
mean1[2] += temp_color[2]*w; \
mean1[3] += temp_color[3]*w;
/* write blurred values to image */
#define UPDATE_OUTPUT_C3\
mean0 = 1./mean0;\
dest[x*pix + 0] = mean1[0]*mean0; \
dest[x*pix + 1] = mean1[1]*mean0; \
dest[x*pix + 2] = mean1[2]*mean0; \
dest[x*pix + 3] = mean1[3]*mean0;
/* initializes deltas for fast access to neighbour pixels */
#define INIT_3X3_DELTAS( deltas, step, nch ) \
((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
(deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
(deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
(deltas)[6] = (step), (deltas)[7] = (step) + (nch));
/* code of this node was heavily inspired by the smooth function of opencv library.
The main change is an optional image input */
static void node_composit_exec_bilateralblur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
NodeBilateralBlurData *nbbd= node->storage;
CompBuf *new, *source, *img= in[0]->data , *refimg= in[1]->data;
double mean0, w, i2sigma_color, i2sigma_space;
double mean1[4];
double weight_tab[8];
float *src, *dest, *ref, *temp_color, *ref_color;
float sigma_color, sigma_space;
int imgx, imgy, x, y, pix, i, step;
int deltas[8];
short found_determinator= 0;
if(img == NULL || out[0]->hasoutput == 0)
return;
if(img->type != CB_RGBA) {
img= typecheck_compbuf(in[0]->data, CB_RGBA);
}
imgx= img->x;
imgy= img->y;
pix= img->type;
step= pix * imgx;
if(refimg) {
refimg= img;
if(refimg->x == imgx && refimg->y == imgy) {
if(refimg->type == CB_VEC2 || refimg->type == CB_VEC3) {
refimg= typecheck_compbuf(in[1]->data, CB_RGBA);
found_determinator= 1;
}
}
}
else {
refimg= img;
}
/* allocs */
source= dupalloc_compbuf(img);
new= alloc_compbuf(imgx, imgy, pix, 1);
/* accept image offsets from other nodes */
new->xof= img->xof;
new->yof= img->yof;
/* bilateral code properties */
sigma_color= nbbd->sigma_color;
sigma_space= nbbd->sigma_space;
i2sigma_color= 1. / (sigma_color * sigma_color);
i2sigma_space= 1. / (sigma_space * sigma_space);
INIT_3X3_DELTAS(deltas, step, pix);
weight_tab[0] = weight_tab[2] = weight_tab[4] = weight_tab[6] = i2sigma_space;
weight_tab[1] = weight_tab[3] = weight_tab[5] = weight_tab[7] = i2sigma_space * 2;
/* iterations */
for(i= 0; i < nbbd->iter; i++) {
src= source->rect;
ref= refimg->rect;
dest= new->rect;
/*goes through image, there are more loops for 1st/last line and all other lines*/
/*kernel element accumulates surrounding colors, which are then written with the update_output function*/
for(x= 0; x < imgx; x++, src+= pix, ref+= pix) {
INIT_C3;
KERNEL_ELEMENT_C3(6);
if(x > 0) {
KERNEL_ELEMENT_C3(5);
KERNEL_ELEMENT_C3(4);
}
if(x < imgx - 1) {
KERNEL_ELEMENT_C3(7);
KERNEL_ELEMENT_C3(0);
}
UPDATE_OUTPUT_C3;
}
dest+= step;
for(y= 1; y < imgy - 1; y++, dest+= step, src+= pix, ref+= pix) {
x= 0;
INIT_C3;
KERNEL_ELEMENT_C3(0);
KERNEL_ELEMENT_C3(1);
KERNEL_ELEMENT_C3(2);
KERNEL_ELEMENT_C3(6);
KERNEL_ELEMENT_C3(7);
UPDATE_OUTPUT_C3;
src+= pix;
ref+= pix;
for(x= 1; x < imgx - 1; x++, src+= pix, ref+= pix) {
INIT_C3;
KERNEL_ELEMENT_C3(0);
KERNEL_ELEMENT_C3(1);
KERNEL_ELEMENT_C3(2);
KERNEL_ELEMENT_C3(3);
KERNEL_ELEMENT_C3(4);
KERNEL_ELEMENT_C3(5);
KERNEL_ELEMENT_C3(6);
KERNEL_ELEMENT_C3(7);
UPDATE_OUTPUT_C3;
}
INIT_C3;
KERNEL_ELEMENT_C3(2);
KERNEL_ELEMENT_C3(3);
KERNEL_ELEMENT_C3(4);
KERNEL_ELEMENT_C3(5);
KERNEL_ELEMENT_C3(6);
UPDATE_OUTPUT_C3;
}
for(x= 0; x < imgx; x++, src+= pix, ref+= pix) {
INIT_C3;
KERNEL_ELEMENT_C3(2);
if(x > 0) {
KERNEL_ELEMENT_C3(3);
KERNEL_ELEMENT_C3(4);
}
if(x < imgx - 1) {
KERNEL_ELEMENT_C3(1);
KERNEL_ELEMENT_C3(0);
}
UPDATE_OUTPUT_C3;
}
if(node->exec & NODE_BREAK) break;
SWAP(CompBuf, *source, *new);
}
if(node->exec & NODE_BREAK)
free_compbuf(source);
if(img != in[0]->data)
free_compbuf(img);
if(found_determinator == 1) {
if(refimg != in[1]->data)
free_compbuf(refimg);
}
out[0]->data= source;
free_compbuf(new);
}
static void node_composit_init_bilateralblur(bNode* node)
{
NodeBilateralBlurData *nbbd= MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data");
node->storage= nbbd;
nbbd->sigma_color= 0.3;
nbbd->sigma_space= 5.0;
}
bNodeType cmp_node_bilateralblur= {
/* *next,*prev */ NULL, NULL,
/* type code */ CMP_NODE_BILATERALBLUR,
/* name */ "Bilateral Blur",
/* width+range */ 150, 120, 200,
/* class+opts */ NODE_CLASS_OP_FILTER, NODE_OPTIONS,
/* input sock */ cmp_node_bilateralblur_in,
/* output sock */ cmp_node_bilateralblur_out,
/* storage */ "NodeBilateralBlurData",
/* execfunc */ node_composit_exec_bilateralblur,
/* butfunc */ NULL,
/* initfunc */ node_composit_init_bilateralblur,
/* freestoragefunc */ node_free_standard_storage,
/* copystoragefunc */ node_copy_standard_storage,
/* id */ NULL
};

@ -0,0 +1,143 @@
/**
*
* ***** 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) 2006 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Alfredo de Greef (eeshlo)
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../CMP_util.h"
static bNodeSocketType cmp_node_dblur_in[]= {
{ SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.f, 0.f, 1.f},
{ -1, 0, "" }
};
static bNodeSocketType cmp_node_dblur_out[]= {
{ SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
float center_x, float center_y, float dist, float angle, float spin, float zoom)
{
if ((dist != 0.f) || (spin != 0.f) || (zoom != 0.f)) {
void (*getpix)(CompBuf*, float, float, float*) = wrap ? qd_getPixelLerpWrap : qd_getPixelLerp;
const float a= angle * (float)M_PI / 180.f;
const float itsc= 1.f / pow(2.f, (float)iterations);
float D;
float center_x_pix, center_y_pix;
float tx, ty;
float sc, rot;
CompBuf *tmp;
int i, j;
tmp= dupalloc_compbuf(img);
D= dist * sqrtf(img->x * img->x + img->y * img->y);
center_x_pix= center_x * img->x;
center_y_pix= center_y * img->y;
tx= itsc * D * cos(a);
ty= -itsc * D * sin(a);
sc= itsc * zoom;
rot= itsc * spin * (float)M_PI / 180.f;
/* blur the image */
for(i= 0; i < iterations; ++i) {
const float cs= cos(rot), ss= sin(rot);
const float isc= 1.f / (1.f + sc);
unsigned int x, y;
float col[4]= {0,0,0,0};
for(y= 0; y < img->y; ++y) {
const float v= isc * (y - center_y_pix) + ty;
for(x= 0; x < img->x; ++x) {
const float u= isc * (x - center_x_pix) + tx;
unsigned int p= (x + y * img->x) * img->type;
getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col);
/* mix img and transformed tmp */
for(j= 0; j < 4; ++j)
img->rect[p + j]= AVG2(img->rect[p + j], col[j]);
}
}
/* copy img to tmp */
if(i != (iterations - 1))
memcpy(tmp->rect, img->rect, sizeof(float) * img->x * img->y * img->type);
/* double transformations */
tx *= 2.f, ty *= 2.f;
sc *= 2.f, rot *= 2.f;
if(node->exec & NODE_BREAK) break;
}
free_compbuf(tmp);
}
return img;
}
static void node_composit_exec_dblur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
NodeDBlurData *ndbd= node->storage;
CompBuf *new, *img= in[0]->data;
if((img == NULL) || (out[0]->hasoutput == 0)) return;
if (img->type != CB_RGBA)
new = typecheck_compbuf(img, CB_RGBA);
else
new = dupalloc_compbuf(img);
out[0]->data= dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom);
}
static void node_composit_init_dblur(bNode* node)
{
NodeDBlurData *ndbd= MEM_callocN(sizeof(NodeDBlurData), "node dblur data");
node->storage= ndbd;
ndbd->center_x= 0.5;
ndbd->center_y= 0.5;
}
bNodeType cmp_node_dblur = {
/* *next,*prev */ NULL, NULL,
/* type code */ CMP_NODE_DBLUR,
/* name */ "Directional Blur",
/* width+range */ 150, 120, 200,
/* class+opts */ NODE_CLASS_OP_FILTER, NODE_OPTIONS,
/* input sock */ cmp_node_dblur_in,
/* output sock */ cmp_node_dblur_out,
/* storage */ "NodeDBlurData",
/* execfunc */ node_composit_exec_dblur,
/* butfunc */ NULL,
/* initfunc */ node_composit_init_dblur,
/* freestoragefunc */ node_free_standard_storage,
/* copystoragefunc */ node_copy_standard_storage,
/* id */ NULL
};

@ -1,5 +1,6 @@
/*
* $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@ -36,6 +37,7 @@ struct ID; /*keep me up here */
/* for open, close in Blender_Load */
#include <fcntl.h>
#include "BDR_editobject.h" /* exit_editmode() */
#include "BDR_drawmesh.h" /* set_mipmap() */
#include "BIF_usiblender.h"
#include "BLI_blenlib.h"
#include "BLO_writefile.h"
@ -285,11 +287,23 @@ static PyObject *Blender_Set( PyObject * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_ValueError,
"expected an integer" );
if (value)
U.flag |= USER_FILECOMPRESS;
if (value)
U.flag |= USER_FILECOMPRESS;
else
U.flag &= ~USER_FILECOMPRESS;
U.flag &= ~USER_FILECOMPRESS;
} else if (StringEqual( name , "mipmap" ) ) {
int value = PyObject_IsTrue( arg );
if (value==-1)
return EXPP_ReturnPyObjError( PyExc_ValueError,
"expected an integer" );
if (value)
U.gameflags &= ~USER_DISABLE_MIPMAP;
else
U.gameflags |= USER_DISABLE_MIPMAP;
set_mipmap(!(U.gameflags & USER_DISABLE_MIPMAP));
}else
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"value given is not a blender setting" ) );
@ -521,14 +535,15 @@ static PyObject *Blender_Get( PyObject * self, PyObject * value )
else if(StringEqual( str, "compressfile" ))
ret = PyInt_FromLong( (U.flag & USER_FILECOMPRESS) >> 15 );
else if(StringEqual( str, "mipmap" ))
ret = PyInt_FromLong( (U.gameflags & USER_DISABLE_MIPMAP) == 0 );
else
return EXPP_ReturnPyObjError( PyExc_AttributeError, "unknown attribute" );
if (ret) return ret;
else
return EXPP_ReturnPyObjError (PyExc_MemoryError,
"could not create pystring!");
"could not create the PyObject!");
}
/*****************************************************************************/

@ -243,7 +243,7 @@ static PyObject *M_Image_New( PyObject * self, PyObject * args)
if (width > 5000 || height > 5000 || width < 1 || height < 1)
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"Image width and height must be between 1 and 5000" ) );
image = BKE_add_image_size(width, height, name, 0, color);
image = BKE_add_image_size(width, height, name, 0, 0, color);
if( !image )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyObject Image_Type" ) );

@ -60,6 +60,7 @@
#include "BKE_mesh.h"
#include "BKE_material.h"
#include "BKE_main.h"
#include "BKE_multires.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_DerivedMesh.h"
@ -7160,7 +7161,7 @@ static int Mesh_setMultires( BPy_Mesh * self, PyObject *value, void *type )
switch ((int)type) {
case MESH_MULTIRES_LEVEL:
self->mesh->mr->newlvl = i;
multires_set_level(self->object, self->mesh, 0);
multires_set_level_cb(self->object, self->mesh);
break;
case MESH_MULTIRES_EDGE:
self->mesh->mr->edgelvl = i;

@ -134,6 +134,7 @@ struct rctf;
#define IPOKEY_PI_SURFACEDAMP 8
#define IPOKEY_PI_RANDOMDAMP 9
#define IPOKEY_PI_PERM 10
#define IPOKEY_LAYER 19
#define PFIELD_FORCE 1
#define PFIELD_VORTEX 2
@ -2343,7 +2344,7 @@ static int Object_setMatrix( BPy_Object * self, MatrixObject * mat )
/*
* Object_insertIpoKey()
* inserts Object IPO key for LOC, ROT, SIZE, LOCROT, or LOCROTSIZE
* inserts Object IPO key for LOC, ROT, SIZE, LOCROT, LOCROTSIZE, or LAYER
* Note it also inserts actions!
*/
@ -2375,6 +2376,9 @@ static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Y, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Z, 0);
}
if (key == IPOKEY_LAYER ){
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LAY, 0);
}
if (key == IPOKEY_PI_STRENGTH ){
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR, 0);
@ -5323,6 +5327,7 @@ static PyObject *M_Object_IpoKeyTypesDict( void )
PyConstant_Insert( d, "SIZE", PyInt_FromLong( IPOKEY_SIZE ) );
PyConstant_Insert( d, "LOCROT", PyInt_FromLong( IPOKEY_LOCROT ) );
PyConstant_Insert( d, "LOCROTSIZE", PyInt_FromLong( IPOKEY_LOCROTSIZE ) );
PyConstant_Insert( d, "LAYER", PyInt_FromLong( IPOKEY_LAYER ) );
PyConstant_Insert( d, "PI_STRENGTH", PyInt_FromLong( IPOKEY_PI_STRENGTH ) );
PyConstant_Insert( d, "PI_FALLOFF", PyInt_FromLong( IPOKEY_PI_FALLOFF ) );
@ -5360,7 +5365,8 @@ PyObject *Object_Init( void )
PyModule_AddIntConstant( module, "SIZE", IPOKEY_SIZE );
PyModule_AddIntConstant( module, "LOCROT", IPOKEY_LOCROT );
PyModule_AddIntConstant( module, "LOCROTSIZE", IPOKEY_LOCROTSIZE );
PyModule_AddIntConstant( module, "LAYER", IPOKEY_LAYER );
PyModule_AddIntConstant( module, "PI_STRENGTH", IPOKEY_PI_STRENGTH );
PyModule_AddIntConstant( module, "PI_FALLOFF", IPOKEY_PI_FALLOFF );
PyModule_AddIntConstant( module, "PI_SURFACEDAMP", IPOKEY_PI_SURFACEDAMP );

@ -51,12 +51,15 @@ struct View3D;
#include "BLI_blenlib.h" /* only for SceneObSeq_new */
#include "BSE_drawview.h" /* for play_anim */
#include "BSE_headerbuttons.h" /* for copy_scene */
#include "BSE_sequence.h" /* to clear_scene_in_allseqs */
#include "BSE_node.h" /* to clear_scene_in_nodes */
#include "BIF_drawscene.h" /* for set_scene */
#include "BIF_space.h" /* for copy_view3d_lock() */
#include "BIF_screen.h" /* curarea */
#include "BDR_editobject.h" /* free_and_unlink_base() */
#include "mydevice.h" /* for #define REDRAW */
#include "DNA_view3d_types.h"
/* python types */
#include "Object.h"
#include "Camera.h"
@ -718,8 +721,9 @@ static PyObject *M_Scene_Unlink( PyObject * self, PyObject * args )
{
PyObject *pyobj;
BPy_Scene *pyscn;
Scene *scene;
Scene *scene, *sce;
bScreen *sc;
if( !PyArg_ParseTuple( args, "O!", &Scene_Type, &pyobj ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected Scene PyType object" );
@ -733,6 +737,23 @@ static PyObject *M_Scene_Unlink( PyObject * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_SystemError,
"current Scene cannot be removed!" );
/* Copied from header_info.c */
/* check all sets */
for (sce= G.main->scene.first; sce; sce= sce->id.next) {
if(sce->set == scene) sce->set= 0;
}
/* check all sequences */
clear_scene_in_allseqs(scene);
/* check render layer nodes in other scenes */
clear_scene_in_nodes(scene);
for (sc= G.main->screen.first; sc; sc= sc->id.next ) {
if(sc->scene == scene) sc->scene= G.scene;
}
free_libblock( &G.main->scene, scene );
pyscn->scene= NULL;

@ -32,6 +32,7 @@
#include "Texture.h" /*This must come first*/
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
@ -1572,6 +1573,7 @@ static int Texture_setImage( BPy_Texture * self, PyObject * value )
}
self->texture->ima = blimg;
BKE_image_signal(blimg, &self->texture->iuser, IMA_SIGNAL_RELOAD );
id_us_plus( &blimg->id );
return 0;

@ -538,7 +538,7 @@ PyObject *LibBlockSeq_new(BPy_LibBlockSeq *self, PyObject * args, PyObject *kwd)
break;
case ID_IM:
{
id = (ID *)BKE_add_image_size(img_width, img_height, name?name:"Image", 0, color);
id = (ID *)BKE_add_image_size(img_width, img_height, name?name:"Image", 0, 0, color);
if( !id )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyObject Image_Type" ) );

@ -69,6 +69,7 @@ def Set (request, data):
- 'renderdir': default render output dir
- 'soundsdir': sound dir
- 'tempdir': temp file storage dir
- 'mipmap' : Use mipmapping in the 3d view (Use a boolean value True/False).
@type data: int or string
@param data: The new value.
"""
@ -106,6 +107,7 @@ def Get (request):
- 'soundsdir': the path to the user defined dir for sound files. (*)
- 'tempdir': the path to the user defined dir for storage of Blender
temporary files. (*)
- 'mipmap' : Use mipmapping in the 3d view. (*)
- 'version' : the Blender version number.
@note: (*) these can be set in Blender at the User Preferences window -> File
Paths tab.

@ -105,6 +105,7 @@ Example::
- SIZE
- LOCROT
- LOCROTSIZE
- LAYER
- PI_STRENGTH
- PI_FALLOFF
- PI_SURFACEDAMP

@ -206,11 +206,12 @@ float RE_filter_value(int type, float x);
void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nbd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect);
/* shaded view or baking options */
#define RE_BAKE_LIGHT 0
#define RE_BAKE_ALL 1
#define RE_BAKE_AO 2
#define RE_BAKE_NORMALS 3
#define RE_BAKE_TEXTURE 4
#define RE_BAKE_LIGHT 0
#define RE_BAKE_ALL 1
#define RE_BAKE_AO 2
#define RE_BAKE_NORMALS 3
#define RE_BAKE_TEXTURE 4
#define RE_BAKE_DISPLACEMENT 5
void RE_Database_Baking(struct Render *re, struct Scene *scene, int type, struct Object *actob);
void RE_DataBase_GetView(struct Render *re, float mat[][4]);

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