svn merge -r 22800:23207 https://svn.blender.org/svnroot/bf-blender/trunk/blender

Merged volumetric with new raytrace code (it compiles and rendered volume-cube.blend withouth problems)

Part1:
	source/blender
This commit is contained in:
Andre Susano Pinto
2009-09-15 15:15:43 +00:00
549 changed files with 45204 additions and 32907 deletions
+4 -4
View File
@@ -42,18 +42,18 @@ ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(blenfont)
IF(WITH_OPENEXR)
ADD_SUBDIRECTORY(imbuf/intern/openexr)
ADD_SUBDIRECTORY(imbuf/intern/openexr)
ENDIF(WITH_OPENEXR)
IF(WITH_DDS)
ADD_SUBDIRECTORY(imbuf/intern/dds)
ADD_SUBDIRECTORY(imbuf/intern/dds)
ENDIF(WITH_DDS)
IF(WITH_QUICKTIME)
ADD_SUBDIRECTORY(quicktime)
ADD_SUBDIRECTORY(quicktime)
ENDIF(WITH_QUICKTIME)
IF(WITH_PYTHON)
ADD_SUBDIRECTORY(python)
ADD_SUBDIRECTORY(python)
ENDIF(WITH_PYTHON)
+2 -2
View File
@@ -27,8 +27,8 @@
FILE(GLOB SRC intern/*.c)
SET(INC
. ../../../intern/guardedalloc
${JPEG_INC}
. ../../../intern/guardedalloc
${JPEG_INC}
)
BLENDERLIB(bf_avi "${SRC}" "${INC}")
+1 -2
View File
@@ -1,5 +1,4 @@
#!/usr/bin/python
#Import ('extra_includes')
Import ('env')
sources = env.Glob('intern/*.c')
@@ -7,4 +6,4 @@ sources = env.Glob('intern/*.c')
incs = '. #/intern/guardedalloc'
incs += ' ' + env['BF_JPEG_INC']
env.BlenderLib ('bf_avi', sources, Split(incs), [], libtype=['core'], priority = [185] )
env.BlenderLib ('bf_avi', sources, Split(incs), [], libtype=['core','player'], priority = [190,120] )
+27
View File
@@ -70,6 +70,11 @@ void BLF_boundbox(char *str, struct rctf *box);
float BLF_width(char *str);
float BLF_height(char *str);
/*
* The following function return the width and height of the string, but
* just in one call, so avoid extra freetype2 stuff.
*/
void BLF_width_and_height(char *str, float *width, float *height);
/*
* For fixed width fonts only, returns the width of a
@@ -116,6 +121,28 @@ void BLF_shadow(int level, float r, float g, float b, float a);
*/
void BLF_shadow_offset(int x, int y);
/*
* Set the buffer, size and number of channels to draw, one thing to take care is call
* this function with NULL pointer when we finish, for example:
* BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4);
*
* ... set color, position and draw ...
*
* BLF_buffer(NULL, NULL, 0, 0, 0);
*/
void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch);
/*
* Set the color to be used for text.
*/
void BLF_buffer_col(float r, float g, float b, float a);
/*
* Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_
* it's not necessary set both buffer, NULL is valid here.
*/
void BLF_draw_buffer(char *str);
/*
* Search the path directory to the locale files, this try all
* the case for Linux, Win and Mac.
+5 -5
View File
@@ -25,17 +25,17 @@
FILE(GLOB SRC intern/*.c)
SET(INC
../../../intern/guardedalloc ../blenlib ../makesdna ../editors/include
../blenkernel ../../../extern/glew/include .
${FREETYPE_INCLUDE_DIRS}
../../../intern/guardedalloc ../blenlib ../makesdna ../editors/include
../blenkernel ../../../extern/glew/include .
${FREETYPE_INCLUDE_DIRS}
)
IF(WITH_INTERNATIONAL)
SET(INC ${INC} ${GETTEXT_INC})
SET(INC ${INC} ${GETTEXT_INC})
ENDIF(WITH_INTERNATIONAL)
IF(WIN32)
ADD_DEFINITIONS(-D_WIN32 -DUSE_GETTEXT_DLL)
ADD_DEFINITIONS(-D_WIN32 -DUSE_GETTEXT_DLL)
ENDIF(WIN32)
BLENDERLIB(bf_blenfont "${SRC}" "${INC}")
+1 -1
View File
@@ -14,4 +14,4 @@ defs = ''
if sys.platform == 'win32':
defs += ' _WIN32 USE_GETTEXT_DLL'
env.BlenderLib ( 'bf_blenfont', sources, Split(incs), Split(defs), libtype=['core'], priority=[210] )
env.BlenderLib ( 'bf_blenfont', sources, Split(incs), Split(defs), libtype=['core','player'], priority=[210,210] )
+45
View File
@@ -371,6 +371,15 @@ void BLF_boundbox(char *str, rctf *box)
blf_font_boundbox(font, str, box);
}
void BLF_width_and_height(char *str, float *width, float *height)
{
FontBLF *font;
font= global_font[global_font_cur];
if (font)
blf_font_width_and_height(font, str, width, height);
}
float BLF_width(char *str)
{
FontBLF *font;
@@ -513,3 +522,39 @@ void BLF_shadow_offset(int x, int y)
font->shadow_y= y;
}
}
void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch)
{
FontBLF *font;
font= global_font[global_font_cur];
if (font) {
font->b_fbuf= fbuf;
font->b_cbuf= cbuf;
font->bw= w;
font->bh= h;
font->bch= nch;
}
}
void BLF_buffer_col(float r, float g, float b, float a)
{
FontBLF *font;
font= global_font[global_font_cur];
if (font) {
font->b_col[0]= r;
font->b_col[1]= g;
font->b_col[2]= b;
font->b_col[3]= a;
}
}
void BLF_draw_buffer(char *str)
{
FontBLF *font;
font= global_font[global_font_cur];
if (font)
blf_font_buffer(font, str);
}
+184 -14
View File
@@ -100,7 +100,7 @@ void blf_font_draw(FontBLF *font, char *str)
unsigned int c;
GlyphBLF *g, *g_prev;
FT_Vector delta;
FT_UInt glyph_index, g_prev_index;
FT_UInt glyph_index;
int pen_x, pen_y;
int i, has_kerning, st;
@@ -112,17 +112,17 @@ void blf_font_draw(FontBLF *font, char *str)
pen_y= 0;
has_kerning= FT_HAS_KERNING(font->face);
g_prev= NULL;
g_prev_index= 0;
while (str[i]) {
c= blf_utf8_next((unsigned char *)str, &i);
if (c == 0)
break;
glyph_index= FT_Get_Char_Index(font->face, c);
g= blf_glyph_search(font->glyph_cache, c);
if (!g)
if (!g) {
glyph_index= FT_Get_Char_Index(font->face, c);
g= blf_glyph_add(font, glyph_index, c);
}
/* if we don't found a glyph, skip it. */
if (!g)
@@ -133,9 +133,9 @@ void blf_font_draw(FontBLF *font, char *str)
delta.y= 0;
if (font->flags & BLF_KERNING_DEFAULT)
st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta);
st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta);
else
st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta);
st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta);
if (st == 0)
pen_x += delta.x >> 6;
@@ -146,7 +146,158 @@ void blf_font_draw(FontBLF *font, char *str)
pen_x += g->advance;
g_prev= g;
g_prev_index= glyph_index;
}
}
void blf_font_buffer(FontBLF *font, char *str)
{
unsigned char *data, *cbuf;
unsigned int c;
GlyphBLF *g, *g_prev;
FT_Vector delta;
FT_UInt glyph_index;
float a, *fbuf;
int pen_x, pen_y, y, x, yb, diff;
int i, has_kerning, st, chx, chy;
if (!font->glyph_cache)
return;
i= 0;
pen_x= (int)font->pos[0];
pen_y= (int)font->pos[1];
has_kerning= FT_HAS_KERNING(font->face);
g_prev= NULL;
while (str[i]) {
c= blf_utf8_next((unsigned char *)str, &i);
if (c == 0)
break;
g= blf_glyph_search(font->glyph_cache, c);
if (!g) {
glyph_index= FT_Get_Char_Index(font->face, c);
g= blf_glyph_add(font, glyph_index, c);
}
/* if we don't found a glyph, skip it. */
if (!g)
continue;
if (has_kerning && g_prev) {
delta.x= 0;
delta.y= 0;
if (font->flags & BLF_KERNING_DEFAULT)
st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta);
else
st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta);
if (st == 0)
pen_x += delta.x >> 6;
}
chx= pen_x + ((int)g->pos_x);
diff= g->height - ((int)g->pos_y);
if (diff > 0) {
if (g->pitch < 0)
pen_y += diff;
else
pen_y -= diff;
}
else if (diff < 0) {
if (g->pitch < 0)
pen_y -= diff;
else
pen_y += diff;
}
if (g->pitch < 0)
chy= pen_y - ((int)g->pos_y);
else
chy= pen_y + ((int)g->pos_y);
if (font->b_fbuf) {
if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) {
if (g->pitch < 0)
yb= 0;
else
yb= g->height-1;
for (y= 0; y < g->height; y++) {
for (x= 0; x < g->width; x++) {
fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
data= g->bitmap + x + (yb * g->pitch);
a= data[0]/255.0f;
if (a == 1.0) {
fbuf[0]= font->b_col[0];
fbuf[1]= font->b_col[1];
fbuf[2]= font->b_col[2];
}
else {
fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a));
fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a));
fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a));
}
}
if (g->pitch < 0)
yb++;
else
yb--;
}
}
}
if (font->b_cbuf) {
if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) {
if (g->pitch < 0)
yb= 0;
else
yb= g->height-1;
for (y= 0; y < g->height; y++) {
for (x= 0; x < g->width; x++) {
cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
data= g->bitmap + x + (yb * g->pitch);
a= data[0];
if (a == 256) {
cbuf[0]= font->b_col[0];
cbuf[1]= font->b_col[1];
cbuf[2]= font->b_col[2];
}
else {
cbuf[0]= (font->b_col[0]*a) + (cbuf[0] * (256-a));
cbuf[1]= (font->b_col[1]*a) + (cbuf[1] * (256-a));
cbuf[2]= (font->b_col[2]*a) + (cbuf[2] * (256-a));
}
}
if (g->pitch < 0)
yb++;
else
yb--;
}
}
}
if (diff > 0) {
if (g->pitch < 0)
pen_x -= diff;
else
pen_y += diff;
}
else if (diff < 0) {
if (g->pitch < 0)
pen_x += diff;
else
pen_y -= diff;
}
pen_x += g->advance;
g_prev= g;
}
}
@@ -155,7 +306,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
unsigned int c;
GlyphBLF *g, *g_prev;
FT_Vector delta;
FT_UInt glyph_index, g_prev_index;
FT_UInt glyph_index;
rctf gbox;
int pen_x, pen_y;
int i, has_kerning, st;
@@ -173,17 +324,17 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
pen_y= 0;
has_kerning= FT_HAS_KERNING(font->face);
g_prev= NULL;
g_prev_index= 0;
while (str[i]) {
c= blf_utf8_next((unsigned char *)str, &i);
if (c == 0)
break;
glyph_index= FT_Get_Char_Index(font->face, c);
g= blf_glyph_search(font->glyph_cache, c);
if (!g)
if (!g) {
glyph_index= FT_Get_Char_Index(font->face, c);
g= blf_glyph_add(font, glyph_index, c);
}
/* if we don't found a glyph, skip it. */
if (!g)
@@ -194,9 +345,9 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
delta.y= 0;
if (font->flags & BLF_KERNING_DEFAULT)
st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, ft_kerning_default, &delta);
st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta);
else
st= FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta);
st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta);
if (st == 0)
pen_x += delta.x >> 6;
@@ -219,7 +370,6 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
pen_x += g->advance;
g_prev= g;
g_prev_index= glyph_index;
}
if (box->xmin > box->xmax) {
@@ -230,6 +380,17 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
}
}
void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height)
{
rctf box;
if (font->glyph_cache) {
blf_font_boundbox(font, str, &box);
*width= ((box.xmax - box.xmin) * font->aspect);
*height= ((box.ymax - box.ymin) * font->aspect);
}
}
float blf_font_width(FontBLF *font, char *str)
{
rctf box;
@@ -311,6 +472,15 @@ void blf_font_fill(FontBLF *font)
font->glyph_cache= NULL;
font->blur= 0;
font->max_tex_size= -1;
font->b_fbuf= NULL;
font->b_cbuf= NULL;
font->bw= 0;
font->bh= 0;
font->bch= 0;
font->b_col[0]= 0;
font->b_col[1]= 0;
font->b_col[2]= 0;
font->b_col[3]= 0;
}
FontBLF *blf_font_new(char *name, char *filename)
@@ -217,6 +217,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c)
g->next= NULL;
g->prev= NULL;
g->c= c;
g->idx= index;
g->tex= 0;
g->build_tex= 0;
g->bitmap= NULL;
@@ -238,6 +239,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c)
g->advance= ((float)slot->advance.x) / 64.0f;
g->pos_x= slot->bitmap_left;
g->pos_y= slot->bitmap_top;
g->pitch= slot->bitmap.pitch;
FT_Outline_Get_CBox(&(slot->outline), &bbox);
g->box.xmin= ((float)bbox.xMin) / 64.0f;
@@ -45,7 +45,9 @@ void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_s
void blf_font_size(FontBLF *font, int size, int dpi);
void blf_font_draw(FontBLF *font, char *str);
void blf_font_buffer(FontBLF *font, char *str);
void blf_font_boundbox(FontBLF *font, char *str, rctf *box);
void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height);
float blf_font_width(FontBLF *font, char *str);
float blf_font_height(FontBLF *font, char *str);
float blf_font_fixed_width(FontBLF *font);
@@ -85,6 +85,9 @@ typedef struct GlyphBLF {
/* and the character, as UTF8 */
unsigned int c;
/* freetype2 index, to speed-up the search. */
FT_UInt idx;
/* glyph box. */
rctf box;
@@ -106,6 +109,7 @@ typedef struct GlyphBLF {
/* glyph width and height. */
int width;
int height;
int pitch;
/* uv coords. */
float uv[2][2];
@@ -176,6 +180,22 @@ typedef struct FontBLF {
/* freetype2 face. */
FT_Face face;
/* for draw to buffer, always set this to NULL after finish! */
float *b_fbuf;
/* the same but unsigned char */
unsigned char *b_cbuf;
/* buffer size. */
unsigned int bw;
unsigned int bh;
/* number of channels. */
int bch;
/* and the color, the alphas is get from the glyph! */
float b_col[4];
} FontBLF;
typedef struct DirBLF {
+1 -1
View File
@@ -66,7 +66,7 @@ void free_action(struct bAction *act);
void make_local_action(struct bAction *act);
/* Some kind of bounding box operation on the action */
void calc_action_range(const struct bAction *act, float *start, float *end, int incl_hidden);
void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers);
/* Does action have any motion data at all? */
short action_has_motion(const struct bAction *act);
+1 -1
View File
@@ -51,7 +51,7 @@ typedef struct DupliObject {
void free_path(struct Path *path);
void calc_curvepath(struct Object *ob);
int interval_test(int min, int max, int p1, int cycl);
int where_on_path(struct Object *ob, float ctime, float *vec, float *dir);
int where_on_path(struct Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius);
struct ListBase *object_duplilist(struct Scene *sce, struct Object *ob);
void free_object_duplilist(struct ListBase *lb);
+3
View File
@@ -55,6 +55,9 @@ void BKE_free_animdata(struct ID *id);
/* Copy AnimData */
struct AnimData *BKE_copy_animdata(struct AnimData *adt);
/* Make Local */
void BKE_animdata_make_local(struct AnimData *adt);
/* ************************************* */
/* KeyingSets API */
-1
View File
@@ -74,7 +74,6 @@ struct bArmature *add_armature(char *name);
struct bArmature *get_armature(struct Object *ob);
void free_boneChildren(struct Bone *bone);
void free_bones (struct bArmature *arm);
void unlink_armature(struct bArmature *arm);
void free_armature(struct bArmature *arm);
void make_local_armature(struct bArmature *arm);
struct bArmature *copy_armature(struct bArmature *arm);
+1 -1
View File
@@ -43,7 +43,7 @@ struct bContext;
struct ReportList;
#define BLENDER_VERSION 250
#define BLENDER_SUBVERSION 1
#define BLENDER_SUBVERSION 3
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
-1
View File
@@ -64,7 +64,6 @@ float brush_curve_strength(struct Brush *br, float p, const float len);
/* sampling */
float brush_sample_falloff(struct Brush *brush, float dist);
float brush_sample_falloff_noalpha(struct Brush *brush, float dist);
void brush_sample_tex(struct Brush *brush, float *xy, float *rgba);
void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size,
struct ImBuf **imbuf);
+2 -1
View File
@@ -176,7 +176,8 @@ typedef enum
CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), // we have goals enabled
CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled
CLOTH_SIMSETTINGS_FLAG_SCALING = ( 1 << 8 ), /* is advanced scaling active? */
CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12) /* edit cache in editmode */
CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12), /* edit cache in editmode */
CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS = (1 << 13) /* don't allow spring compression */
} CLOTH_SIMSETTINGS_FLAGS;
/* COLLISION FLAGS */
@@ -49,6 +49,7 @@ typedef struct bConstraintOb {
float startmat[4][4]; /* original matrix (before constraint solving) */
short type; /* type of owner */
short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_arithb.h) */
} bConstraintOb;
/* ---------------------------------------------------------------------------- */
+1
View File
@@ -152,6 +152,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C);
struct SpaceIpo *CTX_wm_space_graph(const bContext *C);
struct SpaceAction *CTX_wm_space_action(const bContext *C);
struct SpaceInfo *CTX_wm_space_info(const bContext *C);
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C);
void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm);
void CTX_wm_window_set(bContext *C, struct wmWindow *win);
+2 -2
View File
@@ -47,7 +47,7 @@ struct BevList;
#define SEGMENTSU(nu) ( ((nu)->flagu & CU_CYCLIC) ? (nu)->pntsu : (nu)->pntsu-1 )
#define SEGMENTSV(nu) ( ((nu)->flagv & CU_CYCLIC) ? (nu)->pntsv : (nu)->pntsv-1 )
#define CU_DO_TILT(cu, nu) (((nu->type & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1)
#define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1)
#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || cu->bevobj || cu->ext1!=0.0 || cu->ext2!=0.0) ? 1:0)
@@ -72,7 +72,7 @@ void minmaxNurb( struct Nurb *nu, float *min, float *max);
void makeknots( struct Nurb *nu, short uv);
void makeNurbfaces(struct Nurb *nu, float *coord_array, int rowstride);
void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu);
void makeNurbcurve(struct Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, int resolu, int stride);
void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride);
float *make_orco_curve(struct Scene *scene, struct Object *ob);
float *make_orco_surf( struct Object *ob);
+5 -2
View File
@@ -32,6 +32,8 @@
#define DEPS_DEBUG
*/
struct ID;
struct Main;
struct Scene;
struct DagNodeQueue;
struct DagForest;
@@ -103,8 +105,9 @@ void DAG_object_update_flags(struct Scene *sce, struct Object *ob, unsigned int
/* flushes all recalc flags in objects down the dependency tree */
void DAG_scene_flush_update(struct Scene *sce, unsigned int lay, int time);
/* flushes all recalc flags for this object down the dependency tree */
void DAG_object_flush_update(struct Scene *sce, struct Object *ob, short flag);
/* flushes all recalc flags for this object down the dependency tree,
but not the DAG only supports objects and object data currently */
void DAG_id_flush_update(struct ID *id, short flag);
void DAG_pose_sort(struct Object *ob);
+16 -17
View File
@@ -119,33 +119,32 @@ typedef struct Global {
#define G_GREASEPENCIL (1 << 17)
/* #define G_AUTOMATKEYS (1 << 30) also removed */
#define G_HIDDENHANDLES (1 << 31) /* used for curves only */
/* G.fileflags */
#define G_AUTOPACK (1 << 0)
#define G_FILE_COMPRESS (1 << 1)
#define G_FILE_AUTOPLAY (1 << 2)
#define G_FILE_ENABLE_ALL_FRAMES (1 << 3)
#define G_FILE_SHOW_DEBUG_PROPS (1 << 4)
#define G_FILE_SHOW_FRAMERATE (1 << 5)
#define G_FILE_SHOW_PROFILE (1 << 6)
#define G_FILE_ENABLE_ALL_FRAMES (1 << 3) /* deprecated */
#define G_FILE_SHOW_DEBUG_PROPS (1 << 4) /* deprecated */
#define G_FILE_SHOW_FRAMERATE (1 << 5) /* deprecated */
#define G_FILE_SHOW_PROFILE (1 << 6) /* deprecated */
#define G_FILE_LOCK (1 << 7)
#define G_FILE_SIGN (1 << 8)
#define G_FIle_PUBLISH (1 << 9)
#define G_FILE_NO_UI (1 << 10)
#define G_FILE_GAME_TO_IPO (1 << 11)
#define G_FILE_GAME_MAT (1 << 12)
#define G_FILE_DISPLAY_LISTS (1 << 13)
#define G_FILE_SHOW_PHYSICS (1 << 14)
#define G_FILE_GAME_MAT_GLSL (1 << 15)
#define G_FILE_GLSL_NO_LIGHTS (1 << 16)
#define G_FILE_GLSL_NO_SHADERS (1 << 17)
#define G_FILE_GLSL_NO_SHADOWS (1 << 18)
#define G_FILE_GLSL_NO_RAMPS (1 << 19)
#define G_FILE_GLSL_NO_NODES (1 << 20)
#define G_FILE_GLSL_NO_EXTRA_TEX (1 << 21)
#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22)
#define G_FILE_GAME_TO_IPO (1 << 11) /* deprecated */
#define G_FILE_GAME_MAT (1 << 12) /* deprecated */
#define G_FILE_DISPLAY_LISTS (1 << 13) /* deprecated */
#define G_FILE_SHOW_PHYSICS (1 << 14) /* deprecated */
#define G_FILE_GAME_MAT_GLSL (1 << 15) /* deprecated */
#define G_FILE_GLSL_NO_LIGHTS (1 << 16) /* deprecated */
#define G_FILE_GLSL_NO_SHADERS (1 << 17) /* deprecated */
#define G_FILE_GLSL_NO_SHADOWS (1 << 18) /* deprecated */
#define G_FILE_GLSL_NO_RAMPS (1 << 19) /* deprecated */
#define G_FILE_GLSL_NO_NODES (1 << 20) /* deprecated */
#define G_FILE_GLSL_NO_EXTRA_TEX (1 << 21) /* deprecated */
#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22) /* deprecated */
/* G.windowstate */
#define G_WINDOWSTATE_USERDEF 0
+1
View File
@@ -41,6 +41,7 @@ void free_group_object(struct GroupObject *go);
void free_group(struct Group *group);
void unlink_group(struct Group *group);
struct Group *add_group(char *name);
struct Group *copy_group(struct Group *group);
void add_to_group(struct Group *group, struct Object *ob);
int rem_from_group(struct Group *group, struct Object *ob);
struct Group *find_group(struct Object *ob, struct Group *group);
+3 -2
View File
@@ -52,8 +52,9 @@ struct Key *copy_key(struct Key *key);
void make_local_key(struct Key *key);
void sort_keys(struct Key *key);
void set_four_ipo(float d, float *data, int type);
void set_afgeleide_four_ipo(float d, float *data, int type);
void key_curve_position_weights(float t, float *data, int type);
void key_curve_tangent_weights(float t, float *data, int type);
void key_curve_normal_weights(float t, float *data, int type);
/* only exported to curve.c! */
void cp_cu_key(struct Curve *cu, struct KeyBlock *kb, int start, int end);
+4
View File
@@ -46,6 +46,9 @@ void *copy_libblock(void *rt);
void id_lib_extern(struct ID *id);
void id_us_plus(struct ID *id);
void id_us_min(struct ID *id);
int id_make_local(struct ID *id, int test);
int id_copy(struct ID *id, struct ID **newid, int test);
int id_unlink(struct ID *id, int test);
int check_for_dupid(struct ListBase *lb, struct ID *id, char *name);
int new_id(struct ListBase *lb, struct ID *id, const char *name);
@@ -74,6 +77,7 @@ void IPOnames_to_pupstring(char **str, char *title, char *extraops, struct ListB
void flag_listbase_ids(ListBase *lb, short flag, short value);
void flag_all_listbases_ids(short flag, short value);
void recalc_all_library_objects(struct Main *main);
void set_free_windowmanager_cb(void (*func)(struct bContext *, struct wmWindowManager *) );
+4 -1
View File
@@ -90,7 +90,10 @@ typedef enum {
eModifierTypeFlag_UsesPointCache = (1<<6),
/* For physics modifiers, max one per type */
eModifierTypeFlag_Single = (1<<7)
eModifierTypeFlag_Single = (1<<7),
/* Some modifier can't be added manually by user */
eModifierTypeFlag_NoUserAdd = (1<<8)
} ModifierTypeFlag;
typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin);
+5 -3
View File
@@ -35,10 +35,12 @@ struct Object;
typedef struct MultiresSubsurf {
struct MultiresModifierData *mmd;
struct Mesh *me;
struct Object *ob;
int local_mmd;
} MultiresSubsurf;
/* MultiresDM */
struct Object *MultiresDM_get_object(struct DerivedMesh *dm);
struct Mesh *MultiresDM_get_mesh(struct DerivedMesh *dm);
struct DerivedMesh *MultiresDM_new(struct MultiresSubsurf *, struct DerivedMesh*, int, int, int);
void *MultiresDM_get_vertnorm(struct DerivedMesh *);
@@ -58,8 +60,8 @@ void multires_mark_as_modified(struct Object *ob);
void multires_force_update(struct Object *ob);
struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, struct DerivedMesh*,
struct Mesh *, int, int);
struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*,
struct Object *, int, int);
struct MultiresModifierData *find_multires_modifier(struct Object *ob);
int multiresModifier_switch_level(struct Object *, const int);
+7 -5
View File
@@ -25,7 +25,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Bob Holcomb.
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -325,7 +325,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
#define CMP_NODE_COMBYUVA 234
#define CMP_NODE_DIFF_MATTE 235
#define CMP_NODE_COLOR_SPILL 236
#define CMP_NODE_CHROMA 237
#define CMP_NODE_CHROMA_MATTE 237
#define CMP_NODE_CHANNEL_MATTE 238
#define CMP_NODE_FLIP 239
#define CMP_NODE_SPLITVIEWER 240
@@ -345,6 +345,9 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
#define CMP_NODE_DBLUR 254
#define CMP_NODE_BILATERALBLUR 255
#define CMP_NODE_PREMULKEY 256
#define CMP_NODE_DIST_MATTE 257
#define CMP_NODE_VIEW_LEVELS 258
#define CMP_NODE_COLOR_MATTE 259
#define CMP_NODE_GLARE 301
#define CMP_NODE_TONEMAP 302
@@ -421,10 +424,9 @@ extern struct ListBase node_all_textures;
/* API */
int ntreeTexTagAnimated(struct bNodeTree *ntree);
void ntreeTexUpdatePreviews( struct bNodeTree* nodetree );
void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, char do_preview, short thread, struct Tex *tex, short which_output, int cfra);
void ntreeTexSetPreviewFlag(int);
void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, short thread, struct Tex *tex, short which_output, int cfra);
void ntreeTexCheckCyclics(struct bNodeTree *ntree);
void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node);
char* ntreeTexOutputMenu(struct bNodeTree *ntree);
+5
View File
@@ -115,6 +115,11 @@ void object_handle_update(struct Scene *scene, struct Object *ob);
float give_timeoffset(struct Object *ob);
int give_obdata_texspace(struct Object *ob, int **texflag, float **loc, float **size, float **rot);
int object_insert_ptcache(struct Object *ob);
// void object_delete_ptcache(struct Object *ob, int index);
#ifdef __cplusplus
}
#endif
+45 -1
View File
@@ -29,11 +29,20 @@
#define BKE_PAINT_H
struct Brush;
struct MFace;
struct MultireModifierData;
struct MVert;
struct Object;
struct Paint;
struct Scene;
struct StrokeCache;
void paint_init(struct Paint *p, const char *brush_name);
extern const char PAINT_CURSOR_SCULPT[3];
extern const char PAINT_CURSOR_VERTEX_PAINT[3];
extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
void paint_init(struct Paint *p, const char col[3]);
void free_paint(struct Paint *p);
void copy_paint(struct Paint *orig, struct Paint *new);
@@ -48,4 +57,39 @@ void paint_brush_slot_remove(struct Paint *p);
* however hiding faces is useful */
int paint_facesel_test(struct Object *ob);
/* Session data (mode-specific) */
typedef struct SculptSession {
struct ProjVert *projverts;
/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
struct MultiresModifierData *multires; /* Special handling for multires meshes */
struct MVert *mvert;
struct MFace *mface;
int totvert, totface;
float *face_normals;
/* Mesh connectivity */
struct ListBase *fmap;
struct IndexNode *fmap_mem;
int fmap_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_side, *texcache, texcache_actual;
/* Layer brush persistence between strokes */
float (*mesh_co_orig)[3]; /* Copy of the mesh vertices' locations */
float *layer_disps; /* Displacements for each vertex */
struct SculptStroke *stroke;
struct StrokeCache *cache;
} SculptSession;
void free_sculptsession(SculptSession **);
#endif
+9 -47
View File
@@ -59,6 +59,9 @@ struct SurfaceModifierData;
struct BVHTreeRay;
struct BVHTreeRayHit;
#define PARTICLE_P ParticleData *pa; int p
#define LOOP_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++)
typedef struct ParticleEffectorCache {
struct ParticleEffectorCache *next, *prev;
struct Object *ob;
@@ -109,46 +112,10 @@ typedef struct ParticleCacheKey{
float vel[3];
float rot[4];
float col[3];
float time;
int steps;
} ParticleCacheKey;
typedef struct ParticleEditKey{
float *co;
float *vel;
float *rot;
float *time;
float world_co[3];
float length;
short flag;
} ParticleEditKey;
typedef struct ParticleUndo {
struct ParticleUndo *next, *prev;
struct ParticleEditKey **keys;
struct KDTree *emitter_field;
struct ParticleData *particles;
float *emitter_cosnos;
int totpart, totkeys;
char name[64];
} ParticleUndo;
typedef struct ParticleEdit {
ListBase undo;
struct ParticleUndo *curundo;
ParticleEditKey **keys;
int totkeys;
int *mirror_cache;
struct KDTree *emitter_field;
float *emitter_cosnos;
char sel_col[3];
char nosel_col[3];
} ParticleEdit;
typedef struct ParticleThreadContext {
/* shared */
struct Scene *scene;
@@ -240,9 +207,10 @@ int psys_check_enabled(struct Object *ob, struct ParticleSystem *psys);
void psys_free_boid_rules(struct ListBase *list);
void psys_free_settings(struct ParticleSettings *part);
void free_child_path_cache(struct ParticleSystem *psys);
void psys_free_path_cache(struct ParticleSystem *psys);
void free_hair(struct ParticleSystem *psys, int softbody);
void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit);
void free_hair(struct Object *ob, struct ParticleSystem *psys, int dynamics);
void free_keyed_keys(struct ParticleSystem *psys);
void psys_free_particles(struct ParticleSystem *psys);
void psys_free(struct Object * ob, struct ParticleSystem * psys);
void psys_free_children(struct ParticleSystem *psys);
@@ -271,9 +239,9 @@ void psys_reset(struct ParticleSystem *psys, int mode);
void psys_find_parents(struct Object *ob, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys);
void psys_cache_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate);
void psys_cache_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra);
void psys_cache_edit_paths(struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra);
void psys_cache_child_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate);
void psys_update_world_cos(struct Object *ob, struct ParticleSystem *psys);
int do_guide(struct Scene *scene, struct ParticleKey *state, int pa_num, float time, struct ListBase *lb);
float psys_get_size(struct Object *ob, struct Material *ma, struct ParticleSystemModifierData *psmd, struct IpoCurve *icu_size, struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleData *pa, float *vg_size);
float psys_get_timestep(struct ParticleSettings *part);
@@ -359,12 +327,6 @@ void reset_particle(struct Scene *scene, struct ParticleData *pa, struct Particl
#define PSYS_EC_PARTICLE 4
#define PSYS_EC_REACTOR 8
/* ParticleEditKey->flag */
#define PEK_SELECT 1
#define PEK_TO_SELECT 2
#define PEK_TAG 4
#define PEK_HIDE 8
/* index_dmcache */
#define DMCACHE_NOTFOUND -1
#define DMCACHE_ISCHILD -2
+82 -4
View File
@@ -60,8 +60,8 @@
#define PTCACHE_TYPE_SOFTBODY 0
#define PTCACHE_TYPE_PARTICLES 1
#define PTCACHE_TYPE_CLOTH 2
#define PTCACHE_TYPE_SMOKE_DOMAIN_LOW 3
#define PTCACHE_TYPE_SMOKE_DOMAIN_HIGH 4
#define PTCACHE_TYPE_SMOKE_DOMAIN 3
#define PTCACHE_TYPE_SMOKE_HIGHRES 4
/* PTCache read return code */
#define PTCACHE_READ_EXACT 1
@@ -101,6 +101,8 @@ typedef struct PTCacheFile {
void *cur[BPHYS_TOT_DATA];
} PTCacheFile;
#define PTCACHE_VEL_PER_SEC 1
typedef struct PTCacheID {
struct PTCacheID *next, *prev;
@@ -109,6 +111,7 @@ typedef struct PTCacheID {
void *calldata;
int type;
int stack_index;
int flag;
/* flags defined in DNA_object_force.h */
unsigned int data_types, info_types;
@@ -151,6 +154,76 @@ typedef struct PTCacheBaker {
void *progresscontext;
} PTCacheBaker;
/* PTCacheEditKey->flag */
#define PEK_SELECT 1
#define PEK_TAG 2
#define PEK_HIDE 4
#define PEK_USE_WCO 8
typedef struct PTCacheEditKey{
float *co;
float *vel;
float *rot;
float *time;
float world_co[3];
float ftime;
float length;
short flag;
} PTCacheEditKey;
/* PTCacheEditPoint->flag */
#define PEP_TAG 1
#define PEP_EDIT_RECALC 2
#define PEP_TRANSFORM 4
#define PEP_HIDE 8
typedef struct PTCacheEditPoint {
struct PTCacheEditKey *keys;
int totkey;
short flag;
} PTCacheEditPoint;
typedef struct PTCacheUndo {
struct PTCacheUndo *next, *prev;
struct PTCacheEditPoint *points;
/* particles stuff */
struct ParticleData *particles;
struct KDTree *emitter_field;
float *emitter_cosnos;
int psys_flag;
/* cache stuff */
struct ListBase mem_cache;
int totpoint;
char name[64];
} PTCacheUndo;
typedef struct PTCacheEdit {
ListBase undo;
struct PTCacheUndo *curundo;
PTCacheEditPoint *points;
struct PTCacheID pid;
/* particles stuff */
struct ParticleSystem *psys;
struct ParticleData *particles;
struct KDTree *emitter_field;
float *emitter_cosnos;
int *mirror_cache;
struct ParticleCacheKey **pathcache; /* path cache (runtime) */
ListBase pathcachebufs;
int totpoint, totframes, totcached, edited;
char sel_col[3];
char nosel_col[3];
} PTCacheEdit;
/* Particle functions */
void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **data, float time);
@@ -158,7 +231,8 @@ void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **da
void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb);
void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys);
void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd);
void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num);
void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd);
void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob);
@@ -179,6 +253,10 @@ void BKE_ptcache_update_info(PTCacheID *pid);
/* Size of cache data type. */
int BKE_ptcache_data_size(int data_type);
/* Memory cache read/write helpers. */
void BKE_ptcache_mem_init_pointers(struct PTCacheMem *pm);
void BKE_ptcache_mem_incr_pointers(struct PTCacheMem *pm);
/* Copy a specific data type from cache data to point data. */
void BKE_ptcache_data_get(void **data, int type, int index, void *to);
@@ -197,7 +275,7 @@ int BKE_ptcache_get_continue_physics(void);
/******************* Allocate & free ***************/
struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches);
void BKE_ptache_free_mem(struct PointCache *cache);
void BKE_ptcache_free_mem(struct ListBase *mem_cache);
void BKE_ptcache_free(struct PointCache *cache);
void BKE_ptcache_free_list(struct ListBase *ptcaches);
struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, struct ListBase *ptcaches_old);
-1
View File
@@ -47,7 +47,6 @@ void unlink_actuators(struct ListBase *lb);
void free_actuator(struct bActuator *act);
void free_actuators(struct ListBase *lb);
void free_text_controllers(struct Text *txt);
void free_sensor(struct bSensor *sens);
void free_sensors(struct ListBase *lb);
struct bSensor *copy_sensor(struct bSensor *sens);
-2
View File
@@ -84,7 +84,5 @@ int get_render_child_particle_number(struct RenderData *r, int num);
int get_render_shadow_samples(struct RenderData *r, int samples);
float get_render_aosss_error(struct RenderData *r, float error);
void free_dome_warp_text(struct Text *txt);
#endif
-72
View File
@@ -1,72 +0,0 @@
/*
* $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 MFace;
struct MultireModifierData;
struct MVert;
struct Object;
struct StrokeCache;
typedef struct SculptSession {
struct ProjVert *projverts;
/* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
struct MultiresModifierData *multires; /* Special handling for multires meshes */
struct MVert *mvert;
struct MFace *mface;
int totvert, totface;
float *face_normals;
/* Mesh connectivity */
struct ListBase *fmap;
struct IndexNode *fmap_mem;
int fmap_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_side, *texcache, texcache_actual;
/* Layer brush persistence between strokes */
float (*mesh_co_orig)[3]; /* Copy of the mesh vertices' locations */
float *layer_disps; /* Displacements for each vertex */
struct SculptStroke *stroke;
struct StrokeCache *cache;
} SculptSession;
void free_sculptsession(SculptSession **);
#endif
+2 -2
View File
@@ -115,9 +115,9 @@ typedef struct ShrinkwrapCalcData
int vgroup; //Vertex group num
struct DerivedMesh *target; //mesh we are shrinking to
SpaceTransform local2target; //transform to move bettwem local and target space
SpaceTransform local2target; //transform to move between local and target space
float keepDist; //Distance to kept from target (units are in local space)
float keepDist; //Distance to keep above target surface (units are in local space)
} ShrinkwrapCalcData;
+3 -12
View File
@@ -32,24 +32,15 @@
#ifndef BKE_SMOKE_H_
#define BKE_SMOKE_H_
typedef float (*bresenham_callback) (float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
void smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc);
void smokeModifier_free (struct SmokeModifierData *smd);
void smokeModifier_reset(struct SmokeModifierData *smd);
void smokeModifier_reset_turbulence(struct SmokeModifierData *smd);
void smokeModifier_createType(struct SmokeModifierData *smd);
void smoke_set_tray(struct SmokeModifierData *smd, size_t index, float transparency);
float smoke_get_tray(struct SmokeModifierData *smd, size_t index);
float smoke_get_tvox(struct SmokeModifierData *smd, size_t index);
void smoke_set_tvox(struct SmokeModifierData *smd, size_t index, float tvox);
void smoke_set_bigtray(struct SmokeModifierData *smd, size_t index, float transparency);
float smoke_get_bigtray(struct SmokeModifierData *smd, size_t index);
float smoke_get_bigtvox(struct SmokeModifierData *smd, size_t index);
void smoke_set_bigtvox(struct SmokeModifierData *smd, size_t index, float tvox);
long long smoke_get_mem_req(int xres, int yres, int zres, int amplify);
void smoke_prepare_View(struct SmokeModifierData *smd, float *light);
void smoke_prepare_bigView(struct SmokeModifierData *smd, float *light);
#endif /* BKE_SMOKE_H_ */
+3 -1
View File
@@ -54,7 +54,9 @@ void sound_delete(struct bContext *C, struct bSound* sound);
void sound_cache(struct bSound* sound, int ignore);
void sound_load(struct bSound* sound);
void sound_delete_cache(struct bSound* sound);
void sound_load(struct Main *main, struct bSound* sound);
void sound_free(struct bSound* sound);
+2
View File
@@ -35,6 +35,7 @@
extern "C" {
#endif
struct Main;
struct Text;
struct TextLine;
struct SpaceText;
@@ -46,6 +47,7 @@ struct Text* add_empty_text (char *name);
int reopen_text (struct Text *text);
struct Text* add_text (char *file, const char *relpath);
struct Text* copy_text (struct Text *ta);
void unlink_text (struct Main *bmain, struct Text *text);
char* txt_to_buf (struct Text *text);
void txt_clean_text (struct Text *text);
+12
View File
@@ -40,6 +40,8 @@ struct ColorBand;
struct HaloRen;
struct TexMapping;
struct EnvMap;
struct PointDensity;
struct VoxelData;
/* in ColorBand struct */
#define MAXCOLORBAND 32
@@ -75,6 +77,16 @@ void BKE_free_envmap(struct EnvMap *env);
struct EnvMap *BKE_add_envmap(void);
struct EnvMap *BKE_copy_envmap(struct EnvMap *env);
void BKE_free_pointdensitydata(struct PointDensity *pd);
void BKE_free_pointdensity(struct PointDensity *pd);
struct PointDensity *BKE_add_pointdensity(void);
struct PointDensity *BKE_copy_pointdensity(struct PointDensity *pd);
void BKE_free_voxeldatadata(struct VoxelData *vd);
void BKE_free_voxeldata(struct VoxelData *vd);
struct VoxelData *BKE_add_voxeldata(void);
struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd);
int BKE_texture_dependsOnTime(const struct Tex *texture);
#endif
@@ -115,6 +115,7 @@
#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
#define VECSUB2D(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);}
#define VECADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac);}
#define VECSUBFAC(v1,v2,v3,fac) {*(v1)= *(v2) - *(v3)*(fac); *(v1+1)= *(v2+1) - *(v3+1)*(fac); *(v1+2)= *(v2+2) - *(v3+2)*(fac);}
#define QUATADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac); *(v1+3)= *(v2+3) + *(v3+3)*(fac);}
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
@@ -200,5 +201,54 @@
#define SET_INT_IN_POINTER(i) ((void*)(intptr_t)(i))
#define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i))
/*little array macro library. example of usage:
int *arr = NULL;
V_DECLARE(arr);
int i;
for (i=0; i<10; i++) {
V_GROW(arr);
arr[i] = something;
}
V_FREE(arr);
arrays are buffered, using double-buffering (so on each reallocation,
the array size is doubled). supposedly this should give good Big Oh
behaviour, though it may not be the best in practice.
*/
#define V_DECLARE(vec) int _##vec##_count=0; void *_##vec##_tmp
/*in the future, I plan on having V_DECLARE allocate stack memory it'll
use at first, and switch over to heap when it needs more. that'll mess
up cases where you'd want to use this API to build a dynamic list for
non-local use, so all such cases should use this macro.*/
#define V_DYNDECLARE(vec) V_DECLARE(vec)
/*this returns the entire size of the array, including any buffering.*/
#define V_SIZE(vec) ((signed int)((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec)))
/*this returns the logical size of the array, not including buffering.*/
#define V_COUNT(vec) _##vec##_count
/*grow the array by one. zeroes the new elements.*/
#define V_GROW(vec) \
V_SIZE(vec) > _##vec##_count ? _##vec##_count++ : \
((_##vec##_tmp = MEM_callocN(sizeof(*vec)*(_##vec##_count*2+2), #vec " " __FILE__ " ")),\
(vec && memcpy(_##vec##_tmp, vec, sizeof(*vec) * _##vec##_count)),\
(vec && (MEM_freeN(vec),1)),\
(vec = _##vec##_tmp),\
_##vec##_count++)
#define V_FREE(vec) if (vec) MEM_freeN(vec);
/*resets the logical size of an array to zero, but doesn't
free the memory.*/
#define V_RESET(vec) _##vec##_count=0
/*set the count of the array*/
#define V_SETCOUNT(vec, count) _##vec##_count = (count)
#endif
+26 -20
View File
@@ -27,51 +27,57 @@
FILE(GLOB SRC intern/*.c)
SET(INC
. ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna
../render/extern/include ../../../intern/decimation/extern
../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern
../../../intern/iksolver/extern ../blenloader ../quicktime
../../../extern/bullet2/src
../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern
../../../intern/bsp/extern
../../../intern/audaspace/intern
${ZLIB_INC}
. ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna
../render/extern/include ../../../intern/decimation/extern
../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern
../../../intern/iksolver/extern ../blenloader
../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern
../../../intern/bsp/extern ../blenfont
../../../intern/audaspace/intern
../../../extern/lzo/minilzo
../../../extern/lzma
${ZLIB_INC}
)
IF(WITH_BULLET)
SET(INC ${INC} ../../../extern/bullet2/src)
ADD_DEFINITIONS(-DUSE_BULLET)
ENDIF(WITH_BULLET)
IF(WITH_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
ENDIF(WITH_OPENEXR)
IF(WITH_OPENJPEG)
ADD_DEFINITIONS(-DWITH_OPENJPEG)
ADD_DEFINITIONS(-DWITH_OPENJPEG)
ENDIF(WITH_OPENJPEG)
IF(WITH_DDS)
ADD_DEFINITIONS(-DWITH_DDS)
ADD_DEFINITIONS(-DWITH_DDS)
ENDIF(WITH_DDS)
IF(WITH_QUICKTIME)
SET(INC ${INC} ${QUICKTIME_INC})
ADD_DEFINITIONS(-DWITH_QUICKTIME)
SET(INC ${INC} ../quicktime ${QUICKTIME_INC})
ADD_DEFINITIONS(-DWITH_QUICKTIME)
ENDIF(WITH_QUICKTIME)
IF(WITH_FFMPEG)
SET(INC ${INC} ${FFMPEG_INC})
ADD_DEFINITIONS(-DWITH_FFMPEG)
SET(INC ${INC} ${FFMPEG_INC})
ADD_DEFINITIONS(-DWITH_FFMPEG)
ENDIF(WITH_FFMPEG)
IF(WITH_PYTHON)
SET(INC ${INC} ../python ${PYTHON_INC})
SET(INC ${INC} ../python ${PYTHON_INC})
ELSE(WITH_PYTHON)
ADD_DEFINITIONS(-DDISABLE_PYTHON)
ADD_DEFINITIONS(-DDISABLE_PYTHON)
ENDIF(WITH_PYTHON)
IF(NOT WITH_ELBEEM)
ADD_DEFINITIONS(-DDISABLE_ELBEEM)
ADD_DEFINITIONS(-DDISABLE_ELBEEM)
ENDIF(NOT WITH_ELBEEM)
IF(WIN32)
SET(INC ${INC} ${PTHREADS_INC})
SET(INC ${INC} ${PTHREADS_INC})
ENDIF(WIN32)
BLENDERLIB(bf_blenkernel "${SRC}" "${INC}")
+5 -3
View File
@@ -3,7 +3,7 @@ Import ('env')
sources = env.Glob('intern/*.c')
incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include ../blenlib ../makesdna'
incs = '. #/intern/guardedalloc #/intern/memutil ../editors/include ../blenlib ../blenfont ../makesdna'
incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna'
incs += ' ../imbuf ../avi #/intern/elbeem/extern ../nodes'
incs += ' #/intern/iksolver/extern ../blenloader'
@@ -11,6 +11,8 @@ incs += ' #/extern/bullet2/src'
incs += ' #/intern/opennl/extern #/intern/bsp/extern'
incs += ' ../gpu #/extern/glew/include'
incs += ' #/intern/smoke/extern'
incs += ' #/extern/lzo/minilzo'
incs += ' #/extern/lzma'
incs += ' #/intern/audaspace/intern'
incs += ' ' + env['BF_OPENGL_INC']
@@ -52,7 +54,7 @@ if env['WITH_BF_QUICKTIME']:
incs += ' ' + env['BF_QUICKTIME_INC']
if env['WITH_BF_BULLET']:
defs.append('WITH_BULLET')
defs.append('USE_BULLET')
if env['BF_NO_ELBEEM']:
defs.append('DISABLE_ELBEEM')
@@ -63,4 +65,4 @@ if env['WITH_BF_LCMS']:
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs += ' ' + env['BF_PTHREADS_INC']
env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core'], priority = [165] )
env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25] )
@@ -2077,7 +2077,7 @@ static void clear_mesh_caches(Object *ob)
static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask)
{
Object *obact = scene->basact?scene->basact->object:NULL;
int editing = paint_facesel_test(ob)|(ob && ob->mode & OB_MODE_PARTICLE_EDIT);
int editing = paint_facesel_test(ob);
int needMapping = editing && (ob==obact);
float min[3], max[3];
@@ -51,6 +51,7 @@ CPPFLAGS += -I../../imbuf
CPPFLAGS += -I../../blenlib
CPPFLAGS += -I../../blenloader
CPPFLAGS += -I../../python
CPPFLAGS += -I../../blenfont
# also avi is used
CPPFLAGS += -I../../avi
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
@@ -89,6 +90,10 @@ CPPFLAGS += -I$(NAN_BULLET2)/include
CPPFLAGS += -I$(NAN_FREETYPE)/include
CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
# lzo and lzma, for pointcache
CPPFLAGS += -I$(NAN_LZO)/minilzo
CPPFLAGS += -I$(NAN_LZMA)
ifeq ($(WITH_FFMPEG),true)
CPPFLAGS += -DWITH_FFMPEG
CPPFLAGS += $(NAN_FFMPEGCFLAGS)
@@ -110,3 +115,4 @@ ifeq ($(WITH_QUICKTIME), true)
CPPFLAGS += -I../../quicktime
CPPFLAGS += -DWITH_QUICKTIME
endif
+50 -5
View File
@@ -410,8 +410,9 @@ bActionGroup *action_groups_find_named (bAction *act, const char name[])
bPoseChannel *get_pose_channel(const bPose *pose, const char *name)
{
bPoseChannel *chan;
if (pose==NULL) return NULL;
if (ELEM(NULL, pose, name) || (name[0] == 0))
return NULL;
for (chan=pose->chanbase.first; chan; chan=chan->next) {
if (chan->name[0] == name[0]) {
@@ -837,14 +838,15 @@ short action_has_motion(const bAction *act)
}
/* Calculate the extents of given action */
void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden)
void calc_action_range(const bAction *act, float *start, float *end, short incl_modifiers)
{
FCurve *fcu;
float min=999999999.0f, max=-999999999.0f;
short foundvert=0;
short foundvert=0, foundmod=0;
if (act) {
for (fcu= act->curves.first; fcu; fcu= fcu->next) {
/* if curve has keyframes, consider them first */
if (fcu->totvert) {
float nmin, nmax;
@@ -857,10 +859,53 @@ void calc_action_range(const bAction *act, float *start, float *end, int incl_hi
foundvert= 1;
}
/* if incl_modifiers is enabled, need to consider modifiers too
* - only really care about the last modifier
*/
if ((incl_modifiers) && (fcu->modifiers.last)) {
FModifier *fcm= fcu->modifiers.last;
/* only use the maximum sensible limits of the modifiers if they are more extreme */
switch (fcm->type) {
case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */
{
FMod_Limits *fmd= (FMod_Limits *)fcm->data;
if (fmd->flag & FCM_LIMIT_XMIN) {
min= MIN2(min, fmd->rect.xmin);
}
if (fmd->flag & FCM_LIMIT_XMAX) {
max= MAX2(max, fmd->rect.xmax);
}
}
break;
case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */
{
FMod_Cycles *fmd= (FMod_Cycles *)fcm->data;
if (fmd->before_mode != FCM_EXTRAPOLATE_NONE)
min= MINAFRAMEF;
if (fmd->after_mode != FCM_EXTRAPOLATE_NONE)
max= MAXFRAMEF;
}
break;
// TODO: function modifier may need some special limits
default: /* all other standard modifiers are on the infinite range... */
min= MINAFRAMEF;
max= MAXFRAMEF;
break;
}
foundmod= 1;
}
}
}
if (foundvert) {
if (foundvert || foundmod) {
if(min==max) max+= 1.0f;
*start= min;
*end= max;
+55 -41
View File
@@ -87,15 +87,16 @@ void free_path(Path *path)
void calc_curvepath(Object *ob)
{
BevList *bl;
BevPoint *bevp, *bevpn, *bevpfirst, *bevplast, *tempbevp;
BevPoint *bevp, *bevpn, *bevpfirst, *bevplast;
PathPoint *pp;
Curve *cu;
Nurb *nu;
Path *path;
float *fp, *dist, *maxdist, x, y, z;
float *fp, *dist, *maxdist, xyz[3];
float fac, d=0, fac1, fac2;
int a, tot, cycl=0;
float *ft;
/* in a path vertices are with equal differences: path->len = number of verts */
/* NOW WITH BEVELCURVE!!! */
@@ -132,19 +133,12 @@ void calc_curvepath(Object *ob)
*fp= 0;
for(a=0; a<tot; a++) {
fp++;
if(cycl && a==tot-1) {
x= bevpfirst->x - bevp->x;
y= bevpfirst->y - bevp->y;
z= bevpfirst->z - bevp->z;
}
else {
tempbevp = bevp+1;
x= (tempbevp)->x - bevp->x;
y= (tempbevp)->y - bevp->y;
z= (tempbevp)->z - bevp->z;
}
*fp= *(fp-1)+ (float)sqrt(x*x+y*y+z*z);
if(cycl && a==tot-1)
VecSubf(xyz, bevpfirst->vec, bevp->vec);
else
VecSubf(xyz, (bevp+1)->vec, bevp->vec);
*fp= *(fp-1)+VecLength(xyz);
bevp++;
}
@@ -152,7 +146,7 @@ void calc_curvepath(Object *ob)
/* the path verts in path->data */
/* now also with TILT value */
ft= path->data = (float *)MEM_callocN(16*path->len, "pathdata");
pp= path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint)*4*path->len, "pathdata"); // XXX - why *4? - in 2.4x each element was 4 and the size was 16, so better leave for now - Campbell
bevp= bevpfirst;
bevpn= bevp+1;
@@ -182,13 +176,13 @@ void calc_curvepath(Object *ob)
fac1= fac2/fac1;
fac2= 1.0f-fac1;
ft[0]= fac1*bevp->x+ fac2*(bevpn)->x;
ft[1]= fac1*bevp->y+ fac2*(bevpn)->y;
ft[2]= fac1*bevp->z+ fac2*(bevpn)->z;
ft[3]= fac1*bevp->alfa+ fac2*(bevpn)->alfa;
VecLerpf(pp->vec, bevp->vec, bevpn->vec, fac2);
pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa;
pp->radius= fac1*bevp->radius + fac2*bevpn->radius;
QuatInterpol(pp->quat, bevp->quat, bevpn->quat, fac2);
NormalQuat(pp->quat);
ft+= 4;
pp++;
}
MEM_freeN(dist);
@@ -212,13 +206,14 @@ int interval_test(int min, int max, int p1, int cycl)
/* warning, *vec needs FOUR items! */
/* ctime is normalized range <0-1> */
int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK */
int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius) /* returns OK */
{
Curve *cu;
Nurb *nu;
BevList *bl;
Path *path;
float *fp, *p0, *p1, *p2, *p3, fac;
PathPoint *pp, *p0, *p1, *p2, *p3;
float fac;
float data[4];
int cycl=0, s0, s1, s2, s3;
@@ -229,7 +224,7 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK
return 0;
}
path= cu->path;
fp= path->data;
pp= path->data;
/* test for cyclic */
bl= cu->bev.first;
@@ -248,19 +243,19 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK
s2= interval_test(0, path->len-1-cycl, s1+1, cycl);
s3= interval_test(0, path->len-1-cycl, s1+2, cycl);
p0= fp + 4*s0;
p1= fp + 4*s1;
p2= fp + 4*s2;
p3= fp + 4*s3;
p0= pp + s0;
p1= pp + s1;
p2= pp + s2;
p3= pp + s3;
/* note, commented out for follow constraint */
//if(cu->flag & CU_FOLLOW) {
set_afgeleide_four_ipo(1.0f-fac, data, KEY_BSPLINE);
key_curve_tangent_weights(1.0f-fac, data, KEY_BSPLINE);
dir[0]= data[0]*p0[0] + data[1]*p1[0] + data[2]*p2[0] + data[3]*p3[0] ;
dir[1]= data[0]*p0[1] + data[1]*p1[1] + data[2]*p2[1] + data[3]*p3[1] ;
dir[2]= data[0]*p0[2] + data[1]*p1[2] + data[2]*p2[2] + data[3]*p3[2] ;
dir[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ;
dir[1]= data[0]*p0->vec[1] + data[1]*p1->vec[1] + data[2]*p2->vec[1] + data[3]*p3->vec[1] ;
dir[2]= data[0]*p0->vec[2] + data[1]*p1->vec[2] + data[2]*p2->vec[2] + data[3]*p3->vec[2] ;
/* make compatible with vectoquat */
dir[0]= -dir[0];
@@ -271,16 +266,35 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK
nu= cu->nurb.first;
/* make sure that first and last frame are included in the vectors here */
if((nu->type & 7)==CU_POLY) set_four_ipo(1.0f-fac, data, KEY_LINEAR);
else if((nu->type & 7)==CU_BEZIER) set_four_ipo(1.0f-fac, data, KEY_LINEAR);
else if(s0==s1 || p2==p3) set_four_ipo(1.0f-fac, data, KEY_CARDINAL);
else set_four_ipo(1.0f-fac, data, KEY_BSPLINE);
if(nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
else if(nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR);
else if(s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL);
else key_curve_position_weights(1.0f-fac, data, KEY_BSPLINE);
vec[0]= data[0]*p0[0] + data[1]*p1[0] + data[2]*p2[0] + data[3]*p3[0] ;
vec[1]= data[0]*p0[1] + data[1]*p1[1] + data[2]*p2[1] + data[3]*p3[1] ;
vec[2]= data[0]*p0[2] + data[1]*p1[2] + data[2]*p2[2] + data[3]*p3[2] ;
vec[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ; /* X */
vec[1]= data[0]*p0->vec[1] + data[1]*p1->vec[1] + data[2]*p2->vec[1] + data[3]*p3->vec[1] ; /* Y */
vec[2]= data[0]*p0->vec[2] + data[1]*p1->vec[2] + data[2]*p2->vec[2] + data[3]*p3->vec[2] ; /* Z */
vec[3]= data[0]*p0->vec[3] + data[1]*p1->vec[3] + data[2]*p2->vec[3] + data[3]*p3->vec[3] ; /* Tilt, should not be needed since we have quat still used */
/* Need to verify the quat interpolation is correct - XXX */
vec[3]= data[0]*p0[3] + data[1]*p1[3] + data[2]*p2[3] + data[3]*p3[3] ;
if (quat) {
float totfac, q1[4], q2[4];
totfac= data[0]+data[1];
QuatInterpol(q1, p0->quat, p1->quat, data[0] / totfac);
NormalQuat(q1);
totfac= data[2]+data[3];
QuatInterpol(q2, p2->quat, p3->quat, data[2] / totfac);
NormalQuat(q2);
totfac = data[0]+data[1]+data[2]+data[3];
QuatInterpol(quat, q1, q2, (data[0]+data[1]) / totfac);
NormalQuat(quat);
}
if(radius)
*radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius;
return 1;
}
+51 -21
View File
@@ -204,15 +204,35 @@ AnimData *BKE_copy_animdata (AnimData *adt)
return dadt;
}
/* Make Local -------------------------------------------- */
static void make_local_strips(ListBase *strips)
{
NlaStrip *strip;
for(strip=strips->first; strip; strip=strip->next) {
if(strip->act) make_local_action(strip->act);
if(strip->remap && strip->remap->target) make_local_action(strip->remap->target);
make_local_strips(&strip->strips);
}
}
void BKE_animdata_make_local(AnimData *adt)
{
NlaTrack *nlt;
if(adt->action) make_local_action(adt->action);
if(adt->tmpact) make_local_action(adt->tmpact);
if(adt->remap && adt->remap->target) make_local_action(adt->remap->target);
for(nlt=adt->nla_tracks.first; nlt; nlt=nlt->next)
make_local_strips(&nlt->strips);
}
/* *********************************** */
/* KeyingSet API */
/* NOTES:
* It is very likely that there will be two copies of the api - one for internal use,
* and one 'operator' based wrapper of the internal API, which should allow for access
* from Python/scripts so that riggers can automate the creation of KeyingSets for their rigs.
*/
/* Finding Tools --------------------------- */
/* Find the first path that matches the given criteria */
@@ -245,7 +265,7 @@ KS_Path *BKE_keyingset_find_destination (KeyingSet *ks, ID *id, const char group
if ((ksp->rna_path==0) || strcmp(rna_path, ksp->rna_path))
eq_path= 0;
/* index */
/* index - need to compare whole-array setting too... */
if (ksp->array_index != array_index)
eq_index= 0;
@@ -276,7 +296,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho
if (name)
BLI_snprintf(ks->name, 64, name);
else
strcpy(ks->name, "Keying Set");
strcpy(ks->name, "KeyingSet");
ks->flag= flag;
ks->keyingflag= keyingflag;
@@ -285,7 +305,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho
BLI_addtail(list, ks);
/* make sure KeyingSet has a unique name (this helps with identification) */
BLI_uniquename(list, ks, "Keying Set", ' ', offsetof(KeyingSet, name), 64);
BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), 64);
/* return new KeyingSet for further editing */
return ks;
@@ -299,18 +319,25 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name
KS_Path *ksp;
/* sanity checks */
if ELEM(NULL, ks, rna_path)
if ELEM(NULL, ks, rna_path) {
printf("ERROR: no Keying Set and/or RNA Path to add destination with \n");
return;
}
/* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */
if (id == NULL) {
if (ks->flag & KEYINGSET_ABSOLUTE)
if (ks->flag & KEYINGSET_ABSOLUTE) {
printf("ERROR: No ID provided for absolute destination. \n");
return;
}
}
/* don't add if there is already a matching KS_Path in the KeyingSet */
if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode))
if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode)) {
if (G.f & G_DEBUG)
printf("ERROR: destination already exists in Keying Set \n");
return;
}
/* allocate a new KeyingSet Path */
ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
@@ -440,19 +467,19 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
switch (RNA_property_type(prop))
{
case PROP_BOOLEAN:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(&new_ptr, prop))
RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value);
else
RNA_property_boolean_set(&new_ptr, prop, (int)value);
break;
case PROP_INT:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(&new_ptr, prop))
RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value);
else
RNA_property_int_set(&new_ptr, prop, (int)value);
break;
case PROP_FLOAT:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(&new_ptr, prop))
RNA_property_float_set_index(&new_ptr, prop, array_index, value);
else
RNA_property_float_set(&new_ptr, prop, value);
@@ -1177,19 +1204,19 @@ void nladata_flush_channels (ListBase *channels)
switch (RNA_property_type(prop))
{
case PROP_BOOLEAN:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(ptr, prop))
RNA_property_boolean_set_index(ptr, prop, array_index, (int)value);
else
RNA_property_boolean_set(ptr, prop, (int)value);
break;
case PROP_INT:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(ptr, prop))
RNA_property_int_set_index(ptr, prop, array_index, (int)value);
else
RNA_property_int_set(ptr, prop, (int)value);
break;
case PROP_FLOAT:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(ptr, prop))
RNA_property_float_set_index(ptr, prop, array_index, value);
else
RNA_property_float_set(ptr, prop, value);
@@ -1263,7 +1290,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
dummy_strip.act= adt->action;
dummy_strip.remap= adt->remap;
// FIXME: what happens when we want to included F-Modifier access?
/* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */
calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1);
dummy_strip.start = dummy_strip.actstart;
dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend);
@@ -1423,7 +1450,6 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re
* 'local' (i.e. belonging in the nearest ID-block that setting is related to, not a
* standard 'root') block are overridden by a larger 'user'
*/
// FIXME?: we currently go over entire 'main' database...
void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
{
ID *id;
@@ -1447,8 +1473,11 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
* when there are no actions, don't go over database and loop over heaps of datablocks,
* which should ultimately be empty, since it is not possible for now to have any animation
* without some actions, and drivers wouldn't get affected by any state changes
*
* however, if there are some curves, we will need to make sure that their 'ctime' property gets
* set correctly, so this optimisation must be skipped in that case...
*/
if (main->action.first == NULL) {
if ((main->action.first == NULL) && (main->curve.first == NULL)) {
if (G.f & G_DEBUG)
printf("\tNo Actions, so no animation needs to be evaluated...\n");
@@ -1482,6 +1511,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime)
* value of the curve gets set in case there's no animation for that
* - it needs to be set before animation is evaluated just so that
* animation can successfully override...
* - it shouldn't get set when calculating drivers...
*/
for (id= main->curve.first; id; id= id->next) {
AnimData *adt= BKE_animdata_from_id(id);
+12 -9
View File
@@ -130,7 +130,6 @@ void free_bones (bArmature *arm)
void free_armature(bArmature *arm)
{
if (arm) {
/* unlink_armature(arm);*/
free_bones(arm);
/* free editmode data */
@@ -667,10 +666,10 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
if(bone->segments > MAX_BBONE_SUBDIV)
bone->segments= MAX_BBONE_SUBDIV;
forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0], MAX_BBONE_SUBDIV, 4);
forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1, MAX_BBONE_SUBDIV, 4);
forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2, MAX_BBONE_SUBDIV, 4);
forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3, MAX_BBONE_SUBDIV, 4);
forward_diff_bezier(0.0, h1[0], h2[0], 0.0, data[0], MAX_BBONE_SUBDIV, 4*sizeof(float));
forward_diff_bezier(0.0, h1[1], length + h2[1], length, data[0]+1, MAX_BBONE_SUBDIV, 4*sizeof(float));
forward_diff_bezier(0.0, h1[2], h2[2], 0.0, data[0]+2, MAX_BBONE_SUBDIV, 4*sizeof(float));
forward_diff_bezier(roll1, roll1 + 0.390464f*(roll2-roll1), roll2 - 0.390464f*(roll2-roll1), roll2, data[0]+3, MAX_BBONE_SUBDIV, 4*sizeof(float));
equalize_bezier(data[0], bone->segments); // note: does stride 4!
@@ -1987,10 +1986,14 @@ void chan_calc_mat(bPoseChannel *chan)
/* get scaling matrix */
SizeToMat3(chan->size, smat);
/* rotations may either be quats or eulers (no rotation modes for now...) */
if (chan->rotmode) {
/* euler rotations (will cause gimble lock... no rotation order to solve that yet) */
EulToMat3(chan->eul, rmat);
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (chan->rotmode > 0) {
/* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
EulOToMat3(chan->eul, chan->rotmode, rmat);
}
else if (chan->rotmode == PCHAN_ROT_AXISANGLE) {
/* axis-angle - stored in quaternion data, but not really that great for 3D-changing orientations */
AxisAngleToMat3(&chan->quat[1], chan->quat[0], rmat);
}
else {
/* quats are normalised before use to eliminate scaling issues */
+1 -2
View File
@@ -626,8 +626,7 @@ void BKE_write_undo(bContext *C, char *name)
}
}
/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation
* Note, ALWAYS call sound_initialize_sounds after BKE_undo_step() */
/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
void BKE_undo_step(bContext *C, int step)
{
+112 -90
View File
@@ -74,14 +74,15 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
BoidSettings *boids = bbd->part->boids;
ParticleEffectorCache *ec;
Object *priority_ob = NULL;
BoidParticle *bpa = pa->boid;
float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f};
float mul = (rule->type == eBoidRuleType_Avoid ? 1.0 : -1.0);
float priority = 0.0f, len;
float priority = 0.0f, len = 0.0f;
int ret = 0;
/* first find out goal/predator with highest priority */
/* if rule->ob specified use it */
if(gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != pa->stick_ob)) {
if(gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != bpa->ground)) {
PartDeflect *pd = gabr->ob->pd;
float vec_to_part[3];
@@ -104,7 +105,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
PartDeflect *pd = eob->pd;
/* skip current object */
if(rule->type == eBoidRuleType_Goal && eob == pa->stick_ob)
if(rule->type == eBoidRuleType_Goal && eob == bpa->ground)
continue;
if(pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f) {
@@ -169,10 +170,10 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val,
VECCOPY(bbd->goal_nor, nor);
}
}
else if(rule->type == eBoidRuleType_Avoid && pa->boid->mode == eBoidMode_Climbing &&
else if(rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing &&
priority > 2.0f * gabr->fear_factor) {
/* detach from surface and try to fly away from danger */
VECCOPY(vec_to_part, pa->r_ve);
VECCOPY(vec_to_part, bpa->gravity);
VecMulf(vec_to_part, -1.0f);
}
@@ -205,6 +206,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
KDTreeNearest *ptn = NULL;
ParticleEffectorCache *ec;
ParticleTarget *pt;
BoidParticle *bpa = pa->boid;
float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f};
float co1[3], vel1[3], co2[3], vel2[3];
float len, t, inp, t_min = 2.0f;
@@ -231,7 +233,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
Object *eob = ec->ob;
/* don't check with current ground object */
if(eob == pa->stick_ob)
if(eob == bpa->ground)
continue;
col.md = ( CollisionModifierData * ) ( modifiers_findByType ( eob, eModifierType_Collision ) );
@@ -558,18 +560,19 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va
}
static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
{
BoidParticle *bpa = pa->boid;
BoidRuleAverageSpeed *asbr = (BoidRuleAverageSpeed*)rule;
float vec[3] = {0.0f, 0.0f, 0.0f};
if(asbr->wander > 0.0f) {
/* abuse pa->r_ave for wandering */
pa->r_ave[0] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
pa->r_ave[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
pa->r_ave[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
bpa->wander[0] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
bpa->wander[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand());
Normalize(pa->r_ave);
Normalize(bpa->wander);
VECCOPY(vec, pa->r_ave);
VECCOPY(vec, bpa->wander);
QuatMulVecf(pa->prev_state.rot, vec);
@@ -614,7 +617,8 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
KDTreeNearest *ptn = NULL;
ParticleTarget *pt;
ParticleData *epars;
ParticleData *enemy_pa;
ParticleData *enemy_pa = NULL;
BoidParticle *bpa;
/* friends & enemies */
float closest_enemy[3] = {0.0f,0.0f,0.0f};
float closest_dist = fbr->distance + 1.0f;
@@ -624,8 +628,10 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
/* calculate own group strength */
int neighbors = BLI_kdtree_range_search(bbd->psys->tree, fbr->distance, pa->prev_state.co, NULL, &ptn);
for(n=0; n<neighbors; n++)
health += bbd->psys->particles[ptn[n].index].boid->health;
for(n=0; n<neighbors; n++) {
bpa = bbd->psys->particles[ptn[n].index].boid;
health += bpa->data.health;
}
f_strength += bbd->part->boids->strength * health;
@@ -642,7 +648,8 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
health = 0.0f;
for(n=0; n<neighbors; n++) {
health += epars[ptn[n].index].boid->health;
bpa = epars[ptn[n].index].boid;
health += bpa->data.health;
if(n==0 && pt->mode==PTARGET_MODE_ENEMY && ptn[n].dist < closest_dist) {
VECCOPY(closest_enemy, ptn[n].co);
@@ -674,7 +681,8 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
/* must face enemy to fight */
if(Inpf(pa->prev_state.ave, enemy_dir)>0.5f) {
enemy_pa->boid->health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy);
bpa = enemy_pa->boid;
bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy);
}
}
else {
@@ -683,7 +691,8 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti
}
/* check if boid doesn't want to fight */
if(pa->boid->health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
bpa = pa->boid;
if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) {
/* decide to flee */
if(closest_dist < fbr->flee_distance * fbr->distance) {
VecMulf(bbd->wanted_co, -1.0f);
@@ -721,18 +730,20 @@ static boid_rule_cb boid_rules[] = {
static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *pa)
{
if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
val->max_speed = boids->land_max_speed * pa->boid->health/boids->health;
BoidParticle *bpa = pa->boid;
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
val->max_speed = boids->land_max_speed * bpa->data.health/boids->health;
val->max_acc = boids->land_max_acc * val->max_speed;
val->max_ave = boids->land_max_ave * M_PI * pa->boid->health/boids->health;
val->max_ave = boids->land_max_ave * M_PI * bpa->data.health/boids->health;
val->min_speed = 0.0f; /* no minimum speed on land */
val->personal_space = boids->land_personal_space;
val->jump_speed = boids->land_jump_speed * pa->boid->health/boids->health;
val->jump_speed = boids->land_jump_speed * bpa->data.health/boids->health;
}
else {
val->max_speed = boids->air_max_speed * pa->boid->health/boids->health;
val->max_speed = boids->air_max_speed * bpa->data.health/boids->health;
val->max_acc = boids->air_max_acc * val->max_speed;
val->max_ave = boids->air_max_ave * M_PI * pa->boid->health/boids->health;
val->max_ave = boids->air_max_ave * M_PI * bpa->data.health/boids->health;
val->min_speed = boids->air_min_speed * boids->air_max_speed;
val->personal_space = boids->air_personal_space;
val->jump_speed = 0.0f; /* no jumping in air */
@@ -740,11 +751,13 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *
}
static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *ground_co, float *ground_nor)
{
if(pa->boid->mode == eBoidMode_Climbing) {
BoidParticle *bpa = pa->boid;
if(bpa->data.mode == eBoidMode_Climbing) {
SurfaceModifierData *surmd = NULL;
float x[3], v[3];
surmd = (SurfaceModifierData *)modifiers_findByType ( pa->stick_ob, eModifierType_Surface );
surmd = (SurfaceModifierData *)modifiers_findByType ( bpa->ground, eModifierType_Surface );
/* take surface velocity into account */
effector_find_co(bbd->scene, pa->state.co, surmd, NULL, NULL, x, NULL, v, NULL);
@@ -753,7 +766,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
/* get actual position on surface */
effector_find_co(bbd->scene, x, surmd, NULL, NULL, ground_co, ground_nor, NULL, NULL);
return pa->stick_ob;
return bpa->ground;
}
else {
float zvec[3] = {0.0f, 0.0f, 2000.0f};
@@ -803,13 +816,15 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro
}
static int boid_rule_applies(ParticleData *pa, BoidSettings *boids, BoidRule *rule)
{
BoidParticle *bpa = pa->boid;
if(rule==NULL)
return 0;
if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND)
return 1;
if(pa->boid->mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
if(bpa->data.mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR)
return 1;
return 0;
@@ -835,12 +850,13 @@ void boids_precalc_rules(ParticleSettings *part, float cfra)
}
static void boid_climb(BoidSettings *boids, ParticleData *pa, float *surface_co, float *surface_nor)
{
BoidParticle *bpa = pa->boid;
float nor[3], vel[3];
VECCOPY(nor, surface_nor);
/* gather apparent gravity to r_ve */
VECADDFAC(pa->r_ve, pa->r_ve, surface_nor, -1.0);
Normalize(pa->r_ve);
/* gather apparent gravity */
VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0);
Normalize(bpa->gravity);
/* raise boid it's size from surface */
VecMulf(nor, pa->size * boids->height);
@@ -877,16 +893,17 @@ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val,
}
static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa) {
BoidState *state = boids->states.first;
BoidParticle *bpa = pa->boid;
for(; state; state=state->next) {
if(state->id==pa->boid->state_id)
if(state->id==bpa->data.state_id)
return state;
}
/* for some reason particle isn't at a valid state */
state = boids->states.first;
if(state)
pa->boid->state_id = state->id;
bpa->data.state_id = state->id;
return state;
}
@@ -902,9 +919,11 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
BoidSettings *boids = bbd->part->boids;
BoidValues val;
BoidState *state = get_boid_state(boids, pa);
BoidParticle *bpa = pa->boid;
int rand;
//BoidCondition *cond;
if(pa->boid->health <= 0.0f) {
if(bpa->data.health <= 0.0f) {
pa->alive = PARS_DYING;
return;
}
@@ -922,7 +941,9 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f;
/* create random seed for every particle & frame */
BLI_srandom(bbd->psys->seed + p + (int)bbd->cfra + (int)(1000*pa->r_rot[0]));
BLI_srandom(bbd->psys->seed + p);
rand = BLI_rand();
BLI_srandom((int)bbd->cfra + rand);
set_boid_values(&val, bbd->part->boids, pa);
@@ -939,7 +960,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
case eBoidRulesetType_Random:
{
/* use random rule for each particle (allways same for same particle though) */
rule = BLI_findlink(&state->rules, (int)(1000.0f * pa->r_rot[1]) % BLI_countlist(&state->rules));
rule = BLI_findlink(&state->rules, rand % BLI_countlist(&state->rules));
apply_boid_rule(bbd, rule, &val, pa, -1.0);
}
@@ -969,7 +990,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
}
/* decide on jumping & liftoff */
if(pa->boid->mode == eBoidMode_OnLand) {
if(bpa->data.mode == eBoidMode_OnLand) {
/* fuzziness makes boids capable of misjudgement */
float mul = 1.0 + state->rule_fuzziness;
@@ -983,7 +1004,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
Normalize2(cvel);
if(Inp2f(cvel, dir) > 0.95 / mul)
pa->boid->mode = eBoidMode_Liftoff;
bpa->data.mode = eBoidMode_Liftoff;
}
else if(val.jump_speed > 0.0f) {
float jump_v[3];
@@ -1036,7 +1057,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
if(jump) {
VECCOPY(pa->prev_state.vel, jump_v);
pa->boid->mode = eBoidMode_Falling;
bpa->data.mode = eBoidMode_Falling;
}
}
}
@@ -1045,6 +1066,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
void boid_body(BoidBrainData *bbd, ParticleData *pa)
{
BoidSettings *boids = bbd->part->boids;
BoidParticle *bpa = pa->boid;
BoidValues val;
float acc[3] = {0.0f, 0.0f, 0.0f}, tan_acc[3], nor_acc[3];
float dvec[3], bvec[3];
@@ -1066,10 +1088,10 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
pa_mass*=pa->size;
/* if boids can't fly they fall to the ground */
if((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && bbd->part->acc[2] != 0.0f)
pa->boid->mode = eBoidMode_Falling;
if((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && bbd->part->acc[2] != 0.0f)
bpa->data.mode = eBoidMode_Falling;
if(pa->boid->mode == eBoidMode_Falling) {
if(bpa->data.mode == eBoidMode_Falling) {
/* Falling boids are only effected by gravity. */
acc[2] = bbd->part->acc[2];
}
@@ -1079,14 +1101,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
float level = landing_level + 1.0f;
float new_vel[3];
if(pa->boid->mode == eBoidMode_Liftoff) {
pa->boid->mode = eBoidMode_InAir;
pa->stick_ob = boid_find_ground(bbd, pa, ground_co, ground_nor);
if(bpa->data.mode == eBoidMode_Liftoff) {
bpa->data.mode = eBoidMode_InAir;
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
}
else if(pa->boid->mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) {
else if(bpa->data.mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) {
/* auto-leveling & landing if close to ground */
pa->stick_ob = boid_find_ground(bbd, pa, ground_co, ground_nor);
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* level = how many particle sizes above ground */
level = (pa->prev_state.co[2] - ground_co[2])/(2.0f * pa->size) - 0.5;
@@ -1097,7 +1119,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
if(level < 1.0f) {
bbd->wanted_co[0] = bbd->wanted_co[1] = bbd->wanted_co[2] = 0.0f;
bbd->wanted_speed = 0.0f;
pa->boid->mode = eBoidMode_Falling;
bpa->data.mode = eBoidMode_Falling;
}
else if(level < landing_level) {
bbd->wanted_speed *= (level - 1.0f)/landing_level;
@@ -1188,7 +1210,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* account for effectors */
do_effectors(p, pa, &pa->state, bbd->scene, bbd->ob, bbd->psys, pa->state.co, force, tvel, bbd->dfra, bbd->cfra);
if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) {
float length = Normalize(force);
length = MAX2(0.0f, length - boids->land_stick_force);
@@ -1199,8 +1221,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
VecAddf(acc, acc, force);
/* store smoothed acceleration for nice banking etc. */
VECADDFAC(pa->boid->acc, pa->boid->acc, acc, dtime);
VecMulf(pa->boid->acc, 1.0f / (1.0f + dtime));
VECADDFAC(bpa->data.acc, bpa->data.acc, acc, dtime);
VecMulf(bpa->data.acc, 1.0f / (1.0f + dtime));
/* integrate new location & velocity */
@@ -1218,32 +1240,32 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime);
if(pa->boid->mode != eBoidMode_InAir)
pa->stick_ob = boid_find_ground(bbd, pa, ground_co, ground_nor);
if(bpa->data.mode != eBoidMode_InAir)
bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor);
/* change modes, constrain movement & keep track of down vector */
switch(pa->boid->mode) {
switch(bpa->data.mode) {
case eBoidMode_InAir:
{
float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f};
/* don't take forward acceleration into account (better banking) */
if(Inpf(pa->boid->acc, pa->state.vel) > 0.0f) {
Projf(dvec, pa->boid->acc, pa->state.vel);
VecSubf(dvec, pa->boid->acc, dvec);
if(Inpf(bpa->data.acc, pa->state.vel) > 0.0f) {
Projf(dvec, bpa->data.acc, pa->state.vel);
VecSubf(dvec, bpa->data.acc, dvec);
}
else {
VECCOPY(dvec, pa->boid->acc);
VECCOPY(dvec, bpa->data.acc);
}
/* gather apparent gravity to r_ve */
VECADDFAC(pa->r_ve, grav, dvec, -boids->banking);
Normalize(pa->r_ve);
/* gather apparent gravity */
VECADDFAC(bpa->gravity, grav, dvec, -boids->banking);
Normalize(bpa->gravity);
/* stick boid on goal when close enough */
if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
pa->boid->mode = eBoidMode_Climbing;
pa->stick_ob = bbd->goal_ob;
bpa->data.mode = eBoidMode_Climbing;
bpa->ground = bbd->goal_ob;
boid_find_ground(bbd, pa, ground_co, ground_nor);
boid_climb(boids, pa, ground_co, ground_nor);
}
@@ -1251,7 +1273,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
else if(boids->options & BOID_ALLOW_LAND && pa->state.co[2] <= ground_co[2] + pa->size * boids->height) {
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
pa->state.vel[2] = 0.0f;
pa->boid->mode = eBoidMode_OnLand;
bpa->data.mode = eBoidMode_OnLand;
}
break;
}
@@ -1259,15 +1281,15 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
{
float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f};
/* gather apparent gravity to r_ve */
VECADDFAC(pa->r_ve, pa->r_ve, grav, dtime);
Normalize(pa->r_ve);
/* gather apparent gravity */
VECADDFAC(bpa->gravity, bpa->gravity, grav, dtime);
Normalize(bpa->gravity);
if(boids->options & BOID_ALLOW_LAND) {
/* stick boid on goal when close enough */
if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
pa->boid->mode = eBoidMode_Climbing;
pa->stick_ob = bbd->goal_ob;
bpa->data.mode = eBoidMode_Climbing;
bpa->ground = bbd->goal_ob;
boid_find_ground(bbd, pa, ground_co, ground_nor);
boid_climb(boids, pa, ground_co, ground_nor);
}
@@ -1275,14 +1297,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
else if(pa->state.co[2] <= ground_co[2] + 1.01 * pa->size * boids->height){
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
pa->state.vel[2] = 0.0f;
pa->boid->mode = eBoidMode_OnLand;
bpa->data.mode = eBoidMode_OnLand;
}
/* if we're falling, can fly and want to go upwards lets fly */
else if(boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f)
pa->boid->mode = eBoidMode_InAir;
bpa->data.mode = eBoidMode_InAir;
}
else
pa->boid->mode = eBoidMode_InAir;
bpa->data.mode = eBoidMode_InAir;
break;
}
case eBoidMode_Climbing:
@@ -1308,14 +1330,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
{
/* stick boid on goal when close enough */
if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) {
pa->boid->mode = eBoidMode_Climbing;
pa->stick_ob = bbd->goal_ob;
bpa->data.mode = eBoidMode_Climbing;
bpa->ground = bbd->goal_ob;
boid_find_ground(bbd, pa, ground_co, ground_nor);
boid_climb(boids, pa, ground_co, ground_nor);
}
/* ground is too far away so boid falls */
else if(pa->state.co[2]-ground_co[2] > 1.1 * pa->size * boids->height)
pa->boid->mode = eBoidMode_Falling;
bpa->data.mode = eBoidMode_Falling;
else {
/* constrain to surface */
pa->state.co[2] = ground_co[2] + pa->size * boids->height;
@@ -1329,17 +1351,17 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
VECCOPY(grav, ground_nor);
VecMulf(grav, -1.0f);
Projf(dvec, pa->boid->acc, pa->state.vel);
VecSubf(dvec, pa->boid->acc, dvec);
Projf(dvec, bpa->data.acc, pa->state.vel);
VecSubf(dvec, bpa->data.acc, dvec);
/* gather apparent gravity to r_ve */
VECADDFAC(pa->r_ve, grav, dvec, -boids->banking);
Normalize(pa->r_ve);
/* gather apparent gravity */
VECADDFAC(bpa->gravity, grav, dvec, -boids->banking);
Normalize(bpa->gravity);
}
else {
/* gather negative surface normal to r_ve */
VECADDFAC(pa->r_ve, pa->r_ve, ground_nor, -1.0f);
Normalize(pa->r_ve);
/* gather negative surface normal */
VECADDFAC(bpa->gravity, bpa->gravity, ground_nor, -1.0f);
Normalize(bpa->gravity);
}
break;
}
@@ -1347,29 +1369,29 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
/* save direction to state.ave unless the boid is falling */
/* (boids can't effect their direction when falling) */
if(pa->boid->mode!=eBoidMode_Falling && VecLength(pa->state.vel) > 0.1*pa->size) {
if(bpa->data.mode!=eBoidMode_Falling && VecLength(pa->state.vel) > 0.1*pa->size) {
VECCOPY(pa->state.ave, pa->state.vel);
Normalize(pa->state.ave);
}
/* apply damping */
if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing))
if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing))
VecMulf(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac);
/* calculate rotation matrix based on forward & down vectors */
if(pa->boid->mode == eBoidMode_InAir) {
if(bpa->data.mode == eBoidMode_InAir) {
VECCOPY(mat[0], pa->state.ave);
Projf(dvec, pa->r_ve, pa->state.ave);
VecSubf(mat[2], pa->r_ve, dvec);
Projf(dvec, bpa->gravity, pa->state.ave);
VecSubf(mat[2], bpa->gravity, dvec);
Normalize(mat[2]);
}
else {
Projf(dvec, pa->state.ave, pa->r_ve);
Projf(dvec, pa->state.ave, bpa->gravity);
VecSubf(mat[0], pa->state.ave, dvec);
Normalize(mat[0]);
VECCOPY(mat[2], pa->r_ve);
VECCOPY(mat[2], bpa->gravity);
}
VecMulf(mat[2], -1.0f);
Crossf(mat[1], mat[2], mat[0]);
@@ -589,7 +589,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type)
MEM_freeN(mat);
/* update dag */
DAG_object_flush_update(scene, ob_new, OB_RECALC_DATA);
DAG_id_flush_update(&ob_new->id, OB_RECALC_DATA);
return 1;
}
+2 -17
View File
@@ -75,6 +75,8 @@ Brush *add_brush(const char *name)
brush->alpha= 0.2f;
brush->size= 25;
brush->spacing= 10.0f;
brush->smooth_stroke_radius= 75;
brush->smooth_stroke_factor= 0.9;
brush->rate= 0.1f;
brush->innerradius= 0.5f;
brush->clone.alpha= 0.5;
@@ -407,23 +409,6 @@ float brush_sample_falloff(Brush *brush, float dist)
return 0.0f;
}
float brush_sample_falloff_noalpha(Brush *brush, float dist)
{
float outer, inner;
outer = brush->size >> 1;
inner = outer*brush->innerradius;
if (dist <= inner) {
return 1.0f;
}
else if ((dist < outer) && (inner < outer)) {
return 1.0f - sqrt((dist - inner)/(outer - inner));
}
else
return 0.0f;
}
void brush_sample_tex(Brush *brush, float *xy, float *rgba)
{
MTex *mtex= brush->mtex[brush->texact];
@@ -1288,6 +1288,7 @@ typedef struct MultiresDM {
CDDerivedMesh cddm;
MultiresModifierData *mmd;
int local_mmd;
int lvl, totlvl;
float (*orco)[3];
@@ -1297,7 +1298,7 @@ typedef struct MultiresDM {
IndexNode *vert_face_map_mem, *vert_edge_map_mem;
int *face_offsets;
Mesh *me;
Object *ob;
int modified;
void (*update)(DerivedMesh*);
@@ -1309,14 +1310,19 @@ static void MultiresDM_release(DerivedMesh *dm)
int mvert_layer;
/* Before freeing, need to update the displacement map */
if(dm->needsFree && mrdm->modified)
mrdm->update(dm);
if(dm->needsFree && mrdm->modified) {
/* Check that mmd still exists */
if(!mrdm->local_mmd && BLI_findindex(&mrdm->ob->modifiers, mrdm->mmd) < 0)
mrdm->mmd = NULL;
if(mrdm->mmd)
mrdm->update(dm);
}
/* If the MVert data is being used as the sculpt undo store, don't free it */
mvert_layer = CustomData_get_layer_index(&dm->vertData, CD_MVERT);
if(mvert_layer != -1) {
CustomDataLayer *cd = &dm->vertData.layers[mvert_layer];
if(cd->data == mrdm->mmd->undo_verts)
if(mrdm->mmd && cd->data == mrdm->mmd->undo_verts)
cd->flag |= CD_FLAG_NOFREE;
}
@@ -1348,7 +1354,8 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts
dm = &mrdm->cddm.dm;
mrdm->mmd = ms->mmd;
mrdm->me = ms->me;
mrdm->ob = ms->ob;
mrdm->local_mmd = ms->local_mmd;
if(dm) {
MDisps *disps;
@@ -1391,7 +1398,12 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts
Mesh *MultiresDM_get_mesh(DerivedMesh *dm)
{
return ((MultiresDM*)dm)->me;
return get_mesh(((MultiresDM*)dm)->ob);
}
Object *MultiresDM_get_object(DerivedMesh *dm)
{
return ((MultiresDM*)dm)->ob;
}
void *MultiresDM_get_orco(DerivedMesh *dm)
@@ -1428,10 +1440,11 @@ void MultiresDM_set_update(DerivedMesh *dm, void (*update)(DerivedMesh*))
ListBase *MultiresDM_get_vert_face_map(DerivedMesh *dm)
{
MultiresDM *mrdm = (MultiresDM*)dm;
Mesh *me = mrdm->ob->data;
if(!mrdm->vert_face_map)
create_vert_face_map(&mrdm->vert_face_map, &mrdm->vert_face_map_mem, mrdm->me->mface,
mrdm->me->totvert, mrdm->me->totface);
create_vert_face_map(&mrdm->vert_face_map, &mrdm->vert_face_map_mem, me->mface,
me->totvert, me->totface);
return mrdm->vert_face_map;
}
@@ -1439,10 +1452,11 @@ ListBase *MultiresDM_get_vert_face_map(DerivedMesh *dm)
ListBase *MultiresDM_get_vert_edge_map(DerivedMesh *dm)
{
MultiresDM *mrdm = (MultiresDM*)dm;
Mesh *me = mrdm->ob->data;
if(!mrdm->vert_edge_map)
create_vert_edge_map(&mrdm->vert_edge_map, &mrdm->vert_edge_map_mem, mrdm->me->medge,
mrdm->me->totvert, mrdm->me->totedge);
create_vert_edge_map(&mrdm->vert_edge_map, &mrdm->vert_edge_map_mem, me->medge,
me->totvert, me->totedge);
return mrdm->vert_edge_map;
}
@@ -1450,6 +1464,7 @@ ListBase *MultiresDM_get_vert_edge_map(DerivedMesh *dm)
int *MultiresDM_get_face_offsets(DerivedMesh *dm)
{
MultiresDM *mrdm = (MultiresDM*)dm;
Mesh *me = mrdm->ob->data;
int i, accum = 0;
if(!mrdm->face_offsets) {
@@ -1457,11 +1472,11 @@ int *MultiresDM_get_face_offsets(DerivedMesh *dm)
int area = len * len;
int t = 1 + len * 3 + area * 3, q = t + len + area;
mrdm->face_offsets = MEM_callocN(sizeof(int) * mrdm->me->totface, "mrdm face offsets");
for(i = 0; i < mrdm->me->totface; ++i) {
mrdm->face_offsets = MEM_callocN(sizeof(int) * me->totface, "mrdm face offsets");
for(i = 0; i < me->totface; ++i) {
mrdm->face_offsets[i] = accum;
accum += (mrdm->me->mface[i].v4 ? q : t);
accum += (me->mface[i].v4 ? q : t);
}
}
+32 -36
View File
@@ -347,7 +347,7 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
// don't do anything as long as we're in editmode!
if(pid.cache->flag & PTCACHE_BAKE_EDIT_ACTIVE)
if(pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT)
return;
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
@@ -496,23 +496,32 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
if(!do_init_cloth(ob, clmd, result, framenr))
return result;
if(framenr == startframe) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
do_init_cloth(ob, clmd, result, framenr);
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->flag &= ~PTCACHE_REDO_NEEDED;
return result;
}
/* try to read from cache */
cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec);
if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe= framenr;
implicit_set_positions(clmd);
cloth_to_object (ob, clmd, result);
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_write_cache(&pid, framenr);
return result;
}
else if(cache_result==PTCACHE_READ_OLD) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE);
implicit_set_positions(clmd);
cache->flag |= PTCACHE_SIMULATION_VALID;
}
else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) {
@@ -523,38 +532,25 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob,
return result;
}
if(framenr == startframe) {
if(cache->flag & PTCACHE_REDO_NEEDED) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
do_init_cloth(ob, clmd, result, framenr);
}
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe= framenr;
/* if on second frame, write cache for first frame */
if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
BKE_ptcache_write_cache(&pid, startframe);
/* don't write cache on first frame, but on second frame write
* cache for frame 1 and 2 */
clmd->sim_parms->timescale *= framenr - cache->simframe;
/* do simulation */
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe= framenr;
if(!do_step_cloth(ob, clmd, result, framenr)) {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
cache->last_exact= 0;
}
else {
/* if on second frame, write cache for first frame */
if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
BKE_ptcache_write_cache(&pid, startframe);
else
BKE_ptcache_write_cache(&pid, framenr);
clmd->sim_parms->timescale *= framenr - cache->simframe;
/* do simulation */
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe= framenr;
if(!do_step_cloth(ob, clmd, result, framenr)) {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
cache->last_exact= 0;
}
else
BKE_ptcache_write_cache(&pid, framenr);
cloth_to_object (ob, clmd, result);
}
cloth_to_object (ob, clmd, result);
return result;
}
+2 -2
View File
@@ -591,7 +591,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap
ClothModifierData *clmd = ( ClothModifierData * ) md1;
CollisionModifierData *collmd = ( CollisionModifierData * ) md2;
MFace *face1=NULL, *face2 = NULL;
#ifdef WITH_BULLET
#ifdef USE_BULLET
ClothVertex *verts1 = clmd->clothObject->verts;
#endif
double distance = 0;
@@ -669,7 +669,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap
break;
}
#ifdef WITH_BULLET
#ifdef USE_BULLET
// calc distance + normal
distance = plNearestPoints (
verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa,collpair->pb,collpair->vector );
@@ -502,8 +502,8 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr)
for(a=0; a<cuma->totpoint-1; a++, fp += 2*CM_RESOL) {
correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]);
forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2);
forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2);
forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float));
forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float));
}
/* store first and last handle for extrapolation, unit length */
+69 -35
View File
@@ -121,6 +121,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
if (ob) {
cob->ob = ob;
cob->type = datatype;
cob->rotOrder = EULER_ORDER_DEFAULT; // TODO: when objects have rotation order too, use that
Mat4CpyMat4(cob->matrix, ob->obmat);
}
else
@@ -137,6 +138,15 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata,
cob->pchan = (bPoseChannel *)subdata;
cob->type = datatype;
if (cob->pchan->rotmode > 0) {
/* should be some type of Euler order */
cob->rotOrder= cob->pchan->rotmode;
}
else {
/* Quats, so eulers should just use default order */
cob->rotOrder= EULER_ORDER_DEFAULT;
}
/* matrix in world-space */
Mat4MulMat4(cob->matrix, cob->pchan->pose_mat, ob->obmat);
}
@@ -664,6 +674,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
* really just to help this code easier to read)
*/
// TODO: cope with getting rotation order...
#define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \
{ \
ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
@@ -687,6 +698,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain
* (Hopefully all compilers will be happy with the lines with just a space on them. Those are
* really just to help this code easier to read)
*/
// TODO: cope with getting rotation order...
#define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \
{ \
ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \
@@ -795,11 +807,11 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
/* extract components of both matrices */
VECCOPY(loc, ct->matrix[3]);
Mat4ToEul(ct->matrix, eul);
Mat4ToEulO(ct->matrix, eul, ct->rotOrder);
Mat4ToSize(ct->matrix, size);
VECCOPY(loco, invmat[3]);
Mat4ToEul(invmat, eulo);
Mat4ToEulO(invmat, eulo, cob->rotOrder);
Mat4ToSize(invmat, sizo);
/* disable channels not enabled */
@@ -814,8 +826,8 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f;
/* make new target mat and offset mat */
LocEulSizeToMat4(ct->matrix, loc, eul, size);
LocEulSizeToMat4(invmat, loco, eulo, sizo);
LocEulOSizeToMat4(ct->matrix, loc, eul, size, ct->rotOrder);
LocEulOSizeToMat4(invmat, loco, eulo, sizo, cob->rotOrder);
/* multiply target (parent matrix) by offset (parent inverse) to get
* the effect of the parent that will be exherted on the owner
@@ -1150,7 +1162,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
if (VALID_CONS_TARGET(ct)) {
Curve *cu= ct->tar->data;
float q[4], vec[4], dir[3], quat[4], x1;
float q[4], vec[4], dir[3], quat[4], radius, x1;
float totmat[4][4];
float curvetime;
@@ -1162,21 +1174,30 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
*/
/* only happens on reload file, but violates depsgraph still... fix! */
if (cu->path==NULL || cu->path->data==NULL)
if (cu->path==NULL || cu->path->data==NULL)
makeDispListCurveTypes(cob->scene, ct->tar, 0);
if (cu->path && cu->path->data) {
curvetime= bsystem_time(cob->scene, ct->tar, (float)ctime, 0.0) - data->offset;
#if 0 // XXX old animation system
if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) {
curvetime /= cu->pathlen;
if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
/* animated position along curve depending on time */
curvetime= bsystem_time(cob->scene, ct->tar, ctime, 0.0) - data->offset;
/* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
* but this will only work if it actually is animated...
*
* we firstly calculate the modulus of cu->ctime/cu->pathlen to clamp ctime within the 0.0 to 1.0 times pathlen
* range, then divide this (the modulus) by pathlen to get a value between 0.0 and 1.0
*/
curvetime= fmod(cu->ctime, cu->pathlen) / cu->pathlen;
CLAMP(curvetime, 0.0, 1.0);
}
#endif // XXX old animation system
else {
/* fixed position along curve */
curvetime= data->offset; // XXX might need a more sensible value
}
if ( where_on_path(ct->tar, curvetime, vec, dir) ) {
if (data->followflag) {
if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius) ) {
if (data->followflag & FOLLOWPATH_FOLLOW) {
vectoquat(dir, (short) data->trackflag, (short) data->upflag, quat);
Normalize(dir);
@@ -1189,6 +1210,14 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
QuatToMat4(quat, totmat);
}
if (data->followflag & FOLLOWPATH_RADIUS) {
float tmat[4][4], rmat[4][4];
Mat4Scale(tmat, radius);
Mat4MulMat4(rmat, totmat, tmat);
Mat4CpyMat4(totmat, rmat);
}
VECCOPY(totmat[3], vec);
Mat4MulSerie(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL);
@@ -1206,7 +1235,8 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
/* only evaluate if there is a target */
if (VALID_CONS_TARGET(ct)) {
float obmat[4][4];
float size[3], obsize[3];
float size[3];
bFollowPathConstraint *data= con->data;
/* get Object local transform (loc/rot/size) to determine transformation from path */
//object_to_mat4(ob, obmat);
@@ -1219,13 +1249,17 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
Mat4MulSerie(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL);
/* un-apply scaling caused by path */
Mat4ToSize(cob->matrix, obsize);
if (obsize[0])
VecMulf(cob->matrix[0], size[0] / obsize[0]);
if (obsize[1])
VecMulf(cob->matrix[1], size[1] / obsize[1]);
if (obsize[2])
VecMulf(cob->matrix[2], size[2] / obsize[2]);
if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */
float obsize[3];
Mat4ToSize(cob->matrix, obsize);
if (obsize[0])
VecMulf(cob->matrix[0], size[0] / obsize[0]);
if (obsize[1])
VecMulf(cob->matrix[1], size[1] / obsize[1]);
if (obsize[2])
VecMulf(cob->matrix[2], size[2] / obsize[2]);
}
}
}
@@ -1304,7 +1338,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t
VECCOPY(loc, cob->matrix[3]);
Mat4ToSize(cob->matrix, size);
Mat4ToEul(cob->matrix, eul);
Mat4ToEulO(cob->matrix, eul, cob->rotOrder);
/* eulers: radians to degrees! */
eul[0] = (float)(eul[0] / M_PI * 180);
@@ -1339,7 +1373,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t
eul[1] = (float)(eul[1] / 180 * M_PI);
eul[2] = (float)(eul[2] / 180 * M_PI);
LocEulSizeToMat4(cob->matrix, loc, eul, size);
LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder);
}
static bConstraintTypeInfo CTI_ROTLIMIT = {
@@ -1546,14 +1580,14 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
VECCOPY(loc, cob->matrix[3]);
Mat4ToSize(cob->matrix, size);
Mat4ToEul(ct->matrix, eul);
Mat4ToEul(cob->matrix, obeul);
Mat4ToEulO(ct->matrix, eul, ct->rotOrder);
Mat4ToEulO(cob->matrix, obeul, cob->rotOrder);
if ((data->flag & ROTLIKE_X)==0)
eul[0] = obeul[0];
else {
if (data->flag & ROTLIKE_OFFSET)
euler_rot(eul, obeul[0], 'x');
eulerO_rot(eul, obeul[0], 'x', cob->rotOrder);
if (data->flag & ROTLIKE_X_INVERT)
eul[0] *= -1;
@@ -1563,7 +1597,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
eul[1] = obeul[1];
else {
if (data->flag & ROTLIKE_OFFSET)
euler_rot(eul, obeul[1], 'y');
eulerO_rot(eul, obeul[1], 'y', cob->rotOrder);
if (data->flag & ROTLIKE_Y_INVERT)
eul[1] *= -1;
@@ -1573,14 +1607,14 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
eul[2] = obeul[2];
else {
if (data->flag & ROTLIKE_OFFSET)
euler_rot(eul, obeul[2], 'z');
eulerO_rot(eul, obeul[2], 'z', cob->rotOrder);
if (data->flag & ROTLIKE_Z_INVERT)
eul[2] *= -1;
}
compatible_eul(eul, obeul);
LocEulSizeToMat4(cob->matrix, loc, eul, size);
LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder);
}
}
@@ -2843,7 +2877,7 @@ static void clampto_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain
*/
/* only happens on reload file, but violates depsgraph still... fix! */
if (cu->path==NULL || cu->path->data==NULL)
if (cu->path==NULL || cu->path->data==NULL)
makeDispListCurveTypes(cob->scene, ct->tar, 0);
}
@@ -2954,7 +2988,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
}
/* 3. position on curve */
if (where_on_path(ct->tar, curvetime, vec, dir) ) {
if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL) ) {
Mat4One(totmat);
VECCOPY(totmat[3], vec);
@@ -3036,7 +3070,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
Mat4ToSize(ct->matrix, dvec);
break;
case 1: /* rotation (convert to degrees first) */
Mat4ToEul(ct->matrix, dvec);
Mat4ToEulO(ct->matrix, dvec, cob->rotOrder);
for (i=0; i<3; i++)
dvec[i] = (float)(dvec[i] / M_PI * 180);
break;
@@ -3047,7 +3081,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
/* extract components of owner's matrix */
VECCOPY(loc, cob->matrix[3]);
Mat4ToEul(cob->matrix, eul);
Mat4ToEulO(cob->matrix, eul, cob->rotOrder);
Mat4ToSize(cob->matrix, size);
/* determine where in range current transforms lie */
@@ -3102,7 +3136,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
}
/* apply to matrix */
LocEulSizeToMat4(cob->matrix, loc, eul, size);
LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder);
}
}
@@ -338,6 +338,13 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C)
return NULL;
}
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
{
if(C->wm.area && C->wm.area->spacetype==SPACE_USERPREF)
return C->wm.area->spacedata.first;
return NULL;
}
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
{
C->wm.manager= wm;
File diff suppressed because it is too large Load Diff
+66 -27
View File
@@ -61,6 +61,7 @@
#include "DNA_space_types.h"
#include "DNA_view2d_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_ghash.h"
@@ -2141,39 +2142,77 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay)
}
/* flag this object and all its relations to recalc */
/* if you need to do more objects, tag object yourself and
use DAG_scene_flush_update() in end */
void DAG_object_flush_update(Scene *sce, Object *ob, short flag)
void DAG_id_flush_update(ID *id, short flag)
{
if(ob==NULL || sce->theDag==NULL) return;
Main *bmain= G.main;
wmWindowManager *wm;
wmWindow *win;
Scene *sce;
Object *obt, *ob= NULL;
short idtype;
ob->recalc |= flag;
BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
/* all users of this ob->data should be checked */
/* BUT! displists for curves are still only on cu */
if(flag & OB_RECALC_DATA) {
if(ob->type!=OB_CURVE && ob->type!=OB_SURF) {
ID *id= ob->data;
if(id && id->us>1) {
/* except when there's a key and shapes are locked */
if(ob_get_key(ob) && (ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)));
else {
Object *obt;
for (obt=G.main->object.first; obt; obt= obt->id.next) {
if (obt != ob && obt->data==ob->data) {
obt->recalc |= OB_RECALC_DATA;
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
}
}
/* only one scene supported currently, making more scenes work
correctly requires changes beyond just the dependency graph */
if((wm= bmain->wm.first)) {
/* if we have a windowmanager, use sce from first window */
for(win=wm->windows.first; win; win=win->next) {
sce= (win->screen)? win->screen->scene: NULL;
if(sce)
break;
}
}
else
/* if not, use the first sce */
sce= bmain->scene.first;
if(!id || !sce || !sce->theDag)
return;
/* set flags & pointcache for object */
if(GS(id->name) == ID_OB) {
ob= (Object*)id;
ob->recalc |= flag;
BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH);
if(flag & OB_RECALC_DATA) {
/* all users of this ob->data should be checked */
id= ob->data;
/* no point in trying in this cases */
if(!id || id->us <= 1)
id= NULL;
/* curves and surfaces only need to mark one object, since
otherwise cu->displist would be computed multiple times */
else if(ob->type==OB_CURVE || ob->type==OB_SURF)
id= NULL;
/* also for locked shape keys we make an exception */
else if(ob_get_key(ob) && (ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)))
id= NULL;
}
}
/* set flags & pointcache for object data */
if(id) {
idtype= GS(id->name);
if(ELEM7(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR)) {
for(obt=bmain->object.first; obt; obt= obt->id.next) {
if(!(ob && obt == ob) && obt->data == id) {
obt->recalc |= OB_RECALC_DATA;
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
/* for these we only flag one object, otherwise cu->displist
would be computed multiple times */
if(obt->type==OB_CURVE || obt->type==OB_SURF)
break;
}
}
}
}
/* flush to other objects that depend on this one */
// XXX if(G.curscreen)
// DAG_scene_flush_update(sce, dag_screen_view3d_layers(), 0);
// else
+26 -22
View File
@@ -821,7 +821,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
DispList *dl;
BezTriple *bezt, *prevbezt;
BPoint *bp;
float *data, *v1, *v2;
float *data;
int a, len, resolu;
nu= nubase->first;
@@ -834,7 +834,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
resolu= nu->resolu;
if(!check_valid_nurb_u(nu));
else if((nu->type & 7)==CU_BEZIER) {
else if(nu->type == CU_BEZIER) {
/* count */
len= 0;
@@ -886,11 +886,15 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
data+= 3;
}
else {
v1= prevbezt->vec[1];
v2= bezt->vec[0];
forward_diff_bezier(v1[0], v1[3], v2[0], v2[3], data, resolu, 3);
forward_diff_bezier(v1[1], v1[4], v2[1], v2[4], data+1, resolu, 3);
forward_diff_bezier(v1[2], v1[5], v2[2], v2[5], data+2, resolu, 3);
int j;
for(j=0; j<3; j++) {
forward_diff_bezier( prevbezt->vec[1][j],
prevbezt->vec[2][j],
bezt->vec[0][j],
bezt->vec[1][j],
data+j, resolu, 3*sizeof(float));
}
data+= 3*resolu;
}
@@ -902,7 +906,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
bezt++;
}
}
else if((nu->type & 7)==CU_NURBS) {
else if(nu->type == CU_NURBS) {
len= (resolu*SEGMENTSU(nu));
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
@@ -917,9 +921,9 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
data= dl->verts;
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
makeNurbcurve(nu, data, NULL, NULL, resolu);
makeNurbcurve(nu, data, NULL, NULL, resolu, 3*sizeof(float));
}
else if((nu->type & 7)==CU_POLY) {
else if(nu->type == CU_POLY) {
len= nu->pntsu;
dl= MEM_callocN(sizeof(DispList), "makeDispListpoly");
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
@@ -1424,7 +1428,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRende
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
else dl->type= DL_SEGM;
makeNurbcurve(nu, data, NULL, NULL, nu->resolu);
makeNurbcurve(nu, data, NULL, NULL, nu->resolu, 3*sizeof(float));
}
else {
len= (nu->pntsu*nu->resolu) * (nu->pntsv*nu->resolv);
@@ -1539,9 +1543,9 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
bevp= (BevPoint *)(bl+1);
data= dl->verts;
while(a--) {
data[0]= bevp->x+widfac*bevp->sina;
data[1]= bevp->y+widfac*bevp->cosa;
data[2]= bevp->z;
data[0]= bevp->vec[0]+widfac*bevp->sina;
data[1]= bevp->vec[1]+widfac*bevp->cosa;
data[2]= bevp->vec[2];
bevp++;
data+=3;
}
@@ -1581,7 +1585,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
fac = calc_taper(scene, cu->taperobj, a, bl->nr);
}
if (bevp->f1) {
if (bevp->split_tag) {
dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F);
}
@@ -1595,16 +1599,16 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco)
vec[1]= fp1[2];
vec[2]= 0.0;
Mat3MulVecfl(bevp->mat, vec);
QuatMulVecf(bevp->quat, vec);
data[0]= bevp->x+ fac*vec[0];
data[1]= bevp->y+ fac*vec[1];
data[2]= bevp->z+ fac*vec[2];
data[0]= bevp->vec[0] + fac*vec[0];
data[1]= bevp->vec[1] + fac*vec[1];
data[2]= bevp->vec[2] + fac*vec[2];
}
else {
data[0]= bevp->x+ fac*(widfac+fp1[1])*bevp->sina;
data[1]= bevp->y+ fac*(widfac+fp1[1])*bevp->cosa;
data[2]= bevp->z+ fac*fp1[2];
data[0]= bevp->vec[0] + fac*(widfac+fp1[1])*bevp->sina;
data[1]= bevp->vec[1] + fac*(widfac+fp1[1])*bevp->cosa;
data[2]= bevp->vec[2] + fac*fp1[2];
}
}
}
+3 -3
View File
@@ -698,19 +698,19 @@ float driver_get_target_value (ChannelDriver *driver, DriverTarget *dtar)
if (RNA_path_resolve(&id_ptr, path, &ptr, &prop)) {
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(&ptr, prop))
value= (float)RNA_property_boolean_get_index(&ptr, prop, index);
else
value= (float)RNA_property_boolean_get(&ptr, prop);
break;
case PROP_INT:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(&ptr, prop))
value= (float)RNA_property_int_get_index(&ptr, prop, index);
else
value= (float)RNA_property_int_get(&ptr, prop);
break;
case PROP_FLOAT:
if (RNA_property_array_length(prop))
if (RNA_property_array_length(&ptr, prop))
value= RNA_property_float_get_index(&ptr, prop, index);
else
value= RNA_property_float_get(&ptr, prop);
+3 -4
View File
@@ -462,7 +462,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
nu2->resolu= cu->resolu;
nu2->bezt = NULL;
nu2->knotsu = nu2->knotsv = NULL;
nu2->flag= 0;
nu2->flag= CU_2D;
nu2->charidx = charidx+1000;
if (mat_nr > 0) nu2->mat_nr= mat_nr-1;
nu2->pntsu = 4;
@@ -495,7 +495,6 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
nu2->bp[3].vec[2] = 0;
nu2->bp[3].vec[3] = 1.0;
nu2->type = CU_2D;
BLI_addtail(&(cu->nurb), nu2);
}
@@ -1040,8 +1039,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
/* calc the right loc AND the right rot separately */
/* vec, tvec need 4 items */
where_on_path(cu->textoncurve, ctime, vec, tvec);
where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec);
where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL);
where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL);
VecMulf(vec, sizefac);
+6 -1
View File
@@ -214,6 +214,11 @@ bGPdata *gpencil_data_addnew (char name[])
/* initial settings */
gpd->flag = (GP_DATA_DISPINFO|GP_DATA_EXPAND);
/* for now, stick to view is also enabled by default
* since this is more useful...
*/
gpd->flag |= GP_DATA_VIEWALIGN;
return gpd;
}
@@ -308,7 +313,7 @@ bGPdata *gpencil_data_duplicate (bGPdata *src)
void gpencil_frame_delete_laststroke (bGPDlayer *gpl, bGPDframe *gpf)
{
bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL;
int cfra = 1; // XXX FIXME!!!
int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */
/* error checking */
if (ELEM(NULL, gpf, gps))
+10
View File
@@ -142,6 +142,16 @@ Group *add_group(char *name)
return group;
}
Group *copy_group(Group *group)
{
Group *groupn;
groupn= MEM_dupallocN(group);
BLI_duplicatelist(&groupn->gobject, &group->gobject);
return groupn;
}
/* external */
void add_to_group(Group *group, Object *ob)
{
+1 -1
View File
@@ -167,7 +167,7 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
for (i=newlen; i<prop->len; i++) {
IDP_FreeProperty(GETPROP(prop, i));
}
memcpy(newarr, prop->data.pointer, newlen*prop->len*sizeof(IDProperty));
memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty));
}
if(prop->data.pointer)
+136 -89
View File
@@ -38,6 +38,11 @@
#include <time.h>
#ifdef _WIN32
#define open _open
#define close _close
#endif
#include "MEM_guardedalloc.h"
#include "IMB_imbuf_types.h"
@@ -73,6 +78,8 @@
//XXX #include "BIF_editseq.h"
#include "BLF_api.h"
#include "PIL_time.h"
#include "RE_pipeline.h"
@@ -978,7 +985,6 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (do_prefix) strcpy(stamp_data->file, "File <untitled>");
else strcpy(stamp_data->file, "<untitled>");
}
stamp_data->note[0] = '\0';
} else {
stamp_data->file[0] = '\0';
}
@@ -1046,8 +1052,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (scene->r.stamp & R_STAMP_FRAME) {
char format[32];
if (do_prefix) sprintf(format, "Frame %%0%di\n", 1 + (int) log10(scene->r.efra));
else sprintf(format, "%%0%di\n", 1 + (int) log10(scene->r.efra));
if (do_prefix) sprintf(format, "Frame %%0%di", 1 + (int) log10(scene->r.efra));
else sprintf(format, "%%0%di", 1 + (int) log10(scene->r.efra));
sprintf (stamp_data->frame, format, scene->r.cfra);
} else {
stamp_data->frame[0] = '\0';
@@ -1083,131 +1089,172 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
}
}
// XXX - Bad level call.
extern int datatoc_bmonofont_ttf_size;
extern char datatoc_bmonofont_ttf[];
// XXX - copied from text_font_begin
static void stamp_font_begin(int size)
{
static int mono= -1;
if (mono == -1)
mono= BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
BLF_set(mono);
BLF_aspect(1.0);
BLF_size(size, 72);
}
void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels)
{
#if 0
// XXX
// This go back when BLF_draw_buffer is implemented - Diego
struct StampData stamp_data;
int x=1,y=1;
int font_height;
int text_width;
int text_pad;
struct BMF_Font *font;
float w, h, pad;
int x, y;
if (!rect && !rectf)
return;
stampdata(scene, &stamp_data, 1);
switch (scene->r.stamp_font_id) {
case 1: /* tiny */
font = BMF_GetFont(BMF_kHelveticaBold8);
break;
case 2: /* small */
font = BMF_GetFont(BMF_kHelveticaBold10);
break;
case 3: /* medium */
font = BMF_GetFont(BMF_kScreen12);
break;
case 0: /* large - default */
font = BMF_GetFont(BMF_kScreen15);
break;
case 4: /* huge */
font = BMF_GetFont(BMF_kHelveticaBold14);
break;
default:
font = NULL;
break;
}
font_height = BMF_GetFontHeight(font);
/* All texts get halfspace+1 pixel on each side and 1 pix
above and below as padding against their backing rectangles */
text_pad = BMF_GetStringWidth(font, " ");
x = 1; /* Inits for everyone, text position, so 1 for padding, not 0 */
y = height - font_height - 1; /* Also inits for everyone, notice padding pixel */
stamp_font_begin(12);
BLF_buffer(rectf, rect, width, height, channels);
BLF_buffer_col(scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
pad= BLF_width("--");
x= 0;
y= height;
if (stamp_data.file[0]) {
/* Top left corner */
text_width = BMF_GetStringWidth(font, stamp_data.file);
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.file, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
y -= font_height+2; /* Top and bottom 1 pix padding each */
BLF_width_and_height(stamp_data.file, &w, &h);
y -= h;
/* also a little of space to the background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+3);
/* and draw the text. */
BLF_position(x, y, 0.0);
BLF_draw_buffer(stamp_data.file);
/* the extra pixel for background. */
y -= 4;
}
/* Top left corner, below File */
if (stamp_data.note[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.note);
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.note, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
y -= font_height+2; /* Top and bottom 1 pix padding each */
BLF_width_and_height(stamp_data.note, &w, &h);
y -= h;
/* and space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-2, w+3, y+h+2);
BLF_position(x, y+1, 0.0);
BLF_draw_buffer(stamp_data.note);
/* the extra pixel for background. */
y -= 4;
}
/* Top left corner, below File (or Note) */
if (stamp_data.date[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.date);
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.date, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
BLF_width_and_height(stamp_data.date, &w, &h);
y -= h;
/* and space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3);
BLF_position(x, y, 0.0);
BLF_draw_buffer(stamp_data.date);
}
x= 0;
y= 0;
/* Bottom left corner, leaving space for timing */
if (stamp_data.marker[0]) {
x = 1;
y = font_height+2+1; /* 2 for padding in TIME|FRAME fields below and 1 for padding in this one */
text_width = BMF_GetStringWidth(font, stamp_data.marker);
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.marker, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
BLF_width_and_height(stamp_data.marker, &w, &h);
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+3);
/* and pad the text. */
BLF_position(x, y+3, 0.0);
BLF_draw_buffer(stamp_data.marker);
/* space width. */
x += w + pad;
}
/* Left bottom corner */
if (stamp_data.time[0]) {
x = 1;
y = 1;
text_width = BMF_GetStringWidth(font, stamp_data.time);
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.time, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
x += text_width+text_pad+2; /* Both sides have 1 pix additional padding each */
BLF_width_and_height(stamp_data.time, &w, &h);
/* extra space for background */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3);
/* and pad the text. */
BLF_position(x, y+3, 0.0);
BLF_draw_buffer(stamp_data.time);
/* space width. */
x += w + pad;
}
if (stamp_data.frame[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.frame);
/* Left bottom corner (after SMPTE if exists) */
if (!stamp_data.time[0]) x = 1;
y = 1;
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.frame, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
BLF_width_and_height(stamp_data.frame, &w, &h);
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3);
/* and pad the text. */
BLF_position(x, y+3, 0.0);
BLF_draw_buffer(stamp_data.frame);
/* space width. */
x += w + pad;
}
if (stamp_data.camera[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.camera);
/* Center of bottom edge */
x = (width/2) - (BMF_GetStringWidth(font, stamp_data.camera)/2);
y = 1;
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.camera, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
BLF_width_and_height(stamp_data.camera, &w, &h);
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3);
BLF_position(x, y+3, 0.0);
BLF_draw_buffer(stamp_data.camera);
}
if (stamp_data.scene[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.scene);
/* Bottom right corner */
x = width - (text_width+1+text_pad);
y = 1;
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.scene, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
BLF_width_and_height(stamp_data.scene, &w, &h);
/* Bottom right corner, with an extra space because blenfont is too strict! */
x= width - w - 2;
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+3);
/* and pad the text. */
BLF_position(x, y+3, 0.0);
BLF_draw_buffer(stamp_data.scene);
}
if (stamp_data.strip[0]) {
text_width = BMF_GetStringWidth(font, stamp_data.strip);
/* Top right corner */
x = width - (text_width+1+text_pad);
y = height - font_height - 1;
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-1, y-1, x+text_width+text_pad+1, y+font_height+1);
BMF_DrawStringBuf(font, stamp_data.strip, x+(text_pad/2), y, scene->r.fg_stamp, rect, rectf, width, height, channels);
BLF_width_and_height(stamp_data.scene, &w, &h);
/* Top right corner, with an extra space because blenfont is too strict! */
x= width - w - pad;
y= height - h;
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+3);
BLF_position(x, y, 0.0);
BLF_draw_buffer(stamp_data.strip);
}
#endif // 0 XXX
/* cleanup the buffer. */
BLF_buffer(NULL, NULL, 0, 0, 0);
}
void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf)
+86 -2
View File
@@ -1183,7 +1183,8 @@ DO_INLINE void dfdx_spring(float to[3][3], float dir[3],float length,float L,fl
//return ( (I-outerprod(dir,dir))*Min(1.0f,rest/length) - I) * -k;
mul_fvectorT_fvector(to, dir, dir);
sub_fmatrix_fmatrix(to, I, to);
mul_fmatrix_S(to, (((L/length)> 1.0f) ? (1.0f): (L/length)));
mul_fmatrix_S(to, (L/length));
sub_fmatrix_fmatrix(to, to, I);
mul_fmatrix_S(to, -k);
}
@@ -1218,6 +1219,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
float nulldfdx[3][3]={ {0,0,0}, {0,0,0}, {0,0,0}};
float scaling = 0.0;
int no_compress = clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS;
VECCOPY(s->f, nullf);
cp_fmatrix(s->dfdx, nulldfdx);
@@ -1254,7 +1257,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
// calculate force of structural + shear springs
if((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR))
{
if(length > L) // only on elonglation
if(length > L || no_compress)
{
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
@@ -1393,6 +1396,84 @@ float calculateVertexWindForce(float wind[3], float vertexnormal[3])
return (INPR(wind, vertexnormal));
}
typedef struct HairGridVert {
float velocity[3];
float density;
} HairGridVert;
/* Smoothing of hair velocities:
* adapted from
Volumetric Methods for Simulation and Rendering of Hair
by Lena Petrovic, Mark Henne and John Anderson
* Pixar Technical Memo #06-08, Pixar Animation Studios
*/
static void hair_velocity_smoothing(float smoothfac, lfVector *lF, lfVector *lX, lfVector *lV, int numverts)
{
/* TODO: this is an initial implementation and should be made much better in due time */
/* 10x10x10 grid gives nice initial results */
HairGridVert grid[10][10][10];
float gmin[3], gmax[3], density;
int v = 0;
int i = 0;
int j = 0;
int k = 0;
lfVector temp;
INIT_MINMAX(gmin, gmax);
for(i = 0; i < numverts; i++)
DO_MINMAX(lX[i], gmin, gmax);
/* initialize grid */
for(i = 0; i < 10; i++) {
for(j = 0; j < 10; j++) {
for(k = 0; k < 10; k++) {
grid[i][j][k].velocity[0] = 0.0f;
grid[i][j][k].velocity[1] = 0.0f;
grid[i][j][k].velocity[2] = 0.0f;
grid[i][j][k].density = 0.0f;
}
}
}
/* gather velocities & density */
for(v = 0; v < numverts; v++) {
i = (int)( (lX[v][0] - gmin[0]) / (gmax[0] - gmin[0]) * 9.99f );
j = (int)( (lX[v][1] - gmin[1]) / (gmax[1] - gmin[1]) * 9.99f );
k = (int)( (lX[v][2] - gmin[2]) / (gmax[2] - gmin[2]) * 9.99f );
grid[i][j][k].velocity[0] += lV[v][0];
grid[i][j][k].velocity[1] += lV[v][1];
grid[i][j][k].velocity[2] += lV[v][2];
grid[i][j][k].density += 1.0f;
}
/* divide velocity with density */
for(i = 0; i < 10; i++) {
for(j = 0; j < 10; j++) {
for(k = 0; k < 10; k++) {
density = grid[i][j][k].density;
if(density > 0.0f) {
grid[i][j][k].velocity[0] /= density;
grid[i][j][k].velocity[1] /= density;
grid[i][j][k].velocity[2] /= density;
}
}
}
}
/* calculate forces */
for(v = 0; v < numverts; v++) {
i = (int)( (lX[v][0] - gmin[0]) / (gmax[0] - gmin[0]) * 9.99f );
j = (int)( (lX[v][1] - gmin[1]) / (gmax[1] - gmin[1]) * 9.99f );
k = (int)( (lX[v][2] - gmin[2]) / (gmax[2] - gmin[2]) * 9.99f );
/* 2.0f is an experimental value that seems to give good results */
lF[v][0] += 2.0f * smoothfac * (grid[i][j][k].velocity[0] - lV[v][0]);
lF[v][1] += 2.0f * smoothfac * (grid[i][j][k].velocity[1] - lV[v][1]);
lF[v][2] += 2.0f * smoothfac * (grid[i][j][k].velocity[2] - lV[v][2]);
}
}
static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M)
{
/* Collect forces and derivatives: F,dFdX,dFdV */
@@ -1416,6 +1497,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF,
init_lfvector(lF, gravity, numverts);
if(clmd->sim_parms->velocity_smooth > 0.0f)
hair_velocity_smoothing(clmd->sim_parms->velocity_smooth, lF, lX, lV, numverts);
/* multiply lF with mass matrix
// force = mass * acceleration (in this case: gravity)
*/
+71 -46
View File
@@ -266,66 +266,91 @@ void sort_keys(Key *key)
/**************** do the key ****************/
void set_four_ipo(float d, float *data, int type)
void key_curve_position_weights(float t, float *data, int type)
{
float d2, d3, fc;
float t2, t3, fc;
if(type==KEY_LINEAR) {
data[0]= 0.0f;
data[1]= 1.0f-d;
data[2]= d;
data[3]= 0.0f;
data[0]= 0.0f;
data[1]= -t + 1.0f;
data[2]= t;
data[3]= 0.0f;
}
else {
d2= d*d;
d3= d2*d;
else if(type==KEY_CARDINAL) {
t2= t*t;
t3= t2*t;
fc= 0.71f;
if(type==KEY_CARDINAL) {
data[0]= -fc*t3 + 2.0f*fc*t2 - fc*t;
data[1]= (2.0f-fc)*t3 + (fc-3.0f)*t2 + 1.0f;
data[2]= (fc-2.0f)*t3 + (3.0f-2.0f*fc)*t2 + fc*t;
data[3]= fc*t3 - fc*t2;
}
else if(type==KEY_BSPLINE) {
t2= t*t;
t3= t2*t;
fc= 0.71f;
data[0]= -fc*d3 +2.0f*fc*d2 -fc*d;
data[1]= (2.0f-fc)*d3 +(fc-3.0f)*d2 +1.0f;
data[2]= (fc-2.0f)*d3 +(3.0f-2.0f*fc)*d2 +fc*d;
data[3]= fc*d3 -fc*d2;
}
else if(type==KEY_BSPLINE) {
data[0]= -0.16666666f*d3 +0.5f*d2 -0.5f*d +0.16666666f;
data[1]= 0.5f*d3 -d2 +0.6666666f;
data[2]= -0.5f*d3 +0.5f*d2 +0.5f*d +0.16666666f;
data[3]= 0.16666666f*d3 ;
}
data[0]= -0.16666666f*t3 + 0.5f*t2 - 0.5f*t + 0.16666666f;
data[1]= 0.5f*t3 - t2 + 0.6666666f;
data[2]= -0.5f*t3 + 0.5f*t2 + 0.5f*t + 0.16666666f;
data[3]= 0.16666666f*t3;
}
}
void set_afgeleide_four_ipo(float d, float *data, int type)
/* first derivative */
void key_curve_tangent_weights(float t, float *data, int type)
{
float d2, fc;
float t2, fc;
if(type==KEY_LINEAR) {
data[0]= 0.0f;
data[1]= -1.0f;
data[2]= 1.0f;
data[3]= 0.0f;
}
else {
d2= d*d;
else if(type==KEY_CARDINAL) {
t2= t*t;
fc= 0.71f;
if(type==KEY_CARDINAL) {
data[0]= -3.0f*fc*t2 +4.0f*fc*t - fc;
data[1]= 3.0f*(2.0f-fc)*t2 +2.0f*(fc-3.0f)*t;
data[2]= 3.0f*(fc-2.0f)*t2 +2.0f*(3.0f-2.0f*fc)*t + fc;
data[3]= 3.0f*fc*t2 -2.0f*fc*t;
}
else if(type==KEY_BSPLINE) {
t2= t*t;
fc= 0.71f;
data[0]= -3.0f*fc*d2 +4.0f*fc*d -fc;
data[1]= 3.0f*(2.0f-fc)*d2 +2.0f*(fc-3.0f)*d;
data[2]= 3.0f*(fc-2.0f)*d2 +2.0f*(3.0f-2.0f*fc)*d +fc;
data[3]= 3.0f*fc*d2 -2.0f*fc*d;
}
else if(type==KEY_BSPLINE) {
data[0]= -0.5f*t2 + t - 0.5f;
data[1]= 1.5f*t2 - 2.0f*t;
data[2]= -1.5f*t2 + t + 0.5f;
data[3]= 0.5f*t2;
}
}
data[0]= -0.16666666f*3.0f*d2 +d -0.5f;
data[1]= 1.5f*d2 -2.0f*d;
data[2]= -1.5f*d2 +d +0.5f;
data[3]= 0.16666666f*3.0f*d2 ;
}
/* second derivative */
void key_curve_normal_weights(float t, float *data, int type)
{
float fc;
if(type==KEY_LINEAR) {
data[0]= 0.0f;
data[1]= 0.0f;
data[2]= 0.0f;
data[3]= 0.0f;
}
else if(type==KEY_CARDINAL) {
fc= 0.71f;
data[0]= -6.0f*fc*t + 4.0f*fc;
data[1]= 6.0f*(2.0f-fc)*t + 2.0f*(fc-3.0f);
data[2]= 6.0f*(fc-2.0f)*t + 2.0f*(3.0f-2.0f*fc);
data[3]= 6.0f*fc*t - 2.0f*fc;
}
else if(type==KEY_BSPLINE) {
data[0]= -1.0f*t + 1.0f;
data[1]= 3.0f*t - 2.0f;
data[2]= -3.0f*t + 1.0f;
data[3]= 1.0f*t;
}
}
@@ -436,10 +461,10 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
/* interpolation */
set_four_ipo(d, t, k[1]->type);
key_curve_position_weights(d, t, k[1]->type);
if(k[1]->type != k[2]->type) {
set_four_ipo(d, fval, k[2]->type);
key_curve_position_weights(d, fval, k[2]->type);
temp= 1.0f-d;
t[0]= temp*t[0]+ d*fval[0];
+21 -10
View File
@@ -364,7 +364,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
u= (vec[0]-lt->fu)/lt->du;
ui= (int)floor(u);
u -= ui;
set_four_ipo(u, tu, lt->typeu);
key_curve_position_weights(u, tu, lt->typeu);
}
else {
tu[0]= tu[2]= tu[3]= 0.0; tu[1]= 1.0;
@@ -375,7 +375,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
v= (vec[1]-lt->fv)/lt->dv;
vi= (int)floor(v);
v -= vi;
set_four_ipo(v, tv, lt->typev);
key_curve_position_weights(v, tv, lt->typev);
}
else {
tv[0]= tv[2]= tv[3]= 0.0; tv[1]= 1.0;
@@ -386,7 +386,7 @@ void calc_latt_deform(Object *ob, float *co, float weight)
w= (vec[2]-lt->fw)/lt->dw;
wi= (int)floor(w);
w -= wi;
set_four_ipo(w, tw, lt->typew);
key_curve_position_weights(w, tw, lt->typew);
}
else {
tw[0]= tw[2]= tw[3]= 0.0; tw[1]= 1.0;
@@ -472,7 +472,7 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc
}
/* this makes sure we can extend for non-cyclic. *vec needs 4 items! */
static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir) /* returns OK */
static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius) /* returns OK */
{
Curve *cu= ob->data;
BevList *bl;
@@ -490,21 +490,25 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir)
else ctime1= ctime;
/* vec needs 4 items */
if(where_on_path(ob, ctime1, vec, dir)) {
if(where_on_path(ob, ctime1, vec, dir, quat, radius)) {
if(cycl==0) {
Path *path= cu->path;
float dvec[3];
if(ctime < 0.0) {
VecSubf(dvec, path->data+4, path->data);
VecSubf(dvec, path->data[1].vec, path->data[0].vec);
VecMulf(dvec, ctime*(float)path->len);
VECADD(vec, vec, dvec);
if(quat) QUATCOPY(quat, path->data[0].quat);
if(radius) *radius= path->data[0].radius;
}
else if(ctime > 1.0) {
VecSubf(dvec, path->data+4*path->len-4, path->data+4*path->len-8);
VecSubf(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
VecMulf(dvec, (ctime-1.0)*(float)path->len);
VECADD(vec, vec, dvec);
if(quat) QUATCOPY(quat, path->data[path->len-1].quat);
if(radius) *radius= path->data[path->len-1].radius;
}
}
return 1;
@@ -520,7 +524,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir)
static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, CurveDeform *cd, float *quatp)
{
Curve *cu= par->data;
float fac, loc[4], dir[3], cent[3];
float fac, loc[4], dir[3], cent[3], radius;
short upflag, index;
if(axis==MOD_CURVE_POSX || axis==MOD_CURVE_NEGX) {
@@ -575,7 +579,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
}
#endif // XXX old animation system
if( where_on_path_deform(par, fac, loc, dir)) { /* returns OK */
if( where_on_path_deform(par, fac, loc, dir, NULL, &radius)) { /* returns OK */
float q[4], mat[3][3], quat[4];
if(cd->no_rot_axis) /* set by caller */
@@ -595,7 +599,14 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
QuatMul(quat, q, quat);
}
QuatToMat3(quat, mat);
if(cu->flag & CU_PATH_RADIUS) {
float tmat[3][3], rmat[3][3];
Mat3Scale(tmat, radius);
Mat3MulMat3(rmat, mat, tmat);
Mat3CpyMat3(mat, rmat);
}
/* local rotation */
Mat3MulVecfl(mat, cent);
+232 -7
View File
@@ -119,6 +119,13 @@
#define MAX_IDPUP 60 /* was 24 */
/* GS reads the memory pointed at in a specific ordering.
only use this definition, makes little and big endian systems
work fine, in conjunction with MAKE_ID */
/* from blendef: */
#define GS(a) (*((short *)(a)))
/* ************* general ************************ */
void id_lib_extern(ID *id)
@@ -148,6 +155,220 @@ void id_us_min(ID *id)
id->us--;
}
int id_make_local(ID *id, int test)
{
if(id->flag & LIB_INDIRECT)
return 0;
switch(GS(id->name)) {
case ID_SCE:
return 0; /* not implemented */
case ID_LI:
return 0; /* can't be linked */
case ID_OB:
if(!test) make_local_object((Object*)id);
return 1;
case ID_ME:
if(!test) {
make_local_mesh((Mesh*)id);
make_local_key(((Mesh*)id)->key);
}
return 1;
case ID_CU:
if(!test) {
make_local_curve((Curve*)id);
make_local_key(((Curve*)id)->key);
}
return 1;
case ID_MB:
if(!test) make_local_mball((MetaBall*)id);
return 1;
case ID_MA:
if(!test) make_local_material((Material*)id);
return 1;
case ID_TE:
if(!test) make_local_texture((Tex*)id);
return 1;
case ID_IM:
return 0; /* not implemented */
case ID_WV:
return 0; /* deprecated */
case ID_LT:
if(!test) {
make_local_lattice((Lattice*)id);
make_local_key(((Lattice*)id)->key);
}
return 1;
case ID_LA:
if(!test) make_local_lamp((Lamp*)id);
return 1;
case ID_CA:
if(!test) make_local_camera((Camera*)id);
return 1;
case ID_IP:
return 0; /* deprecated */
case ID_KE:
if(!test) make_local_key((Key*)id);
return 1;
case ID_WO:
if(!test) make_local_world((World*)id);
return 1;
case ID_SCR:
return 0; /* can't be linked */
case ID_VF:
return 0; /* not implemented */
case ID_TXT:
return 0; /* not implemented */
case ID_SCRIPT:
return 0; /* deprecated */
case ID_SO:
return 0; /* not implemented */
case ID_GR:
return 0; /* not implemented */
case ID_AR:
if(!test) make_local_armature((bArmature*)id);
return 1;
case ID_AC:
if(!test) make_local_action((bAction*)id);
return 1;
case ID_NT:
return 0; /* not implemented */
case ID_BR:
if(!test) make_local_brush((Brush*)id);
return 1;
case ID_PA:
if(!test) make_local_particlesettings((ParticleSettings*)id);
return 1;
case ID_WM:
return 0; /* can't be linked */
case ID_GD:
return 0; /* not implemented */
}
return 0;
}
int id_copy(ID *id, ID **newid, int test)
{
if(!test) *newid= NULL;
/* conventions:
* - make shallow copy, only this ID block
* - id.us of the new ID is set to 1 */
switch(GS(id->name)) {
case ID_SCE:
return 0; /* can't be copied from here */
case ID_LI:
return 0; /* can't be copied from here */
case ID_OB:
if(!test) *newid= (ID*)copy_object((Object*)id);
return 1;
case ID_ME:
if(!test) *newid= (ID*)copy_mesh((Mesh*)id);
return 1;
case ID_CU:
if(!test) *newid= (ID*)copy_curve((Curve*)id);
return 1;
case ID_MB:
if(!test) *newid= (ID*)copy_mball((MetaBall*)id);
return 1;
case ID_MA:
if(!test) *newid= (ID*)copy_material((Material*)id);
return 1;
case ID_TE:
if(!test) *newid= (ID*)copy_texture((Tex*)id);
return 1;
case ID_IM:
return 0; /* not implemented */
case ID_WV:
return 0; /* deprecated */
case ID_LT:
if(!test) *newid= (ID*)copy_lattice((Lattice*)id);
return 1;
case ID_LA:
if(!test) *newid= (ID*)copy_lamp((Lamp*)id);
return 1;
case ID_CA:
if(!test) *newid= (ID*)copy_camera((Camera*)id);
return 1;
case ID_IP:
return 0; /* deprecated */
case ID_KE:
if(!test) *newid= (ID*)copy_key((Key*)id);
return 1;
case ID_WO:
if(!test) *newid= (ID*)copy_world((World*)id);
return 1;
case ID_SCR:
return 0; /* can't be copied from here */
case ID_VF:
return 0; /* not implemented */
case ID_TXT:
if(!test) *newid= (ID*)copy_text((Text*)id);
return 1;
case ID_SCRIPT:
return 0; /* deprecated */
case ID_SO:
return 0; /* not implemented */
case ID_GR:
if(!test) *newid= (ID*)copy_group((Group*)id);
return 1;
case ID_AR:
if(!test) *newid= (ID*)copy_armature((bArmature*)id);
return 1;
case ID_AC:
if(!test) *newid= (ID*)copy_action((bAction*)id);
return 1;
case ID_NT:
if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id, 0);
return 1;
case ID_BR:
if(!test) *newid= (ID*)copy_brush((Brush*)id);
return 1;
case ID_PA:
if(!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id);
return 1;
case ID_WM:
return 0; /* can't be copied from here */
case ID_GD:
return 0; /* not implemented */
}
return 0;
}
int id_unlink(ID *id, int test)
{
Main *mainlib= G.main;
ListBase *lb;
switch(GS(id->name)) {
case ID_TXT:
if(test) return 1;
unlink_text(mainlib, (Text*)id);
break;
case ID_GR:
if(test) return 1;
unlink_group((Group*)id);
break;
case ID_OB:
if(test) return 1;
unlink_object(NULL, (Object*)id);
break;
}
if(id->us == 0) {
if(test) return 1;
lb= wich_libbase(mainlib, GS(id->name));
free_libblock(lb, id);
return 1;
}
return 0;
}
ListBase *wich_libbase(Main *mainlib, short type)
{
switch( type ) {
@@ -234,6 +455,17 @@ void flag_all_listbases_ids(short flag, short value)
while(a--) flag_listbase_ids(lbarray[a], flag, value);
}
void recalc_all_library_objects(struct Main *main)
{
/* DISPLISTS? */
Object *ob= main->object.first;
while(ob) {
if(ob->id.lib) {
ob->recalc |= OB_RECALC;
}
ob= ob->id.next;
}
}
/* note: MAX_LIBARRAY define should match this code */
int set_listbasepointers(Main *main, ListBase **lb)
@@ -409,13 +641,6 @@ void *alloc_libblock(ListBase *lb, short type, const char *name)
return id;
}
/* GS reads the memory pointed at in a specific ordering.
only use this definition, makes little and big endian systems
work fine, in conjunction with MAKE_ID */
/* from blendef: */
#define GS(a) (*((short *)(a)))
/* by spec, animdata is first item after ID */
/* we still read ->adt itself, to ensure compiler warns when it doesnt exist */
static void id_copy_animdata(ID *id)
+56 -12
View File
@@ -170,7 +170,22 @@ void init_material(Material *ma)
ma->sss_front= 1.0f;
ma->sss_back= 1.0f;
ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR;
ma->vol.density = 1.0f;
ma->vol.emission = 0.0f;
ma->vol.absorption = 1.0f;
ma->vol.scattering = 1.0f;
ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f;
ma->vol.absorption_col[0] = ma->vol.absorption_col[1] = ma->vol.absorption_col[2] = 0.0f;
ma->vol.density_scale = 1.0f;
ma->vol.depth_cutoff = 0.01f;
ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED;
ma->vol.stepsize = 0.2f;
ma->vol.shade_stepsize = 0.2f;
ma->vol.shade_type = MA_VOL_SHADE_SINGLE;
ma->vol.shadeflag |= MA_VOL_PRECACHESHADING;
ma->vol.precache_resolution = 50;
ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP;
ma->preview = NULL;
}
@@ -1016,15 +1031,15 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col)
}
break;
case MA_RAMP_DARK:
tmp= fac*col[0];
if(tmp < *r) *r= tmp;
if(g) {
tmp= fac*col[1];
if(tmp < *g) *g= tmp;
tmp= fac*col[2];
if(tmp < *b) *b= tmp;
}
break;
tmp=col[0]+((1-col[0])*facm);
if(tmp < *r) *r= tmp;
if(g) {
tmp=col[1]+((1-col[1])*facm);
if(tmp < *g) *g= tmp;
tmp=col[2]+((1-col[2])*facm);
if(tmp < *b) *b= tmp;
}
break;
case MA_RAMP_LIGHT:
tmp= fac*col[0];
if(tmp > *r) *r= tmp;
@@ -1154,8 +1169,37 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col)
}
}
break;
}
case MA_RAMP_SOFT:
if (g){
float scr, scg, scb;
/* first calculate non-fac based Screen mix */
scr = 1.0 - ((1.0 - col[0])) * (1.0 - *r);
scg = 1.0 - ((1.0 - col[1])) * (1.0 - *g);
scb = 1.0 - ((1.0 - col[2])) * (1.0 - *b);
*r = facm*(*r) + fac*(((1.0 - *r) * col[0] * (*r)) + (*r * scr));
*g = facm*(*g) + fac*(((1.0 - *g) * col[1] * (*g)) + (*g * scg));
*b = facm*(*b) + fac*(((1.0 - *b) * col[2] * (*b)) + (*b * scb));
}
break;
case MA_RAMP_LINEAR:
if (col[0] > 0.5)
*r = *r + fac*(2*(col[0]-0.5));
else
*r = *r + fac*(2*(col[0]) - 1);
if (g){
if (col[1] > 0.5)
*g = *g + fac*(2*(col[1]-0.5));
else
*g = *g + fac*(2*(col[1]) -1);
if (col[2] > 0.5)
*b = *b + fac*(2*(col[2]-0.5));
else
*b = *b + fac*(2*(col[2]) - 1);
}
break;
}
}
+2 -2
View File
@@ -977,7 +977,7 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth)
}
}
// XXX do this in caller DAG_object_flush_update(scene, meshOb, OB_RECALC_DATA);
// XXX do this in caller DAG_id_flush_update(&me->id, OB_RECALC_DATA);
}
void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float **faceNors_r)
@@ -1265,7 +1265,7 @@ void mesh_pmv_revert(Object *ob, Mesh *me)
MEM_freeN(me->pv->vert_map);
me->pv->vert_map= NULL;
// XXX do this in caller DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
// XXX do this in caller DAG_id_flush_update(&me->id, OB_RECALC_DATA);
}
}
+46 -52
View File
@@ -73,11 +73,12 @@
#include "BLI_editVert.h"
#include "MTC_matrixops.h"
#include "MTC_vectorops.h"
#include "BKE_main.h"
#include "BKE_anim.h"
#include "BKE_action.h"
#include "BKE_bmesh.h"
// XXX #include "BKE_booleanops.h"
#include "BKE_cloth.h"
@@ -1189,7 +1190,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(amd->end_cap && amd->end_cap != ob)
end_cap = mesh_get_derived_final(scene, amd->end_cap, CD_MASK_MESH);
MTC_Mat4One(offset);
Mat4One(offset);
indexMap = MEM_callocN(sizeof(*indexMap) * dm->getNumVerts(dm),
"indexmap");
@@ -1211,14 +1212,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
float result_mat[4][4];
if(ob)
MTC_Mat4Invert(obinv, ob->obmat);
Mat4Invert(obinv, ob->obmat);
else
MTC_Mat4One(obinv);
Mat4One(obinv);
MTC_Mat4MulSerie(result_mat, offset,
Mat4MulSerie(result_mat, offset,
obinv, amd->offset_ob->obmat,
NULL, NULL, NULL, NULL, NULL);
MTC_Mat4CpyMat4(offset, result_mat);
Mat4CpyMat4(offset, result_mat);
}
if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
@@ -1243,7 +1244,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
prescribed length */
if(amd->fit_type == MOD_ARR_FITLENGTH
|| amd->fit_type == MOD_ARR_FITCURVE) {
float dist = sqrt(MTC_dot3Float(offset[3], offset[3]));
float dist = sqrt(Inpf(offset[3], offset[3]));
if(dist > 1e-6f)
/* this gives length = first copy start to last copy end
@@ -1276,11 +1277,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces);
/* calculate the offset matrix of the final copy (for merging) */
MTC_Mat4One(final_offset);
Mat4One(final_offset);
for(j=0; j < count - 1; j++) {
MTC_Mat4MulMat4(tmp_mat, final_offset, offset);
MTC_Mat4CpyMat4(final_offset, tmp_mat);
Mat4MulMat4(tmp_mat, final_offset, offset);
Mat4CpyMat4(final_offset, tmp_mat);
}
numVerts = numEdges = numFaces = 0;
@@ -1316,7 +1317,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if((count > 1) && (amd->flags & MOD_ARR_MERGE)) {
float tmp_co[3];
VECCOPY(tmp_co, mv->co);
MTC_Mat4MulVecfl(offset, tmp_co);
Mat4MulVecfl(offset, tmp_co);
for(j = 0; j < maxVerts; j++) {
/* if vertex already merged, don't use it */
@@ -1331,7 +1332,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if(amd->flags & MOD_ARR_MERGEFINAL) {
VECCOPY(tmp_co, inMV->co);
inMV = &src_mvert[i];
MTC_Mat4MulVecfl(final_offset, tmp_co);
Mat4MulVecfl(final_offset, tmp_co);
if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist))
indexMap[i].merge_final = 1;
}
@@ -1349,7 +1350,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
*mv2 = *mv;
numVerts++;
MTC_Mat4MulVecfl(offset, co);
Mat4MulVecfl(offset, co);
VECCOPY(mv2->co, co);
}
} else if(indexMap[i].merge != i && indexMap[i].merge_final) {
@@ -3181,7 +3182,7 @@ static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle,
/* we know the edge has 2 faces, so check the angle */
SmoothFace *face1 = edge->faces->link;
SmoothFace *face2 = edge->faces->next->link;
float edge_angle_cos = MTC_dot3Float(face1->normal,
float edge_angle_cos = Inpf(face1->normal,
face2->normal);
if(edge_angle_cos < threshold) {
@@ -4050,11 +4051,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
/* find the projector which the face points at most directly
* (projector normal with largest dot product is best)
*/
best_dot = MTC_dot3Float(projectors[0].normal, face_no);
best_dot = Inpf(projectors[0].normal, face_no);
best_projector = &projectors[0];
for(j = 1; j < num_projectors; ++j) {
float tmp_dot = MTC_dot3Float(projectors[j].normal,
float tmp_dot = Inpf(projectors[j].normal,
face_no);
if(tmp_dot > best_dot) {
best_dot = tmp_dot;
@@ -5598,6 +5599,7 @@ static void hookModifier_copyData(ModifierData *md, ModifierData *target)
thmd->indexar = MEM_dupallocN(hmd->indexar);
memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv));
strncpy(thmd->name, hmd->name, 32);
strncpy(thmd->subtarget, hmd->subtarget, 32);
}
CustomDataMask hookModifier_requiredDataMask(Object *ob, ModifierData *md)
@@ -5642,9 +5644,11 @@ static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest, Sce
if (hmd->object) {
DagNode *curNode = dag_get_node(forest, hmd->object);
dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA,
"Hook Modifier");
if (hmd->subtarget[0])
dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, "Hook Modifier");
else
dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, "Hook Modifier");
}
}
@@ -5653,12 +5657,22 @@ static void hookModifier_deformVerts(
float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc)
{
HookModifierData *hmd = (HookModifierData*) md;
float vec[3], mat[4][4];
bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget);
float vec[3], mat[4][4], dmat[4][4];
int i;
DerivedMesh *dm = derivedData;
/* get world-space matrix of target, corrected for the space the verts are in */
if (hmd->subtarget[0] && pchan) {
/* bone target if there's a matching pose-channel */
Mat4MulMat4(dmat, pchan->pose_mat, hmd->object->obmat);
}
else {
/* just object target */
Mat4CpyMat4(dmat, hmd->object->obmat);
}
Mat4Invert(ob->imat, ob->obmat);
Mat4MulSerie(mat, ob->imat, hmd->object->obmat, hmd->parentinv,
Mat4MulSerie(mat, ob->imat, dmat, hmd->parentinv,
NULL, NULL, NULL, NULL, NULL);
/* vertex indices? */
@@ -5715,7 +5729,8 @@ static void hookModifier_deformVerts(
}
}
}
} else { /* vertex group hook */
}
else if(hmd->name[0]) { /* vertex group hook */
bDeformGroup *curdef;
Mesh *me = ob->data;
int index = 0;
@@ -5801,26 +5816,6 @@ static void smokeModifier_initData(ModifierData *md)
smd->coll = NULL;
smd->type = 0;
smd->time = -1;
/*
smd->fluid = NULL;
smd->maxres = 48;
smd->amplify = 4;
smd->omega = 0.5;
smd->time = 0;
smd->flags = 0;
smd->noise = MOD_SMOKE_NOISEWAVE;
smd->visibility = 1;
// init 3dview buffer
smd->tvox = NULL;
smd->tray = NULL;
smd->tvoxbig = NULL;
smd->traybig = NULL;
smd->viewsettings = 0;
smd->bind = NULL;
smd->max_textures = 0;
*/
}
static void smokeModifier_freeData(ModifierData *md)
@@ -6701,10 +6696,8 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
if((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path){
float ran = 0.0f;
if(pimd->random_position != 0.0f) {
/* just use some static collection of random numbers */
/* TODO: use something else that's unique to each instanced object */
pa = psys->particles + (i/totvert)%totpart;
ran = pimd->random_position * 0.5 * (1.0f + pa->r_ave[0]);
BLI_srandom(psys->seed + (i/totvert)%totpart);
ran = pimd->random_position * BLI_frand();
}
if(pimd->flag & eParticleInstanceFlag_KeepShape) {
@@ -8078,14 +8071,13 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob,
int useRenderParams, int isFinalCalc)
{
MultiresModifierData *mmd = (MultiresModifierData*)md;
Mesh *me = get_mesh(ob);
DerivedMesh *final;
/* TODO: for now just skip a level1 mesh */
if(mmd->lvl == 1)
return dm;
final = multires_dm_create_from_derived(mmd, dm, me, useRenderParams, isFinalCalc);
final = multires_dm_create_from_derived(mmd, 0, dm, ob, useRenderParams, isFinalCalc);
if(mmd->undo_signal && mmd->undo_verts && mmd->undo_verts_tot == final->getNumVerts(final)) {
int i;
MVert *dst = CDDM_get_verts(final);
@@ -8580,7 +8572,9 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
mti->type = eModifierTypeType_OnlyDeform;
mti->initData = smokeModifier_initData;
mti->freeData = smokeModifier_freeData;
mti->flags = eModifierTypeFlag_AcceptsMesh;
mti->flags = eModifierTypeFlag_AcceptsMesh
| eModifierTypeFlag_UsesPointCache
| eModifierTypeFlag_Single;
mti->deformVerts = smokeModifier_deformVerts;
mti->dependsOnTime = smokeModifier_dependsOnTime;
mti->updateDepgraph = smokeModifier_updateDepgraph;
@@ -8611,7 +8605,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
mti = INIT_TYPE(Surface);
mti->type = eModifierTypeType_OnlyDeform;
mti->initData = surfaceModifier_initData;
mti->flags = eModifierTypeFlag_AcceptsMesh;
mti->flags = eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_NoUserAdd;
mti->dependsOnTime = surfaceModifier_dependsOnTime;
mti->freeData = surfaceModifier_freeData;
mti->deformVerts = surfaceModifier_deformVerts;
+15 -10
View File
@@ -83,7 +83,7 @@ int multiresModifier_switch_level(Object *ob, const int distance)
mmd->lvl += distance;
if(mmd->lvl < 1) mmd->lvl = 1;
else if(mmd->lvl > mmd->totlvl) mmd->lvl = mmd->totlvl;
/* XXX: DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
/* XXX: DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
object_handle_update(ob);*/
return 1;
}
@@ -204,10 +204,11 @@ static void VecAddUf(float a[3], float b[3])
a[2] += b[2];
}
static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, int lvl, int totlvl,
static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final, int lvl, int totlvl,
int totsubvert, int totsubedge, int totsubface, int addverts)
{
DerivedMesh *mrdm;
Mesh *me = ob->data;
MultiresModifierData mmd_sub;
MVert *mvs = CDDM_get_verts(final);
MVert *mvd, *mvd_f1, *mvs_f1, *mvd_f3, *mvd_f4;
@@ -222,7 +223,7 @@ static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, in
memset(&mmd_sub, 0, sizeof(MultiresModifierData));
mmd_sub.lvl = mmd_sub.totlvl = totlvl;
mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0);
mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0);
mvd = CDDM_get_verts(mrdm);
/* Need to map from ccg to mrdm */
@@ -395,7 +396,7 @@ static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, in
}
}
final->needsFree = 1;
final->needsFree = 1;
final->release(final);
mrdm->needsFree = 1;
MultiresDM_mark_as_modified(mrdm);
@@ -468,7 +469,8 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista
orig = CDDM_from_mesh(me, NULL);
memset(&mmd_sub, 0, sizeof(MultiresModifierData));
mmd_sub.lvl = mmd_sub.totlvl = mmd->lvl;
mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0);
mmd_sub.simple = simple;
mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0);
totsubvert = mrdm->getNumVerts(mrdm);
totsubedge = mrdm->getNumEdges(mrdm);
totsubface = mrdm->getNumFaces(mrdm);
@@ -497,7 +499,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista
orig = CDDM_from_mesh(me, NULL);
multires_subdisp(orig, me, final, mmd->lvl, mmd->totlvl, totsubvert, totsubedge, totsubface, 0);
multires_subdisp(orig, ob, final, mmd->lvl, mmd->totlvl, totsubvert, totsubedge, totsubface, 0);
orig->needsFree = 1;
orig->release(orig);
@@ -1166,9 +1168,11 @@ static void multiresModifier_disp_run(DerivedMesh *dm, MVert *subco, int invert)
static void multiresModifier_update(DerivedMesh *dm)
{
Object *ob;
Mesh *me;
MDisps *mdisps;
ob = MultiresDM_get_object(dm);
me = MultiresDM_get_mesh(dm);
mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS);
@@ -1189,7 +1193,7 @@ static void multiresModifier_update(DerivedMesh *dm)
(includes older displacements but not new sculpts) */
mmd.totlvl = totlvl;
mmd.lvl = lvl;
subco_dm = multires_dm_create_from_derived(&mmd, orig, me, 0, 0);
subco_dm = multires_dm_create_from_derived(&mmd, 1, orig, ob, 0, 0);
cur_lvl_orig_verts = CDDM_get_verts(subco_dm);
/* Subtract the original vertex cos from the new vertex cos */
@@ -1199,7 +1203,7 @@ static void multiresModifier_update(DerivedMesh *dm)
final = multires_subdisp_pre(dm, totlvl - lvl, 0);
multires_subdisp(orig, me, final, lvl, totlvl, dm->getNumVerts(dm), dm->getNumEdges(dm),
multires_subdisp(orig, ob, final, lvl, totlvl, dm->getNumVerts(dm), dm->getNumEdges(dm),
dm->getNumFaces(dm), 1);
subco_dm->release(subco_dm);
@@ -1226,7 +1230,7 @@ void multires_force_update(Object *ob)
}
}
struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, DerivedMesh *dm, Mesh *me,
struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int local_mmd, DerivedMesh *dm, Object *ob,
int useRenderParams, int isFinalCalc)
{
SubsurfModifierData smd;
@@ -1235,7 +1239,8 @@ struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, D
int i;
ms.mmd = mmd;
ms.me = me;
ms.ob = ob;
ms.local_mmd = local_mmd;
memset(&smd, 0, sizeof(SubsurfModifierData));
smd.levels = smd.renderLevels = mmd->lvl - 1;
+1 -1
View File
@@ -291,7 +291,7 @@ NlaStrip *add_nlastrip (bAction *act)
/* determine initial range
* - strip length cannot be 0... ever...
*/
calc_action_range(strip->act, &strip->actstart, &strip->actend, 1);
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
strip->start = strip->actstart;
strip->end = (IS_EQ(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f): (strip->actend);
+6 -9
View File
@@ -22,7 +22,7 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
* Contributor(s): Bob Holcomb.
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -950,9 +950,6 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id)
if(ntype->initfunc!=NULL)
ntype->initfunc(node);
if(type==TEX_NODE_OUTPUT)
ntreeTexAssignIndex(ntree, node);
nodeAddSockets(node, ntype);
return node;
@@ -1021,9 +1018,6 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal)
nnode->new_node= NULL;
nnode->preview= NULL;
if(node->type==TEX_NODE_OUTPUT)
ntreeTexAssignIndex(ntree, node);
return nnode;
}
@@ -2603,7 +2597,7 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
if(outsocket_exists(lnode->new_node, lsock->new_sock)) {
lsock->new_sock->ns.data= lsock->ns.data;
lsock->ns.data= NULL;
lsock->new_sock= NULL;
lsock->new_sock= NULL;
}
}
}
@@ -2938,6 +2932,7 @@ static void registerCompositNodes(ListBase *ntypelist)
nodeRegisterType(ntypelist, &cmp_node_viewer);
nodeRegisterType(ntypelist, &cmp_node_splitviewer);
nodeRegisterType(ntypelist, &cmp_node_output_file);
nodeRegisterType(ntypelist, &cmp_node_view_levels);
nodeRegisterType(ntypelist, &cmp_node_curve_rgb);
nodeRegisterType(ntypelist, &cmp_node_mix_rgb);
@@ -2977,7 +2972,9 @@ static void registerCompositNodes(ListBase *ntypelist)
nodeRegisterType(ntypelist, &cmp_node_premulkey);
nodeRegisterType(ntypelist, &cmp_node_diff_matte);
nodeRegisterType(ntypelist, &cmp_node_chroma);
nodeRegisterType(ntypelist, &cmp_node_distance_matte);
nodeRegisterType(ntypelist, &cmp_node_chroma_matte);
nodeRegisterType(ntypelist, &cmp_node_color_matte);
nodeRegisterType(ntypelist, &cmp_node_channel_matte);
nodeRegisterType(ntypelist, &cmp_node_color_spill);
nodeRegisterType(ntypelist, &cmp_node_luma_matte);
+108 -27
View File
@@ -101,13 +101,13 @@
#include "BKE_mball.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_property.h"
#include "BKE_sca.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_sculpt.h"
#include "BKE_softbody.h"
#include "LBM_fluidsim.h"
@@ -284,6 +284,7 @@ void free_object(Object *ob)
if(ob->adt) BKE_free_animdata((ID *)ob);
if(ob->poselib) ob->poselib->id.us--;
if(ob->dup_group) ob->dup_group->id.us--;
if(ob->gpd) ob->gpd->id.us--;
if(ob->defbase.first)
BLI_freelistN(&ob->defbase);
if(ob->pose)
@@ -307,6 +308,8 @@ void free_object(Object *ob)
if(ob->gpulamp.first) GPU_lamp_free(ob);
free_sculptsession(&ob->sculpt);
if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
}
static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin)
@@ -478,15 +481,15 @@ void unlink_object(Scene *scene, Object *ob)
if(tpsys->part->dup_ob==ob)
tpsys->part->dup_ob= NULL;
if(tpsys->part->flag&PART_STICKY) {
if(tpsys->part->phystype==PART_PHYS_BOIDS) {
ParticleData *pa;
BoidParticle *bpa;
int p;
for(p=0,pa=tpsys->particles; p<tpsys->totpart; p++,pa++) {
if(pa->stick_ob==ob) {
pa->stick_ob= 0;
pa->flag &= ~PARS_STICKY;
}
bpa = pa->boid;
if(bpa->ground == ob)
bpa->ground = NULL;
}
}
if(tpsys->part->boids) {
@@ -1016,6 +1019,8 @@ Object *add_only_object(int type, char *name)
ob->fluidsimFlag = 0;
ob->fluidsimSettings = NULL;
ob->pc_ids.first = ob->pc_ids.last = NULL;
return ob;
}
@@ -1077,34 +1082,44 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys)
{
ParticleSystem *psysn;
ParticleData *pa;
int a;
int p;
psysn= MEM_dupallocN(psys);
psysn->particles= MEM_dupallocN(psys->particles);
psysn->child= MEM_dupallocN(psys->child);
if(psysn->particles->keys)
psysn->particles->keys = MEM_dupallocN(psys->particles->keys);
for(a=0, pa=psysn->particles; a<psysn->totpart; a++, pa++) {
if(pa->hair)
pa->hair= MEM_dupallocN(pa->hair);
if(a)
pa->keys= (pa-1)->keys + (pa-1)->totkey;
if(psys->part->type == PART_HAIR) {
for(p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++)
pa->hair = MEM_dupallocN(pa->hair);
}
if(psys->soft) {
psysn->soft= copy_softbody(psys->soft);
psysn->soft->particles = psysn;
if(psysn->particles->keys || psysn->particles->boid) {
ParticleKey *key = psysn->particles->keys;
BoidParticle *boid = psysn->particles->boid;
if(key)
key = MEM_dupallocN(key);
if(boid)
boid = MEM_dupallocN(boid);
for(p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) {
if(boid)
pa->boid = boid++;
if(key) {
pa->keys = key;
key += pa->totkey;
}
}
}
if(psys->particles->boid) {
psysn->particles->boid = MEM_dupallocN(psys->particles->boid);
for(a=1, pa=psysn->particles+1; a<psysn->totpart; a++, pa++)
pa->boid = (pa-1)->boid + 1;
if(psys->clmd) {
ClothModifierData *nclmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)nclmd);
psys->hair_in_dm = psys->hair_out_dm = NULL;
}
if(psys->targets.first)
BLI_duplicatelist(&psysn->targets, &psys->targets);
BLI_duplicatelist(&psysn->targets, &psys->targets);
psysn->pathcache= NULL;
psysn->childcache= NULL;
@@ -1268,7 +1283,8 @@ Object *copy_object(Object *ob)
obn->derivedFinal = NULL;
obn->gpulamp.first = obn->gpulamp.last = NULL;
obn->pc_ids.first = obn->pc_ids.last = NULL;
return obn;
}
@@ -1630,7 +1646,7 @@ int enable_cu_speed= 1;
static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
{
Curve *cu;
float q[4], vec[4], dir[3], quat[4], x1, ctime;
float q[4], vec[4], dir[3], quat[4], radius, x1, ctime;
float timeoffs = 0.0, sf_orig = 0.0;
Mat4One(mat);
@@ -1678,7 +1694,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
/* vec: 4 items! */
if( where_on_path(par, ctime, vec, dir) ) {
if( where_on_path(par, ctime, vec, dir, NULL, &radius) ) {
if(cu->flag & CU_FOLLOW) {
vectoquat(dir, ob->trackflag, ob->upflag, quat);
@@ -1695,6 +1711,13 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
QuatToMat4(quat, mat);
}
if(cu->flag & CU_PATH_RADIUS) {
float tmat[4][4], rmat[4][4];
Mat4Scale(tmat, radius);
Mat4MulMat4(rmat, mat, tmat);
Mat4CpyMat4(mat, rmat);
}
VECCOPY(mat[3], vec);
}
@@ -1792,7 +1815,7 @@ static void give_parvert(Object *par, int nr, float *vec)
count= 0;
while(nu && !found) {
if((nu->type & 7)==CU_BEZIER) {
if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
@@ -2535,3 +2558,61 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
return result;
}
static int pc_cmp(void *a, void *b)
{
LinkData *ad = a, *bd = b;
if((int)ad->data > (int)bd->data)
return 1;
else return 0;
}
int object_insert_ptcache(Object *ob)
{
LinkData *link = NULL;
int i = 0;
BLI_sortlist(&ob->pc_ids, pc_cmp);
for(link=ob->pc_ids.first, i = 0; link; link=link->next, i++)
{
int index =(int)link->data;
if(i < index)
break;
}
link = MEM_callocN(sizeof(LinkData), "PCLink");
link->data = (void *)i;
BLI_addtail(&ob->pc_ids, link);
return i;
}
#if 0
static int pc_findindex(ListBase *listbase, int index)
{
LinkData *link= NULL;
int number= 0;
if (listbase == NULL) return -1;
link= listbase->first;
while (link) {
if ((int)link->data == index)
return number;
number++;
link= link->next;
}
return -1;
}
void object_delete_ptcache(Object *ob, int index)
{
int list_index = pc_findindex(&ob->pc_ids, index);
LinkData *link = BLI_findlink(&ob->pc_ids, list_index);
BLI_freelinkN(&ob->pc_ids, link);
}
#endif
@@ -63,6 +63,14 @@
#include "BKE_packedFile.h"
#include "BKE_report.h"
#ifdef _WIN32
#define open _open
#define close _close
#define read _read
#define write _write
#endif
int seekPackedFile(PackedFile *pf, int offset, int whence)
{
int oldseek = -1, seek = 0;
@@ -473,7 +481,7 @@ int unpackSound(ReportList *reports, bSound *sound, int how)
freePackedFile(sound->packedfile);
sound->packedfile = 0;
sound_load(sound);
sound_load(NULL, sound);
ret_value = RET_OK;
}
+10 -2
View File
@@ -39,6 +39,11 @@
#include <stdlib.h>
#include <string.h>
const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100};
const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255};
const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255};
const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
Paint *paint_get_active(Scene *sce)
{
if(sce && sce->basact && sce->basact->object) {
@@ -154,14 +159,17 @@ int paint_facesel_test(Object *ob)
}
void paint_init(Paint *p, const char *name)
void paint_init(Paint *p, const char col[3])
{
Brush *brush;
/* If there's no brush, create one */
brush = paint_brush(p);
brush_check_exists(&brush, name);
brush_check_exists(&brush, "Brush");
paint_brush_set(p, brush);
memcpy(p->paint_cursor_col, col, 3);
p->paint_cursor_col[3] = 128;
}
void free_paint(Paint *paint)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+330 -130
View File
@@ -59,26 +59,21 @@
#include "BLI_blenlib.h"
/* both in intern */
#include "smoke_API.h"
#include "minilzo.h"
#include "LzmaLib.h"
/* needed for directory lookup */
/* untitled blend's need getpid for a unique name */
#ifndef WIN32
#include <dirent.h>
#else
#include "BLI_winstuff.h"
#endif
/* untitled blend's need getpid for a unique name */
#ifdef WIN32
#include <process.h>
#else
#include <unistd.h>
#endif
#ifdef _WIN32
#ifndef snprintf
#define snprintf _snprintf
#endif
#else
#include <process.h>
#include "BLI_winstuff.h"
#endif
static void ptcache_data_to(void **data, int type, int index, void *to);
@@ -176,6 +171,7 @@ static int ptcache_write_particle(int index, void *psys_v, void **data)
{
ParticleSystem *psys= psys_v;
ParticleData *pa = psys->particles + index;
BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL;
float times[3] = {pa->time, pa->dietime, pa->lifetime};
if(data[BPHYS_DATA_INDEX]) {
@@ -193,8 +189,8 @@ static int ptcache_write_particle(int index, void *psys_v, void **data)
ptcache_data_from(data, BPHYS_DATA_SIZE, &pa->size);
ptcache_data_from(data, BPHYS_DATA_TIMES, times);
if(pa->boid)
ptcache_data_from(data, BPHYS_DATA_TIMES, &pa->boid);
if(boid)
ptcache_data_from(data, BPHYS_DATA_BOIDS, &boid->data);
return 1;
}
@@ -210,6 +206,7 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr
{
ParticleSystem *psys= psys_v;
ParticleData *pa = psys->particles + index;
BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL;
if(cfra > pa->state.time)
memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey));
@@ -233,8 +230,8 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr
pa->lifetime = times[2];
}
if(pa->boid)
ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &pa->boid);
if(boid)
ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &boid->data);
/* determine velocity from previous location */
if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) {
@@ -385,10 +382,6 @@ static int ptcache_totpoint_cloth(void *cloth_v)
/* Creating ID's */
void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
{
ParticleSystemModifierData *psmd;
ModifierData *md;
int a;
memset(pid, 0, sizeof(PTCacheID));
pid->ob= ob;
@@ -411,34 +404,24 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY);
pid->info_types= 0;
if(sb->particles) {
psmd= psys_get_modifier(ob, sb->particles);
pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd);
}
else {
for(a=0, md=ob->modifiers.first; md; md=md->next, a++) {
if(md->type == eModifierType_Softbody) {
pid->stack_index = a;
break;
}
}
}
pid->stack_index = pid->cache->index;
}
void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
memset(pid, 0, sizeof(PTCacheID));
pid->ob= ob;
pid->calldata= psys;
pid->type= PTCACHE_TYPE_PARTICLES;
pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd);
pid->stack_index= psys->pointcache->index;
pid->cache= psys->pointcache;
pid->cache_ptr= &psys->pointcache;
pid->ptcaches= &psys->ptcaches;
if(psys->part->type != PART_HAIR)
pid->flag |= PTCACHE_VEL_PER_SEC;
pid->write_elem= ptcache_write_particle;
pid->write_stream = NULL;
pid->read_stream = NULL;
@@ -469,76 +452,254 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
pid->info_types= (1<<BPHYS_DATA_TIMES);
}
#if 0 // XXX smoke pointcache stuff breaks compiling now
/* Smoke functions */
static int ptcache_totpoint_smoke(void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if(sds->fluid)
{
if(sds->fluid) {
return sds->res[0]*sds->res[1]*sds->res[2];
}
else
return 0;
}
/* Smoke functions */
static int ptcache_totpoint_smoke_turbulence(void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if(sds->wt) {
return sds->res_wt[0]*sds->res_wt[1]*sds->res_wt[2];
}
else
return 0;
}
// forward decleration
static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size);
static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode)
{
int r = 0;
unsigned char compressed;
LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
unsigned int out_len = LZO_OUT_LEN(in_len);
unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
size_t sizeOfIt = 5;
if(mode == 1) {
r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);
if (!(r == LZO_E_OK) || (out_len >= in_len))
compressed = 0;
else
compressed = 1;
}
else if(mode == 2) {
r = LzmaCompress(out, (size_t *)&out_len, in, in_len,//assume sizeof(char)==1....
props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2);
if(!(r == SZ_OK) || (out_len >= in_len))
compressed = 0;
else
compressed = 2;
}
ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char));
if(compressed) {
ptcache_file_write(pf, &out_len, 1, sizeof(unsigned int));
ptcache_file_write(pf, out, out_len, sizeof(unsigned char));
}
else
ptcache_file_write(pf, in, in_len, sizeof(unsigned char));
if(compressed == 2)
{
ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int));
ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char));
}
MEM_freeN(props);
return r;
}
static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if(sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
unsigned char *obstacles;
unsigned int in_len = sizeof(float)*(unsigned int)res;
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
int mode = res >= 1000000 ? 2 : 1;
smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
ptcache_compress_write(pf, (unsigned char *)sds->shadow, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)dens, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)densold, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)heat, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)heatold, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)vx, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)vy, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)vz, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)vxold, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)vyold, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)vzold, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode);
ptcache_file_write(pf, &dt, 1, sizeof(float));
ptcache_file_write(pf, &dx, 1, sizeof(float));
MEM_freeN(out);
return 1;
}
return 0;
}
static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if(sds->fluid)
{
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
float *dens, *densold, *heat, *heatold, *vx, *vy, *vz;
smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz);
ptcache_file_write(pf, dens, res, sizeof(float));
ptcache_file_write(pf, densold, res, sizeof(float));
ptcache_file_write(pf, heat, res, sizeof(float));
ptcache_file_write(pf, heatold, res, sizeof(float));
ptcache_file_write(pf, vx, res, sizeof(float));
ptcache_file_write(pf, vy, res, sizeof(float));
ptcache_file_write(pf, vz, res, sizeof(float));
if(sds->wt) {
unsigned int res_big_array[3];
unsigned int res_big;
unsigned int res = sds->res[0]*sds->res[1]*sds->res[2];
float *dens, *densold, *tcu, *tcv, *tcw;
unsigned int in_len = sizeof(float)*(unsigned int)res;
unsigned int in_len_big;
unsigned char *out;
int mode;
smoke_turbulence_get_res(sds->wt, res_big_array);
res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
mode = res_big >= 1000000 ? 2 : 1;
in_len_big = sizeof(float) * (unsigned int)res_big;
smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer");
ptcache_compress_write(pf, (unsigned char *)dens, in_len_big, out, mode);
ptcache_compress_write(pf, (unsigned char *)densold, in_len_big, out, mode);
MEM_freeN(out);
out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer");
ptcache_compress_write(pf, (unsigned char *)tcu, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)tcv, in_len, out, mode);
ptcache_compress_write(pf, (unsigned char *)tcw, in_len, out, mode);
MEM_freeN(out);
return 1;
}
return 0;
}
// forward decleration
static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size);
static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigned int len)
{
int r = 0;
unsigned char compressed = 0;
unsigned int in_len;
unsigned int out_len = len;
unsigned char *in;
unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
size_t sizeOfIt = 5;
ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
if(compressed) {
ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int));
in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer");
ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
if(compressed == 1)
r = lzo1x_decompress(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
else if(compressed == 2)
{
size_t leni = in_len, leno = out_len;
ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int));
ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char));
r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt);
}
MEM_freeN(in);
}
else {
ptcache_file_read(pf, result, len, sizeof(unsigned char));
}
MEM_freeN(props);
return r;
}
static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if(sds->fluid)
{
if(sds->fluid) {
size_t res = sds->res[0]*sds->res[1]*sds->res[2];
float *dens, *densold, *heat, *heatold, *vx, *vy, *vz;
float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold;
unsigned char *obstacles;
unsigned int out_len = (unsigned int)res * sizeof(float);
smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz);
smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
ptcache_file_read(pf, dens, res, sizeof(float));
ptcache_file_read(pf, densold, res, sizeof(float));
ptcache_file_read(pf, heat, res, sizeof(float));
ptcache_file_read(pf, heatold, res, sizeof(float));
ptcache_file_read(pf, vx, res, sizeof(float));
ptcache_file_read(pf, vy, res, sizeof(float));
ptcache_file_read(pf, vz, res, sizeof(float));
ptcache_compress_read(pf, (unsigned char *)sds->shadow, out_len);
ptcache_compress_read(pf, (unsigned char*)dens, out_len);
ptcache_compress_read(pf, (unsigned char*)densold, out_len);
ptcache_compress_read(pf, (unsigned char*)heat, out_len);
ptcache_compress_read(pf, (unsigned char*)heatold, out_len);
ptcache_compress_read(pf, (unsigned char*)vx, out_len);
ptcache_compress_read(pf, (unsigned char*)vy, out_len);
ptcache_compress_read(pf, (unsigned char*)vz, out_len);
ptcache_compress_read(pf, (unsigned char*)vxold, out_len);
ptcache_compress_read(pf, (unsigned char*)vyold, out_len);
ptcache_compress_read(pf, (unsigned char*)vzold, out_len);
ptcache_compress_read(pf, (unsigned char*)obstacles, (unsigned int)res);
ptcache_file_read(pf, &dt, 1, sizeof(float));
ptcache_file_read(pf, &dx, 1, sizeof(float));
}
}
void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num)
static void ptcache_read_smoke_turbulence(PTCacheFile *pf, void *smoke_v)
{
SmokeModifierData *smd= (SmokeModifierData *)smoke_v;
SmokeDomainSettings *sds = smd->domain;
if(sds->fluid) {
unsigned int res = sds->res[0]*sds->res[1]*sds->res[2];
unsigned int res_big, res_big_array[3];
float *dens, *densold, *tcu, *tcv, *tcw;
unsigned int out_len = sizeof(float)*(unsigned int)res;
unsigned int out_len_big;
smoke_turbulence_get_res(sds->wt, res_big_array);
res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
out_len_big = sizeof(float) * (unsigned int)res_big;
smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
ptcache_compress_read(pf, (unsigned char*)dens, out_len_big);
ptcache_compress_read(pf, (unsigned char*)densold, out_len_big);
ptcache_compress_read(pf, (unsigned char*)tcu, out_len);
ptcache_compress_read(pf, (unsigned char*)tcv, out_len);
ptcache_compress_read(pf, (unsigned char*)tcw, out_len);
}
}
void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
{
SmokeDomainSettings *sds = smd->domain;
@@ -547,24 +708,54 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
pid->ob= ob;
pid->calldata= smd;
// if(num == 0)
pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_LOW;
// else if(num == 1)
// pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_HIGH;
pid->type= PTCACHE_TYPE_SMOKE_DOMAIN;
pid->stack_index= sds->point_cache[0]->index;
pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)smd);
pid->cache= sds->point_cache[0];
pid->cache_ptr= &(sds->point_cache[0]);
pid->ptcaches= &(sds->ptcaches[0]);
pid->cache= sds->point_cache;
pid->cache_ptr= &sds->point_cache;
pid->ptcaches= &sds->ptcaches;
pid->totpoint= pid->totwrite= ptcache_totpoint_smoke;
pid->write_elem= NULL;
pid->read_elem= NULL;
pid->read_stream = ptcache_read_smoke;
pid->write_stream = ptcache_write_smoke;
pid->interpolate_elem= NULL;
pid->write_header= ptcache_write_basic_header;
pid->read_header= ptcache_read_basic_header;
pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values to make pointcache happy
pid->info_types= 0;
}
void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
{
SmokeDomainSettings *sds = smd->domain;
memset(pid, 0, sizeof(PTCacheID));
pid->ob= ob;
pid->calldata= smd;
pid->type= PTCACHE_TYPE_SMOKE_HIGHRES;
pid->stack_index= sds->point_cache[1]->index;
pid->cache= sds->point_cache[1];
pid->cache_ptr= &sds->point_cache[1];
pid->ptcaches= &sds->ptcaches[1];
pid->totpoint= pid->totwrite= ptcache_totpoint_smoke_turbulence;
pid->write_elem= NULL;
pid->read_elem= NULL;
pid->read_stream = ptcache_read_smoke_turbulence;
pid->write_stream = ptcache_write_smoke_turbulence;
pid->interpolate_elem= NULL;
pid->write_header= ptcache_write_basic_header;
@@ -573,7 +764,6 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values tot make pointcache happy
pid->info_types= 0;
}
#endif // XXX smoke poitcache stuff breaks compiling
void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd)
{
@@ -582,7 +772,7 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl
pid->ob= ob;
pid->calldata= clmd;
pid->type= PTCACHE_TYPE_CLOTH;
pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)clmd);
pid->stack_index= clmd->point_cache->index;
pid->cache= clmd->point_cache;
pid->cache_ptr= &clmd->point_cache;
pid->ptcaches= &clmd->ptcaches;
@@ -616,13 +806,9 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob)
}
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_particles(pid, ob, psys);
BLI_addtail(lb, pid);
if(psys->soft) {
if(psys->part) {
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_softbody(pid, ob, psys->soft);
BKE_ptcache_id_from_particles(pid, ob, psys);
BLI_addtail(lb, pid);
}
}
@@ -633,18 +819,19 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob)
BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md);
BLI_addtail(lb, pid);
}
/*
// enabled on next commit
if(md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md, 0);
BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md);
BLI_addtail(lb, pid);
pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID");
BKE_ptcache_id_from_smoke_turbulence(pid, ob, (SmokeModifierData*)md);
BLI_addtail(lb, pid);
}
}
*/
}
}
@@ -728,6 +915,10 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho
}
if (do_ext) {
if(pid->cache->index < 0)
pid->cache->index = pid->stack_index = object_insert_ptcache(pid->ob);
if(pid->cache->flag & PTCACHE_EXTERNAL) {
if(pid->cache->index >= 0)
snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */
@@ -902,7 +1093,7 @@ static void ptcache_file_init_pointers(PTCacheFile *pf)
pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<<BPHYS_DATA_BOIDS) ? &pf->data.boids : NULL;
}
static void ptcache_mem_init_pointers(PTCacheMem *pm)
void BKE_ptcache_mem_init_pointers(PTCacheMem *pm)
{
int data_types = pm->data_types;
int i;
@@ -911,7 +1102,7 @@ static void ptcache_mem_init_pointers(PTCacheMem *pm)
pm->cur[i] = data_types & (1<<i) ? pm->data[i] : NULL;
}
static void ptcache_mem_incr_pointers(PTCacheMem *pm)
void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm)
{
int i;
@@ -977,7 +1168,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
int cfra1 = 0, cfra2 = 0;
int totpoint = 0, totpoint2 = 0;
int *index = &i, *index2 = &i;
int use_old = 0, old_frame;
int use_old = 0, old_frame = 0;
int ret = 0, error = 0;
@@ -1064,12 +1255,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
return 0;
if(pm) {
ptcache_mem_init_pointers(pm);
BKE_ptcache_mem_init_pointers(pm);
totpoint = pm->totpoint;
index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i;
}
if(pm2) {
ptcache_mem_init_pointers(pm2);
BKE_ptcache_mem_init_pointers(pm2);
totpoint2 = pm2->totpoint;
index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i;
}
@@ -1140,18 +1331,18 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
if(use_old) {
if(pid->read_elem && ptcache_file_read(pf, (void*)old_data1, 1, old_elemsize))
pid->read_elem(i, pid->calldata, NULL, frs_sec, cfra, old_data1);
else
else if(pid->read_elem)
{ error = 1; break; }
}
else {
if(pid->read_elem && (pm || ptcache_file_read_data(pf)))
pid->read_elem(*index, pid->calldata, pm ? pm->cur : pf->cur, frs_sec, cfra1 ? (float)cfra1 : (float)cfrai, NULL);
else
else if(pid->read_elem)
{ error = 1; break; }
}
if(pm) {
ptcache_mem_incr_pointers(pm);
BKE_ptcache_mem_incr_pointers(pm);
index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i;
}
}
@@ -1185,7 +1376,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
else
{ error = 1; break; }
}
else
else if(pid->read_elem)
{ error = 1; break; }
}
else {
@@ -1197,12 +1388,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec)
else
{ error = 1; break; }
}
else
else if(pid->read_elem)
{ error = 1; break; }
}
if(pm2) {
ptcache_mem_incr_pointers(pm2);
BKE_ptcache_mem_incr_pointers(pm2);
index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i;
}
}
@@ -1374,11 +1565,11 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra)
pm->data_types = cfra ? pid->data_types : pid->info_types;
ptcache_alloc_data(pm);
ptcache_mem_init_pointers(pm);
BKE_ptcache_mem_init_pointers(pm);
for(i=0; i<totpoint; i++) {
if(pid->write_elem && pid->write_elem(i, pid->calldata, pm->cur))
ptcache_mem_incr_pointers(pm);
BKE_ptcache_mem_incr_pointers(pm);
}
//ptcache_make_index_array(pm, pid->totpoint(pid->calldata));
@@ -1479,6 +1670,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra)
PTCacheMem *pm= pid->cache->mem_cache.first;
PTCacheMem *link= NULL;
pm= pid->cache->mem_cache.first;
if(mode == PTCACHE_CLEAR_ALL) {
pid->cache->last_exact = 0;
for(; pm; pm=pm->next)
@@ -1623,9 +1816,10 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
else if(mode == PTCACHE_RESET_OUTDATED) {
reset = 1;
if(cache->flag & PTCACHE_OUTDATED)
if(!(cache->flag & PTCACHE_BAKED))
clear= 1;
if(cache->flag & PTCACHE_OUTDATED && !(cache->flag & PTCACHE_BAKED)) {
clear= 1;
cache->flag &= ~PTCACHE_OUTDATED;
}
}
if(reset) {
@@ -1639,8 +1833,10 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
sbFreeSimulation(pid->calldata);
else if(pid->type == PTCACHE_TYPE_PARTICLES)
psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH);
else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN_LOW)
else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
smokeModifier_reset(pid->calldata);
else if(pid->type == PTCACHE_TYPE_SMOKE_HIGHRES)
smokeModifier_reset_turbulence(pid->calldata);
}
if(clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
@@ -1666,10 +1862,10 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
}
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
/* Baked softbody hair has to be checked first, because we don't want to reset */
/* particles or softbody in that case -jahka */
if(psys->soft) {
BKE_ptcache_id_from_softbody(&pid, ob, psys->soft);
/* Baked cloth hair has to be checked first, because we don't want to reset */
/* particles or cloth in that case -jahka */
if(psys->clmd) {
BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd);
if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED)))
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
else
@@ -1678,7 +1874,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
else if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD)
skip = 1;
if(skip == 0) {
if(skip == 0 && psys->part) {
BKE_ptcache_id_from_particles(&pid, ob, psys);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
@@ -1689,17 +1885,17 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
/*
// enabled on next commit
if(md->type == eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData *)md;
if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
{
BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md, 0);
BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
BKE_ptcache_id_from_smoke_turbulence(&pid, ob, (SmokeModifierData*)md);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
*/
}
return reset;
@@ -1759,7 +1955,7 @@ void BKE_ptcache_set_continue_physics(Scene *scene, int enable)
if(CONTINUE_PHYSICS == 0) {
for(ob=G.main->object.first; ob; ob=ob->id.next)
if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED))
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
}
}
}
@@ -1779,15 +1975,16 @@ PointCache *BKE_ptcache_add(ListBase *ptcaches)
cache->startframe= 1;
cache->endframe= 250;
cache->step= 10;
cache->index = -1;
BLI_addtail(ptcaches, cache);
return cache;
}
void BKE_ptache_free_mem(PointCache *cache)
void BKE_ptcache_free_mem(ListBase *mem_cache)
{
PTCacheMem *pm = cache->mem_cache.first;
PTCacheMem *pm = mem_cache->first;
if(pm) {
for(; pm; pm=pm->next) {
@@ -1796,22 +1993,25 @@ void BKE_ptache_free_mem(PointCache *cache)
MEM_freeN(pm->index_array);
}
BLI_freelistN(&cache->mem_cache);
BLI_freelistN(mem_cache);
}
}
void BKE_ptcache_free(PointCache *cache)
{
BKE_ptache_free_mem(cache);
BKE_ptcache_free_mem(&cache->mem_cache);
if(cache->edit && cache->free_edit)
cache->free_edit(cache->edit);
MEM_freeN(cache);
}
void BKE_ptcache_free_list(ListBase *ptcaches)
{
PointCache *cache = ptcaches->first;
for(; cache; cache=cache->next)
BKE_ptache_free_mem(cache);
BLI_freelistN(ptcaches);
while(cache) {
BLI_remlink(ptcaches, cache);
BKE_ptcache_free(cache);
cache = ptcaches->first;
}
}
static PointCache *ptcache_copy(PointCache *cache)
@@ -1901,7 +2101,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
Base *base;
ListBase pidlist;
PTCacheID *pid = baker->pid;
PointCache *cache;
PointCache *cache = NULL;
float frameleno = scene->r.framelen;
int cfrao = CFRA;
int startframe = MAXFRAME;
@@ -2075,7 +2275,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid)
pm->frame = cfra;
ptcache_alloc_data(pm);
ptcache_mem_init_pointers(pm);
BKE_ptcache_mem_init_pointers(pm);
ptcache_file_init_pointers(pf);
for(i=0; i<pm->totpoint; i++) {
@@ -2091,7 +2291,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid)
return;
}
ptcache_copy_data(pf->cur, pm->cur);
ptcache_mem_incr_pointers(pm);
BKE_ptcache_mem_incr_pointers(pm);
}
//ptcache_make_index_array(pm, pid->totpoint(pid->calldata));
@@ -2122,7 +2322,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
pf->totpoint = pm->totpoint;
pf->type = pid->type;
ptcache_mem_init_pointers(pm);
BKE_ptcache_mem_init_pointers(pm);
ptcache_file_init_pointers(pf);
if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) {
@@ -2142,7 +2342,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
ptcache_file_close(pf);
return;
}
ptcache_mem_incr_pointers(pm);
BKE_ptcache_mem_incr_pointers(pm);
}
ptcache_file_close(pf);
-26
View File
@@ -52,30 +52,6 @@
#include "BKE_blender.h"
#include "BKE_sca.h"
//#include "wm_event_types.h"
void free_text_controllers(Text *txt)
{
Object *ob;
bController *cont;
ob= G.main->object.first;
while(ob) {
cont= ob->controllers.first;
while(cont) {
if(cont->type==CONT_PYTHON) {
bPythonCont *pc;
pc= cont->data;
if(pc->text==txt) pc->text= NULL;
}
cont= cont->next;
}
ob= ob->id.next;
}
}
/* ******************* SENSORS ************************ */
void free_sensor(bSensor *sens)
@@ -418,12 +394,10 @@ void init_actuator(bActuator *act)
act->data= 0;
switch(act->type) {
#ifdef __NLA
case ACT_ACTION:
case ACT_SHAPEACTION:
act->data= MEM_callocN(sizeof(bActionActuator), "actionact");
break;
#endif
case ACT_SOUND:
sa = act->data= MEM_callocN(sizeof(bSoundActuator), "soundact");
sa->volume = 1.0f;
+15 -12
View File
@@ -155,6 +155,7 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type)
scen->theDag= NULL;
scen->obedit= NULL;
scen->toolsettings= MEM_dupallocN(sce->toolsettings);
scen->stats= NULL;
ts= scen->toolsettings;
if(ts) {
@@ -244,6 +245,11 @@ void free_scene(Scene *sce)
base= base->next;
}
/* do not free objects! */
if(sce->gpd) {
sce->gpd->id.us--;
sce->gpd= NULL;
}
BLI_freelistN(&sce->base);
seq_free_editing(sce);
@@ -299,6 +305,9 @@ void free_scene(Scene *sce)
ntreeFreeTree(sce->nodetree);
MEM_freeN(sce->nodetree);
}
if(sce->stats)
MEM_freeN(sce->stats);
}
Scene *add_scene(char *name)
@@ -395,11 +404,13 @@ Scene *add_scene(char *name)
sce->unit.scale_length = 1.0f;
pset= &sce->toolsettings->particle;
pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER|PE_AUTO_VELOCITY;
pset->emitterdist= 0.25f;
pset->totrekey= 5;
pset->totaddkey= 5;
pset->brushtype= PE_BRUSH_NONE;
pset->draw_step= 2;
pset->fade_frames= 2;
for(a=0; a<PE_TOT_BRUSH; a++) {
pset->brush[a].strength= 50;
pset->brush[a].size= 50;
@@ -442,6 +453,9 @@ Scene *add_scene(char *name)
sce->gm.physubstep = 1;
sce->gm.maxphystep = 5;
sce->gm.flag = GAME_DISPLAY_LISTS;
sce->gm.matmode = GAME_MAT_MULTITEX;
return sce;
}
@@ -846,14 +860,3 @@ float get_render_aosss_error(RenderData *r, float error)
return error;
}
void free_dome_warp_text(struct Text *txt)
{
Scene *scene;
scene = G.main->scene.first;
while(scene) {
if (scene->r.dometext == txt)
scene->r.dometext = NULL;
scene = scene->id.next;
}
}
@@ -2792,6 +2792,10 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
if (!(force || seq->len != v->length || !v->frameMap)) {
return;
}
if (!seq->seq1) { /* make coverity happy and check for (CID 598)
input strip ... */
return;
}
if (!v->frameMap || v->length != seq->len) {
if (v->frameMap) MEM_freeN(v->frameMap);
@@ -2807,7 +2811,7 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
/* if there is no IPO, try to make retiming easy by stretching the
strip */
// XXX old animation system - seq
if (/*!seq->ipo &&*/ seq->seq1 && seq->seq1->enddisp != seq->seq1->start
if (/*!seq->ipo &&*/ seq->seq1->enddisp != seq->seq1->start
&& seq->seq1->len != 0) {
fallback_fac = (float) seq->seq1->len /
(float) (seq->seq1->enddisp - seq->seq1->start);
+1 -1
View File
@@ -570,7 +570,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq)
}
seq->strip->len = seq->len;
} else if (seq->type == SEQ_SOUND) {
seq->len = AUD_getInfo(seq->sound->snd_sound).length * FPS;
seq->len = AUD_getInfo(seq->sound->handle).length * FPS;
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
if (seq->len < 0) {
@@ -574,7 +574,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object
}
}
//Just to make sure we are not letting any memory behind
//Just to make sure we are not leaving any memory behind
assert(ssmd.emCache == NULL);
assert(ssmd.mCache == NULL);
}
File diff suppressed because it is too large Load Diff
+70 -256
View File
@@ -58,7 +58,6 @@ variables on the UI for now
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h" /* here is the softbody struct */
#include "DNA_particle_types.h"
#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -76,7 +75,6 @@ variables on the UI for now
#include "BKE_global.h"
#include "BKE_key.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_softbody.h"
#include "BKE_utildefines.h"
#include "BKE_DerivedMesh.h"
@@ -494,32 +492,21 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h
while (base) {
/*Only proceed for mesh object in same layer */
if(base->object->type==OB_MESH && (base->lay & vertexowner->lay)) {
int particles=0;
ob= base->object;
if((vertexowner) && (ob == vertexowner)) {
if(vertexowner->soft->particles){
particles=1;
}
else {
/* if vertexowner is given we don't want to check collision with owner object */
base = base->next;
continue;
}
/* if vertexowner is given we don't want to check collision with owner object */
base = base->next;
continue;
}
/*+++ only with deflecting set */
if(ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == 0) {
DerivedMesh *dm= NULL;
if(particles) {
dm = psys_get_modifier(ob,psys_get_current(ob))->dm;
}
else {
if(ob->softflag & OB_SB_COLLFINAL) /* so maybe someone wants overkill to collide with subsurfed */
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
else
dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
}
if(ob->softflag & OB_SB_COLLFINAL) /* so maybe someone wants overkill to collide with subsurfed */
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
else
dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
if(dm){
ccd_Mesh *ccdmesh = ccd_mesh_make(ob, dm);
@@ -866,7 +853,8 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring
bp->frozen = 1.0f;
bp->colball = 0.0f;
bp->flag = 0;
bp->springweight = 1.0f;
bp->mass = sb->nodemass;
}
}
}
@@ -3570,107 +3558,6 @@ static void curve_surf_to_softbody(Scene *scene, Object *ob)
}
}
static void springs_from_particles(Object *ob)
{
ParticleSystem *psys;
ParticleSystemModifierData *psmd=0;
ParticleData *pa=0;
HairKey *key=0;
SoftBody *sb;
BodyPoint *bp;
BodySpring *bs;
int a,k;
float hairmat[4][4];
if(ob && ob->soft && ob->soft->particles) {
psys= ob->soft->particles;
sb= ob->soft;
psmd = psys_get_modifier(ob, psys);
bp= sb->bpoint;
for(a=0, pa=psys->particles; a<psys->totpart; a++, pa++) {
for(k=0, key=pa->hair; k<pa->totkey; k++, bp++, key++) {
VECCOPY(bp->origS, key->co);
psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat);
Mat4MulVecfl(hairmat, bp->origS);
}
}
for(a=0, bs=sb->bspring; a<sb->totspring; a++, bs++)
bs->len= VecLenf(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS);
}
}
static void particles_to_softbody(Scene *scene, Object *ob)
{
SoftBody *sb;
BodyPoint *bp;
BodySpring *bs;
ParticleData *pa;
HairKey *key;
ParticleSystem *psys= ob->soft->particles;
float goalfac;
int a, k, curpoint;
int totpoint= psys_count_keys(psys);
int totedge= totpoint-psys->totpart;
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
renew_softbody(scene, ob, totpoint, totedge);
/* find first BodyPoint index for each particle */
if(psys->totpart > 0) {
psys->particles->bpi = 0;
for(a=1, pa=psys->particles+1; a<psys->totpart; a++, pa++)
pa->bpi = (pa-1)->bpi + (pa-1)->totkey;
}
/* we always make body points */
sb= ob->soft;
bp= sb->bpoint;
bs= sb->bspring;
goalfac= ABS(sb->maxgoal - sb->mingoal);
if((ob->softflag & OB_SB_GOAL)) {
for(a=0, pa=psys->particles; a<psys->totpart; a++, pa++) {
for(k=0, key=pa->hair; k<pa->totkey; k++,bp++,key++) {
if(k) {
bp->goal= key->weight;
bp->goal= sb->mingoal + bp->goal*goalfac;
bp->goal= (float)pow(bp->goal, 4.0f);
}
else{
/* hair roots are allways fixed fully to goal */
bp->goal= 1.0f;
}
}
}
}
bp= sb->bpoint;
curpoint=0;
for(a=0, pa=psys->particles; a<psys->totpart; a++, curpoint++, pa++) {
for(k=0; k<pa->totkey-1; k++,bs++,curpoint++) {
bs->v1=curpoint;
bs->v2=curpoint+1;
bs->strength= 1.0;
bs->order=1;
}
}
build_bps_springlist(ob); /* scan for springs attached to bodypoints ONCE */
/* insert *other second order* springs if desired */
if(sb->secondspring > 0.0000001f) {
add_2nd_order_springs(ob,sb->secondspring*10.0); /* exploits the the first run of build_bps_springlist(ob);*/
build_bps_springlist(ob); /* yes we need to do it again*/
}
springs_from_particles(ob); /* write the 'rest'-lenght of the springs */
if(ob->softflag & OB_SB_SELF)
calculate_collision_balls(ob);
}
/* copies softbody result back in object */
static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int local)
{
@@ -3794,44 +3681,16 @@ void sbSetInterruptCallBack(int (*f)(void))
static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCos)[3], int numVerts)
{
ParticleSystemModifierData *psmd= NULL;
ParticleData *pa= NULL;
HairKey *key= NULL;
BodyPoint *bp;
float hairmat[4][4];
int a;
/* update the vertex locations */
if(sb->particles && sb->particles->totpart>0) {
psmd= psys_get_modifier(ob,sb->particles);
pa= sb->particles->particles;
key= pa->hair;
psys_mat_hair_to_global(ob, psmd->dm, sb->particles->part->from, pa, hairmat);
}
for(a=0,bp=sb->bpoint; a<numVerts; a++, bp++) {
/* store where goals are now */
VECCOPY(bp->origS, bp->origE);
/* copy the position of the goals at desired end time */
if(sb->particles) {
if(key == pa->hair + pa->totkey) {
pa++;
key = pa->hair;
psys_mat_hair_to_global(ob, psmd->dm, sb->particles->part->from, pa, hairmat);
}
VECCOPY(bp->origE, key->co);
Mat4MulVecfl(hairmat,bp->origE);
key++;
}
else{
VECCOPY(bp->origE, vertexCos[a]);
/* vertexCos came from local world, go global */
Mat4MulVecfl(ob->obmat, bp->origE);
}
VECCOPY(bp->origE, vertexCos[a]);
/* vertexCos came from local world, go global */
Mat4MulVecfl(ob->obmat, bp->origE);
/* just to be save give bp->origT a defined value
will be calulated in interpolate_exciter()*/
VECCOPY(bp->origT, bp->origE);
@@ -3840,37 +3699,12 @@ static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCo
static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int numVerts)
{
ParticleSystemModifierData *psmd= NULL;
HairKey *key= NULL;
ParticleData *pa= NULL;
BodyPoint *bp;
float hairmat[4][4];
int a;
if(sb->particles && sb->particles->totpart>0) {
psmd= psys_get_modifier(ob, sb->particles);
pa= sb->particles->particles;
key= pa->hair;
psys_mat_hair_to_global(ob, psmd->dm, sb->particles->part->from, pa, hairmat);
}
for(a=0,bp=sb->bpoint; a<numVerts; a++, bp++) {
if(sb->particles) {
if(key == pa->hair + pa->totkey) {
pa++;
key = pa->hair;
psys_mat_hair_to_global(ob, psmd->dm, sb->particles->part->from, pa, hairmat);
}
VECCOPY(bp->pos, key->co);
Mat4MulVecfl(hairmat, bp->pos);
key++;
}
else {
VECCOPY(bp->pos, vertexCos[a]);
Mat4MulVecfl(ob->obmat, bp->pos); /* yep, sofbody is global coords*/
}
VECCOPY(bp->pos, vertexCos[a]);
Mat4MulVecfl(ob->obmat, bp->pos); /* yep, sofbody is global coords*/
VECCOPY(bp->origS, bp->pos);
VECCOPY(bp->origE, bp->pos);
VECCOPY(bp->origT, bp->pos);
@@ -3899,20 +3733,18 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int
sb_new_scratch(sb); /* make a new */
sb->scratch->needstobuildcollider=1;
if((sb->particles)==0) {
/* copy some info to scratch */
switch(ob->type) {
case OB_MESH:
if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
break;
case OB_LATTICE:
break;
case OB_CURVE:
case OB_SURF:
break;
default:
break;
}
/* copy some info to scratch */
switch(ob->type) {
case OB_MESH:
if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
break;
case OB_LATTICE:
break;
case OB_CURVE:
case OB_SURF:
break;
default:
break;
}
}
@@ -4048,8 +3880,6 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
/* simulates one step. framenr is in frames */
void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
{
ParticleSystemModifierData *psmd=0;
ParticleData *pa=0;
SoftBody *sb= ob->soft;
PointCache *cache;
PTCacheID pid;
@@ -4078,7 +3908,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
if(framenr < startframe) {
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe= 0;
cache->last_exact= 0;
//cache->last_exact= 0;
return;
}
@@ -4090,25 +3920,20 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
if(sb->bpoint == NULL ||
((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob))) {
if(sb->particles){
particles_to_softbody(scene, ob);
}
else {
switch(ob->type) {
case OB_MESH:
mesh_to_softbody(scene, ob);
break;
case OB_LATTICE:
lattice_to_softbody(scene, ob);
break;
case OB_CURVE:
case OB_SURF:
curve_surf_to_softbody(scene, ob);
break;
default:
renew_softbody(scene, ob, numVerts, 0);
break;
}
switch(ob->type) {
case OB_MESH:
mesh_to_softbody(scene, ob);
break;
case OB_LATTICE:
lattice_to_softbody(scene, ob);
break;
case OB_CURVE:
case OB_SURF:
curve_surf_to_softbody(scene, ob);
break;
default:
renew_softbody(scene, ob, numVerts, 0);
break;
}
softbody_update_positions(ob, sb, vertexCos, numVerts);
@@ -4126,8 +3951,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
softbody_update_positions(ob, sb, vertexCos, numVerts);
softbody_step(scene, ob, sb, dtime);
if(sb->particles==0)
softbody_to_object(ob, vertexCos, numVerts, 0);
softbody_to_object(ob, vertexCos, numVerts, 0);
return;
}
@@ -4135,25 +3959,33 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
/* still no points? go away */
if(sb->totpoint==0) return;
if(sb->particles){
psmd= psys_get_modifier(ob, sb->particles);
pa= sb->particles->particles;
if(framenr == startframe) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
/* first frame, no simulation to do, just set the positions */
softbody_update_positions(ob, sb, vertexCos, numVerts);
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->flag &= ~PTCACHE_REDO_NEEDED;
return;
}
/* try to read from cache */
cache_result = BKE_ptcache_read_cache(&pid, framenr, scene->r.frs_sec);
if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) {
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe= framenr;
softbody_to_object(ob, vertexCos, numVerts, sb->local);
if(sb->particles==0)
softbody_to_object(ob, vertexCos, numVerts, sb->local);
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
BKE_ptcache_write_cache(&pid, framenr);
return;
}
else if(cache_result==PTCACHE_READ_OLD) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE);
cache->flag |= PTCACHE_SIMULATION_VALID;
}
else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) {
@@ -4164,41 +3996,23 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i
return;
}
if(framenr == startframe) {
if(cache->flag & PTCACHE_REDO_NEEDED) {
softbody_update_positions(ob, sb, vertexCos, numVerts);
softbody_reset(ob, sb, vertexCos, numVerts);
cache->flag &= ~PTCACHE_REDO_NEEDED;
}
/* first frame, no simulation to do, just set the positions */
softbody_update_positions(ob, sb, vertexCos, numVerts);
/* if on second frame, write cache for first frame */
if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
BKE_ptcache_write_cache(&pid, startframe);
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe= framenr;
softbody_update_positions(ob, sb, vertexCos, numVerts);
/* don't write cache on first frame, but on second frame write
* cache for frame 1 and 2 */
}
else {
/* if on second frame, write cache for first frame */
if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
BKE_ptcache_write_cache(&pid, startframe);
/* checking time: */
dtime = framedelta*timescale;
softbody_update_positions(ob, sb, vertexCos, numVerts);
softbody_step(scene, ob, sb, dtime);
/* do simulation */
cache->flag |= PTCACHE_SIMULATION_VALID;
cache->simframe= framenr;
softbody_to_object(ob, vertexCos, numVerts, 0);
/* checking time: */
dtime = framedelta*timescale;
/* do simulation */
cache->simframe= framenr;
cache->flag |= PTCACHE_SIMULATION_VALID;
softbody_step(scene, ob, sb, dtime);
if(sb->particles==0)
softbody_to_object(ob, vertexCos, numVerts, 0);
BKE_ptcache_write_cache(&pid, framenr);
}
BKE_ptcache_write_cache(&pid, framenr);
}
+59 -54
View File
@@ -34,7 +34,7 @@
void sound_init()
{
AUD_Specs specs;
int device, buffersize, success;
int device, buffersize;
device = U.audiodevice;
buffersize = U.mixbufsize;
@@ -54,15 +54,8 @@ void sound_init()
if(specs.channels <= AUD_CHANNELS_INVALID)
specs.channels = AUD_CHANNELS_STEREO;
if(!AUD_init(device, specs, buffersize)) {
if(device == AUD_SDL_DEVICE)
success= AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4);
else
success= AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4);
if(!success)
AUD_init(AUD_NULL_DEVICE, specs, buffersize);
}
if(!AUD_init(device, specs, buffersize))
AUD_init(AUD_NULL_DEVICE, specs, buffersize);
}
void sound_exit()
@@ -78,7 +71,7 @@ struct bSound* sound_new_file(struct Main *main, char* filename)
int len;
strcpy(str, filename);
BLI_convertstringcode(str, G.sce);
BLI_convertstringcode(str, main->name);
len = strlen(filename);
while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
@@ -86,11 +79,11 @@ struct bSound* sound_new_file(struct Main *main, char* filename)
sound = alloc_libblock(&main->sound, ID_SO, filename+len);
strcpy(sound->name, filename);
sound->type = SOUND_TYPE_FILE;
// XXX unused currently sound->type = SOUND_TYPE_FILE;
sound_load(sound);
sound_load(main, sound);
if(!sound->snd_sound)
if(!sound->handle)
{
free_libblock(&main->sound, sound);
sound = NULL;
@@ -114,9 +107,9 @@ struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source)
sound->child_sound = source;
sound->type = SOUND_TYPE_BUFFER;
sound_load(sound);
sound_load(CTX_data_main(C), sound);
if(!sound->snd_sound)
if(!sound->handle)
{
free_libblock(&CTX_data_main(C)->sound, sound);
sound = NULL;
@@ -140,9 +133,9 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa
sound->end = end;
sound->type = SOUND_TYPE_LIMITER;
sound_load(sound);
sound_load(CTX_data_main(C), sound);
if(!sound->snd_sound)
if(!sound->handle)
{
free_libblock(&CTX_data_main(C)->sound, sound);
sound = NULL;
@@ -169,22 +162,35 @@ void sound_cache(struct bSound* sound, int ignore)
if(sound->cache && !ignore)
AUD_unload(sound->cache);
sound->cache = AUD_bufferSound(sound->snd_sound);
sound->cache = AUD_bufferSound(sound->handle);
sound->changed++;
}
void sound_load(struct bSound* sound)
void sound_delete_cache(struct bSound* sound)
{
if(sound->cache)
{
AUD_unload(sound->cache);
sound->cache = NULL;
}
}
void sound_load(struct Main *main, struct bSound* sound)
{
if(sound)
{
if(sound->snd_sound)
if(sound->handle)
{
AUD_unload(sound->snd_sound);
sound->snd_sound = NULL;
AUD_unload(sound->handle);
sound->handle = NULL;
}
// XXX unused currently
#if 0
switch(sound->type)
{
case SOUND_TYPE_FILE:
#endif
{
char fullpath[FILE_MAX];
char *path;
@@ -198,32 +204,32 @@ void sound_load(struct bSound* sound)
if(sound->id.lib)
path = sound->id.lib->filename;
else
path = G.sce;
path = main ? main->name : G.sce;
BLI_convertstringcode(fullpath, path);
/* but we need a packed file then */
if (pf)
sound->snd_sound = AUD_loadBuffer((unsigned char*) pf->data, pf->size);
sound->handle = AUD_loadBuffer((unsigned char*) pf->data, pf->size);
/* or else load it from disk */
else
sound->snd_sound = AUD_load(fullpath);
sound->handle = AUD_load(fullpath);
} // XXX
// XXX unused currently
#if 0
break;
}
case SOUND_TYPE_BUFFER:
if(sound->child_sound && sound->child_sound->snd_sound)
sound->snd_sound = AUD_bufferSound(sound->child_sound->snd_sound);
if(sound->child_sound && sound->child_sound->handle)
sound->handle = AUD_bufferSound(sound->child_sound->handle);
break;
case SOUND_TYPE_LIMITER:
if(sound->child_sound && sound->child_sound->snd_sound)
sound->snd_sound = AUD_limitSound(sound->child_sound, sound->start, sound->end);
if(sound->child_sound && sound->child_sound->handle)
sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end);
break;
}
if(sound->cache)
{
}
#endif
sound->changed++;
}
}
@@ -235,33 +241,36 @@ void sound_free(struct bSound* sound)
sound->packedfile = NULL;
}
if(sound->snd_sound)
if(sound->handle)
{
AUD_unload(sound->snd_sound);
sound->snd_sound = NULL;
AUD_unload(sound->handle);
sound->handle = NULL;
}
}
void sound_unlink(struct bContext *C, struct bSound* sound)
{
bSound *snd;
Scene *scene;
SoundHandle *handle;
// XXX unused currently
#if 0
bSound *snd;
for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next)
{
if(snd->child_sound == sound)
{
snd->child_sound = NULL;
if(snd->snd_sound)
if(snd->handle)
{
AUD_unload(sound->snd_sound);
snd->snd_sound = NULL;
AUD_unload(sound->handle);
snd->handle = NULL;
}
sound_unlink(C, snd);
}
}
#endif
for(scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next)
{
@@ -319,8 +328,6 @@ void sound_stop_all(struct bContext *C)
}
}
#define SOUND_PLAYBACK_LAMBDA 1.0
void sound_update_playing(struct bContext *C)
{
SoundHandle *handle;
@@ -366,12 +373,10 @@ void sound_update_playing(struct bContext *C)
action = 3;
else
{
float diff = AUD_getPosition(handle->handle) - (cfra - handle->startframe) / fps;
// AUD_XXX float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe
float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe;
if(diff < 0.0)
diff = -diff;
if(diff > SOUND_PLAYBACK_LAMBDA)
// AUD_XXX if(diff > 5.0f)
if(diff > FPS/2.0)
{
action = 2;
}
@@ -383,9 +388,9 @@ void sound_update_playing(struct bContext *C)
{
if(handle->state == AUD_STATUS_INVALID)
{
if(handle->source && handle->source->snd_sound)
if(handle->source && handle->source->handle)
{
AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps);
AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps);
handle->handle = AUD_play(limiter, 1);
AUD_unload(limiter);
if(handle->handle)
@@ -424,10 +429,10 @@ void sound_scrub(struct bContext *C)
{
if(cfra >= handle->startframe && cfra < handle->endframe && !handle->mute)
{
if(handle->source && handle->source->snd_sound)
if(handle->source && handle->source->handle)
{
int frameskip = handle->frameskip + cfra - handle->startframe;
AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, frameskip / fps, (frameskip + 1)/fps);
AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, frameskip / fps, (frameskip + 1)/fps);
AUD_play(limiter, 0);
AUD_unload(limiter);
}
@@ -450,7 +455,7 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e
for(handle = scene->sound_handles.first; handle; handle = handle->next)
{
if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->snd_sound)
if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->handle)
{
frameskip = handle->frameskip;
s = handle->startframe - start;
@@ -462,7 +467,7 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e
s = 0;
}
limiter = AUD_limitSound(handle->source->snd_sound, frameskip / fps, e / fps);
limiter = AUD_limitSound(handle->source->handle, frameskip / fps, e / fps);
delayer = AUD_delaySound(limiter, s / fps);
AUD_playDevice(mixdown, delayer);
+90 -3
View File
@@ -37,14 +37,22 @@
#include "BLI_blenlib.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_controller_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_text_types.h"
#include "BKE_utildefines.h"
#include "BKE_text.h"
#include "BKE_library.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_text.h"
#include "BKE_utildefines.h"
#ifndef DISABLE_PYTHON
#include "BPY_extern.h"
@@ -451,6 +459,85 @@ Text *copy_text(Text *ta)
return tan;
}
void unlink_text(Main *bmain, Text *text)
{
bScreen *scr;
ScrArea *area;
SpaceLink *sl;
Scene *scene;
Object *ob;
bController *cont;
bConstraint *con;
short update;
/* dome */
for(scene=bmain->scene.first; scene; scene=scene->id.next)
if(scene->r.dometext == text)
scene->r.dometext = NULL;
for(ob=bmain->object.first; ob; ob=ob->id.next) {
/* game controllers */
for(cont=ob->controllers.first; cont; cont=cont->next) {
if(cont->type==CONT_PYTHON) {
bPythonCont *pc;
pc= cont->data;
if(pc->text==text) pc->text= NULL;
}
}
/* pyconstraints */
update = 0;
if(ob->type==OB_ARMATURE && ob->pose) {
bPoseChannel *pchan;
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
for(con = pchan->constraints.first; con; con=con->next) {
if(con->type==CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
if (data->text==text) data->text = NULL;
update = 1;
}
}
}
}
for(con = ob->constraints.first; con; con=con->next) {
if(con->type==CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
if (data->text==text) data->text = NULL;
update = 1;
}
}
if(update)
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
}
/* pynodes */
// XXX nodeDynamicUnlinkText(&text->id);
/* text space */
for(scr= bmain->screen.first; scr; scr= scr->id.next) {
for(area= scr->areabase.first; area; area= area->next) {
for(sl= area->spacedata.first; sl; sl= sl->next) {
if(sl->spacetype==SPACE_TEXT) {
SpaceText *st= (SpaceText*) sl;
if(st->text==text) {
st->text= NULL;
st->top= 0;
}
}
}
}
}
text->id.us= 0;
}
/*****************************/
/* Editing utility functions */
/*****************************/
+118 -5
View File
@@ -38,11 +38,12 @@
#include "PIL_dynlib.h"
#include "MTC_matrixops.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_rand.h"
#include "BLI_kdopbvh.h"
#include "DNA_texture_types.h"
#include "DNA_key_types.h"
@@ -367,9 +368,9 @@ int do_colorband(ColorBand *coba, float in, float out[4])
CLAMP(fac, 0.0f, 1.0f);
if(coba->ipotype==3)
set_four_ipo(fac, t, KEY_CARDINAL);
key_curve_position_weights(fac, t, KEY_CARDINAL);
else
set_four_ipo(fac, t, KEY_BSPLINE);
key_curve_position_weights(fac, t, KEY_BSPLINE);
out[0]= t[3]*cbd3->r +t[2]*cbd2->r +t[1]*cbd1->r +t[0]*cbd0->r;
out[1]= t[3]*cbd3->g +t[2]*cbd2->g +t[1]*cbd1->g +t[0]*cbd0->g;
@@ -417,6 +418,8 @@ void free_texture(Tex *tex)
free_plugin_tex(tex->plugin);
if(tex->coba) MEM_freeN(tex->coba);
if(tex->env) BKE_free_envmap(tex->env);
if(tex->pd) BKE_free_pointdensity(tex->pd);
if(tex->vd) BKE_free_voxeldata(tex->vd);
BKE_previewimg_free(&tex->preview);
BKE_icon_delete((struct ID*)tex);
tex->id.icon_id = 0;
@@ -486,6 +489,16 @@ void default_tex(Tex *tex)
tex->env->depth=0;
}
if (tex->pd) {
tex->pd->radius = 0.3f;
tex->pd->falloff_type = TEX_PD_FALLOFF_STD;
}
if (tex->vd) {
tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0;
tex->vd->interp_type=TEX_VD_LINEAR;
tex->vd->file_format=TEX_VD_SMOKE;
}
pit = tex->plugin;
if (pit) {
varstr= pit->varstr;
@@ -737,9 +750,9 @@ void make_local_texture(Tex *tex)
void autotexname(Tex *tex)
{
char texstr[20][12]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend",
char texstr[20][15]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend",
"Stucci", "Noise" , "Image", "Plugin", "EnvMap" , "Musgrave",
"Voronoi", "DistNoise", "", "", "", "", "", ""};
"Voronoi", "DistNoise", "Point Density", "Voxel Data", "", "", "", ""};
Image *ima;
char di[FILE_MAXDIR], fi[FILE_MAXFILE];
@@ -887,6 +900,106 @@ void BKE_free_envmap(EnvMap *env)
}
/* ------------------------------------------------------------------------- */
PointDensity *BKE_add_pointdensity(void)
{
PointDensity *pd;
pd= MEM_callocN(sizeof(PointDensity), "pointdensity");
pd->flag = 0;
pd->radius = 0.3f;
pd->falloff_type = TEX_PD_FALLOFF_STD;
pd->falloff_softness = 2.0;
pd->source = TEX_PD_PSYS;
pd->point_tree = NULL;
pd->point_data = NULL;
pd->noise_size = 0.5f;
pd->noise_depth = 1;
pd->noise_fac = 1.0f;
pd->noise_influence = TEX_PD_NOISE_STATIC;
pd->coba = add_colorband(1);
pd->speed_scale = 1.0f;
pd->totpoints = 0;
pd->coba = add_colorband(1);
pd->object = NULL;
pd->psys = NULL;
return pd;
}
PointDensity *BKE_copy_pointdensity(PointDensity *pd)
{
PointDensity *pdn;
pdn= MEM_dupallocN(pd);
pdn->point_tree = NULL;
pdn->point_data = NULL;
if(pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba);
return pdn;
}
void BKE_free_pointdensitydata(PointDensity *pd)
{
if (pd->point_tree) {
BLI_bvhtree_free(pd->point_tree);
pd->point_tree = NULL;
}
if (pd->point_data) {
MEM_freeN(pd->point_data);
pd->point_data = NULL;
}
if(pd->coba) MEM_freeN(pd->coba);
}
void BKE_free_pointdensity(PointDensity *pd)
{
BKE_free_pointdensitydata(pd);
MEM_freeN(pd);
}
void BKE_free_voxeldatadata(struct VoxelData *vd)
{
if (vd->dataset) {
MEM_freeN(vd->dataset);
vd->dataset = NULL;
}
}
void BKE_free_voxeldata(struct VoxelData *vd)
{
BKE_free_voxeldatadata(vd);
MEM_freeN(vd);
}
struct VoxelData *BKE_add_voxeldata(void)
{
VoxelData *vd;
vd= MEM_callocN(sizeof(struct VoxelData), "voxeldata");
vd->dataset = NULL;
vd->resol[0] = vd->resol[1] = vd->resol[2] = 1;
vd->interp_type= TEX_VD_LINEAR;
vd->file_format= TEX_VD_SMOKE;
vd->int_multiplier = 1.0;
vd->object = NULL;
return vd;
}
struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd)
{
VoxelData *vdn;
vdn= MEM_dupallocN(vd);
vdn->dataset = NULL;
return vdn;
}
/* ------------------------------------------------------------------------- */
int BKE_texture_dependsOnTime(const struct Tex *texture)
{
+3
View File
@@ -317,11 +317,14 @@ static int ch_is_op(char op)
case '*':
case '/':
case '|':
case '&':
case '~':
case '<':
case '>':
case '^':
case '!':
case '=':
case '%':
return 1;
default:
return 0;
+65 -18
View File
@@ -174,7 +174,39 @@ void CalcNormShort(short *v1, short *v2, short *v3, float *n);
float power_of_2(float val);
/**
* @section Euler conversion routines
* @section Euler conversion routines (With Custom Order)
*/
/* Defines for rotation orders
* WARNING: must match the ePchan_RotMode in DNA_action_types.h
* order matters - types are saved to file!
*/
typedef enum eEulerRotationOrders {
EULER_ORDER_DEFAULT = 1, /* Blender 'default' (classic) is basically XYZ */
EULER_ORDER_XYZ = 1, /* Blender 'default' (classic) - must be as 1 to sync with PoseChannel rotmode */
EULER_ORDER_XZY,
EULER_ORDER_YXZ,
EULER_ORDER_YZX,
EULER_ORDER_ZXY,
EULER_ORDER_ZYX,
/* NOTE: there are about 6 more entries when including duplicated entries too */
} eEulerRotationOrders;
void EulOToQuat(float eul[3], short order, float quat[4]);
void QuatToEulO(float quat[4], float eul[3], short order);
void EulOToMat3(float eul[3], short order, float Mat[3][3]);
void EulOToMat4(float eul[3], short order, float Mat[4][4]);
void Mat3ToEulO(float Mat[3][3], float eul[3], short order);
void Mat4ToEulO(float Mat[4][4], float eul[3], short order);
void Mat3ToCompatibleEulO(float mat[3][3], float eul[3], float oldrot[3], short order);
void eulerO_rot(float beul[3], float ang, char axis, short order);
/**
* @section Euler conversion routines (Blender XYZ)
*/
void EulToMat3(float *eul, float mat[][3]);
@@ -185,11 +217,14 @@ void Mat4ToEul(float tmat[][4],float *eul);
void EulToQuat(float *eul, float *quat);
void compatible_eul(float *eul, float *oldrot);
void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot);
void compatible_eul(float *eul, float *oldrot);
void euler_rot(float *beul, float ang, char axis);
/**
* @section Quaternion arithmetic routines
*/
@@ -216,6 +251,8 @@ void printquat(char *str, float q[4]);
void QuatInterpol(float *result, float *quat1, float *quat2, float t);
void QuatAdd(float *result, float *quat1, float *quat2, float t);
void QuatToMat3(float *q, float m[][3]);
void QuatToMat4(float *q, float m[][4]);
/**
* @section matrix multiplication and copying routines
@@ -262,7 +299,7 @@ void Mat3MulMat3(float *m1, float *m3, float *m2);
#endif
void Mat4MulMat34(float (*m1)[4], float (*m3)[3], float (*m2)[4]);
void Mat4CpyMat4(float m1[][4], float m2[][4]);
void Mat4SwapMat4(float *m1, float *m2);
void Mat4SwapMat4(float m1[][4], float m2[][4]);
void Mat3CpyMat3(float m1[][3], float m2[][3]);
void Mat3MulSerie(float answ[][3],
@@ -283,6 +320,9 @@ void Mat3Clr(float *m);
void Mat3One(float m[][3]);
void Mat4One(float m[][4]);
void Mat3Scale(float m[][3], float scale);
void Mat4Scale(float m[][4], float scale);
void Mat3Ortho(float mat[][3]);
void Mat4Ortho(float mat[][4]);
@@ -305,8 +345,6 @@ void Mat4AddMat4(float m1[][4], float m2[][4], float m3[][4]);
void VecUpMat3old(float *vec, float mat[][3], short axis);
void VecUpMat3(float *vec, float mat[][3], short axis);
void VecRotToMat3(float *vec, float phi, float mat[][3]);
void VecRotToMat4(float *vec, float phi, float mat[][4]);
void VecCopyf(float *v1, float *v2);
int VecLen(int *v1, int *v2);
@@ -325,6 +363,7 @@ void printvec4f(char *str, float v[4]);
void VecAddf(float *v, float *v1, float *v2);
void VecSubf(float *v, float *v1, float *v2);
void VecMulVecf(float *v, float *v1, float *v2);
void VecLerpf(float *target, float *a, float *b, float t);
void VecMidf(float *v, float *v1, float *v2);
@@ -338,18 +377,32 @@ void Vec2Subf(float *v, float *v1, float *v2);
void Vec2Copyf(float *v1, float *v2);
void Vec2Lerpf(float *target, float *a, float *b, float t);
void AxisAngleToQuat(float *q, float *axis, float angle);
void AxisAngleToQuat(float q[4], float axis[3], float angle);
void QuatToAxisAngle(float q[4], float axis[3], float *angle);
void AxisAngleToEulO(float axis[3], float angle, float eul[3], short order);
void EulOToAxisAngle(float eul[3], short order, float axis[3], float *angle);
void AxisAngleToMat3(float axis[3], float angle, float mat[3][3]);
void AxisAngleToMat4(float axis[3], float angle, float mat[4][4]);
void Mat3ToAxisAngle(float mat[3][3], float axis[3], float *angle);
void Mat4ToAxisAngle(float mat[4][4], float axis[3], float *angle);
void Mat3ToVecRot(float mat[3][3], float axis[3], float *angle);
void Mat4ToVecRot(float mat[4][4], float axis[3], float *angle);
void VecRotToMat3(float *vec, float phi, float mat[][3]);
void VecRotToMat4(float *vec, float phi, float mat[][4]);
void RotationBetweenVectorsToQuat(float *q, float v1[3], float v2[3]);
void vectoquat(float *vec, short axis, short upflag, float *q);
void Mat3ToQuat_is_ok(float wmat[][3], float *q);
void VecReflect(float *out, float *v1, float *v2);
void VecBisect3(float *v, float *v1, float *v2, float *v3);
float VecAngle2(float *v1, float *v2);
float VecAngle3(float *v1, float *v2, float *v3);
float NormalizedVecAngle2(float *v1, float *v2);
float VecAngle3_2D(float *v1, float *v2, float *v3);
float NormalizedVecAngle2_2D(float *v1, float *v2);
void euler_rot(float *beul, float ang, char axis);
void NormalShortToFloat(float *out, short *in);
void NormalFloatToShort(short *out, float *in);
@@ -421,11 +474,6 @@ void VecStar(float mat[][3],float *vec);
short EenheidsMat(float mat[][3]);
void QuatToMat3(float *q, float m[][3]);
void QuatToMat4(float *q, float m[][4]);
void Mat3ToQuat_is_ok(float wmat[][3], float *q);
void i_ortho(float left, float right, float bottom, float top, float nearClip, float farClip, float matrix[][4]);
void i_polarview(float dist, float azimuth, float incidence, float twist, float Vm[][4]);
void i_translate(float Tx, float Ty, float Tz, float mat[][4]);
@@ -434,8 +482,6 @@ void i_rotate(float angle, char axis, float mat[][4]);
void MinMax3(float *min, float *max, float *vec);
void SizeToMat3(float *size, float mat[][3]);
void SizeToMat4(float *size, float mat[][4]);
@@ -455,8 +501,9 @@ void Mat4ToSize(float mat[][4], float *size);
void triatoquat(float *v1, float *v2, float *v3, float *quat);
void LocEulSizeToMat4(float mat[][4], float loc[3], float eul[3], float size[3]);
void LocQuatSizeToMat4(float mat[][4], float loc[3], float quat[4], float size[3]);
void LocEulSizeToMat4(float mat[4][4], float loc[3], float eul[3], float size[3]);
void LocEulOSizeToMat4(float mat[4][4], float loc[3], float eul[3], float size[3], short rotOrder);
void LocQuatSizeToMat4(float mat[4][4], float loc[3], float quat[4], float size[3]);
void tubemap(float x, float y, float z, float *u, float *v);
void spheremap(float x, float y, float z, float *u, float *v);
+1 -2
View File
@@ -36,8 +36,6 @@
#ifndef BLI_FILEOPS_H
#define BLI_FILEOPS_H
void BLI_recurdir_fileops(char *dirname);
int BLI_link(char *file, char *to);
int BLI_is_writable(char *filename);
@@ -56,6 +54,7 @@ char *BLI_last_slash(const char *string);
int BLI_add_slash(char *string);
void BLI_del_slash(char *string);
char *first_slash(char *string);
const char *BLI_short_filename(const char *string);
/* only for the sane unix world: direct calls to system functions :( */
#ifndef WIN32
+6
View File
@@ -71,6 +71,8 @@ typedef void (*BVHTree_NearestPointCallback) (void *userdata, int index, const f
/* callback must update hit in case it finds a nearest successful hit */
typedef void (*BVHTree_RayCastCallback) (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit);
/* callback to range search query */
typedef void (*BVHTree_RangeQuery) (void *userdata, int index, float squared_dist);
BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis);
void BLI_bvhtree_free(BVHTree *tree);
@@ -95,5 +97,9 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float
float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, float *pos);
/* range query */
int BLI_bvhtree_range_query(BVHTree *tree, const float *co, float radius, BVHTree_RangeQuery callback, void *userdata);
#endif // BLI_KDOPBVH_H
+41
View File
@@ -0,0 +1,41 @@
/**
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Matt Ebb, Raul Fernandez Hernandez (Farsthary).
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BLI_VOXEL_H
#define BLI_VOXEL_H
/* find the index number of a voxel, given x/y/z integer coords and resolution vector */
#define V_I(x, y, z, res) ( (z)*(res)[1]*(res)[0] + (y)*(res)[0] + (x) )
/* all input coordinates must be in bounding box 0.0 - 1.0 */
float voxel_sample_nearest(float *data, int *res, float *co);
float voxel_sample_trilinear(float *data, int *res, float *co);
float voxel_sample_triquadratic(float *data, int *res, float *co);
float voxel_sample_tricubic(float *data, int *res, float *co, int bspline);
#endif /* BLI_VOXEL_H */

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