From a1e05f46171dfa5c764a77a469b56adba7120940 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 20 Mar 2009 02:26:02 +0000 Subject: patch from Banlu Kemiyatorn * when joining only 2 faces dont check they are convex * allow edge rotate for non planer faces - Both were very annoying especially when sub-surf modeling with edge loops --- source/blender/src/editmesh_tools.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index 76f1443616f..690b4481ec9 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -3352,11 +3352,9 @@ void join_triangles(void) if(v1 && v2 && v3 && v4){ /*test if simple island first. This mimics 2.42 behaviour and the tests are less restrictive.*/ if(efaa[0]->tmp.l == 1 && efaa[1]->tmp.l == 1){ - if( convex(v1->co, v2->co, v3->co, v4->co) ){ - eed->f1 |= T2QJOIN; - efaa[0]->f1 = 1; //mark for join - efaa[1]->f1 = 1; //mark for join - } + eed->f1 |= T2QJOIN; + efaa[0]->f1 = 1; //mark for join + efaa[1]->f1 = 1; //mark for join } else{ @@ -3615,10 +3613,6 @@ static void edge_rotate(EditEdge *eed,int dir) if(numshared > 1) return; - /* coplaner faces only please */ - if(Inpf(face[0]->n,face[1]->n) <= 0.000001) - return; - /* we want to construct an array of vertex indicis in both faces, starting at the last vertex of the edge being rotated. - first we find the two vertices that lie on the rotating edge -- cgit v1.2.3 From 483ee1157e879304318173981981623e1deeeb65 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 20 Mar 2009 06:12:22 +0000 Subject: fixes for... [18429] Typo in IPO Actuator [18377] Crash fo yofankie (G.curscreen==NULL) /* No screen, happens when saving a blendfile in background mode, * then loading in the game engine * just assume we need the mesh info */ --- source/blender/blenkernel/intern/DerivedMesh.c | 38 +++++++++++++++++--------- source/blender/src/buttons_logic.c | 2 +- 2 files changed, 26 insertions(+), 14 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index b7f068c936b..c934f7d9fe7 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1995,21 +1995,33 @@ CustomDataMask get_viewedit_datamask() /* check if we need tfaces & mcols due to face select or texture paint */ if(FACESEL_PAINT_TEST || G.f & G_TEXTUREPAINT) mask |= CD_MASK_MTFACE | CD_MASK_MCOL; + + if (G.curscreen==NULL) { + /* No screen, happens when saving a blendfile in background mode, + * then loading in the game engine + * just assume we need the mesh info */ + mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - /* check if we need tfaces & mcols due to view mode */ - for(sa = G.curscreen->areabase.first; sa; sa = sa->next) { - if(sa->spacetype == SPACE_VIEW3D) { - View3D *view = sa->spacedata.first; - if(view->drawtype == OB_SHADED) { - /* this includes normals for mesh_create_shadedColors */ - mask |= CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_NORMAL | CD_MASK_ORCO; - } - if((view->drawtype == OB_TEXTURE) || ((view->drawtype == OB_SOLID) && (view->flag2 & V3D_SOLID_TEX))) { - mask |= CD_MASK_MTFACE | CD_MASK_MCOL; + if((G.fileflags & G_FILE_GAME_MAT) && + (G.fileflags & G_FILE_GAME_MAT_GLSL)) { + mask |= CD_MASK_ORCO; + } + } else { + /* check if we need tfaces & mcols due to view mode */ + for(sa = G.curscreen->areabase.first; sa; sa = sa->next) { + if(sa->spacetype == SPACE_VIEW3D) { + View3D *view = sa->spacedata.first; + if(view->drawtype == OB_SHADED) { + /* this includes normals for mesh_create_shadedColors */ + mask |= CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_NORMAL | CD_MASK_ORCO; + } + if((view->drawtype == OB_TEXTURE) || ((view->drawtype == OB_SOLID) && (view->flag2 & V3D_SOLID_TEX))) { + mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if((G.fileflags & G_FILE_GAME_MAT) && - (G.fileflags & G_FILE_GAME_MAT_GLSL)) { - mask |= CD_MASK_ORCO; + if((G.fileflags & G_FILE_GAME_MAT) && + (G.fileflags & G_FILE_GAME_MAT_GLSL)) { + mask |= CD_MASK_ORCO; + } } } } diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 10718c74a4b..01520061a19 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1875,7 +1875,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending"); uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack"); - uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign this property this actions current frame number"); + uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign the action's current frame number to this property"); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR -- cgit v1.2.3 From 615c5232c7b2e51f9722fdff58e04ae53c043797 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 22 Mar 2009 19:19:21 +0000 Subject: == FFMPEG == Updated ffmpeg to release version 0.5 updated x264 to today's daily build thanks to ben2610 for first patches (but you got hddaudio.c wrong :) --- source/blender/blenkernel/intern/writeffmpeg.c | 28 ++++++++++++++------------ source/blender/imbuf/intern/IMB_anim.h | 6 +++--- source/blender/imbuf/intern/anim.c | 8 ++++---- source/blender/imbuf/intern/util.c | 8 ++++---- source/blender/src/buttons_scene.c | 6 +++--- source/blender/src/hddaudio.c | 12 ++++++----- 6 files changed, 36 insertions(+), 32 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index cef6f802729..378e4319223 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -29,11 +29,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #if LIBAVFORMAT_VERSION_INT < (49 << 16) #define FFMPEG_OLD_FRAME_RATE 1 @@ -290,8 +290,8 @@ static AVFrame* generate_video_frame(uint8_t* pixels) int height = c->height; AVFrame* rgb_frame; - if (c->pix_fmt != PIX_FMT_RGBA32) { - rgb_frame = alloc_picture(PIX_FMT_RGBA32, width, height); + if (c->pix_fmt != PIX_FMT_BGR32) { + rgb_frame = alloc_picture(PIX_FMT_BGR32, width, height); if (!rgb_frame) { G.afbreek=1; error("Couldn't allocate temporary frame"); @@ -342,7 +342,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels) } } - if (c->pix_fmt != PIX_FMT_RGBA32) { + if (c->pix_fmt != PIX_FMT_BGR32) { sws_scale(img_convert_ctx, rgb_frame->data, rgb_frame->linesize, 0, c->height, current_frame->data, current_frame->linesize); @@ -498,9 +498,11 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of, c->pix_fmt = PIX_FMT_YUV420P; } - if (!strcmp(of->oformat->name, "mp4") || - !strcmp(of->oformat->name, "mov") || - !strcmp(of->oformat->name, "3gp")) { + if ((of->oformat->flags & AVFMT_GLOBALHEADER) +// || !strcmp(of->oformat->name, "mp4") +// || !strcmp(of->oformat->name, "mov") +// || !strcmp(of->oformat->name, "3gp") + ) { fprintf(stderr, "Using global header\n"); c->flags |= CODEC_FLAG_GLOBAL_HEADER; } @@ -514,7 +516,7 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of, /* xasp & yasp got float lately... */ - c->sample_aspect_ratio = av_d2q( + st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q( ((double) G.scene->r.xasp / (double) G.scene->r.yasp), 255); set_ffmpeg_properties(c, "video"); @@ -531,7 +533,7 @@ static AVStream* alloc_video_stream(int codec_id, AVFormatContext* of, current_frame = alloc_picture(c->pix_fmt, c->width, c->height); img_convert_ctx = sws_getContext(c->width, c->height, - PIX_FMT_RGBA32, + PIX_FMT_BGR32, c->width, c->height, c->pix_fmt, SWS_BICUBIC, diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 745248d3218..7e99df8237a 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -76,9 +76,9 @@ #endif /* WITH_QUICKTIME */ #ifdef WITH_FFMPEG -#include -#include -#include +#include +#include +#include #endif #ifdef WITH_REDCODE diff --git a/source/blender/imbuf/intern/anim.c b/source/blender/imbuf/intern/anim.c index 80bf401bec0..42fe47cc5e9 100644 --- a/source/blender/imbuf/intern/anim.c +++ b/source/blender/imbuf/intern/anim.c @@ -83,10 +83,10 @@ #include "IMB_anim5.h" #ifdef WITH_FFMPEG -#include -#include -#include -#include +#include +#include +#include +#include #if LIBAVFORMAT_VERSION_INT < (49 << 16) #define FFMPEG_OLD_FRAME_RATE 1 diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 15d1d031dbd..ffd5d3431af 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -73,10 +73,10 @@ #endif #ifdef WITH_FFMPEG -#include -#include -#include -#include +#include +#include +#include +#include #if LIBAVFORMAT_VERSION_INT < (49 << 16) #define FFMPEG_OLD_FRAME_RATE 1 diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 376a57b11e9..be988c5a68a 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -109,9 +109,9 @@ #ifdef WITH_FFMPEG -#include /* for PIX_FMT_* and CODEC_ID_* */ -#include -#include +#include /* for PIX_FMT_* and CODEC_ID_* */ +#include +#include static int ffmpeg_preset_sel = 0; diff --git a/source/blender/src/hddaudio.c b/source/blender/src/hddaudio.c index 7e6b314f296..7175f140b09 100644 --- a/source/blender/src/hddaudio.c +++ b/source/blender/src/hddaudio.c @@ -33,9 +33,9 @@ #endif #ifdef WITH_FFMPEG -#include -#include -#include +#include +#include +#include #if LIBAVFORMAT_VERSION_INT < (49 << 16) #define FFMPEG_OLD_FRAME_RATE 1 #else @@ -311,7 +311,8 @@ static void sound_hdaudio_extract_small_block( audio_pkt_size = packet.size; while (audio_pkt_size > 0) { - len = avcodec_decode_audio( + data_size=AVCODEC_MAX_AUDIO_FRAME_SIZE; + len = avcodec_decode_audio2( hdaudio->pCodecCtx, hdaudio->decode_cache + decode_pos, @@ -478,7 +479,8 @@ static void sound_hdaudio_extract_small_block( } while (audio_pkt_size > 0) { - len = avcodec_decode_audio( + data_size=AVCODEC_MAX_AUDIO_FRAME_SIZE; + len = avcodec_decode_audio2( hdaudio->pCodecCtx, hdaudio->decode_cache + decode_pos, -- cgit v1.2.3 From fa765a554c6883364dc24c286dd5b630ce5dcfe6 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 22 Mar 2009 21:06:08 +0000 Subject: only write tex plugin and envmap data to file if texture is the right type. This takes care of lingering errors with missing texture plugins after texture type is changed --- source/blender/blenloader/intern/writefile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 92d847d4782..cf8109fe9b3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1332,9 +1332,9 @@ static void write_textures(WriteData *wd, ListBase *idbase) if (tex->id.properties) IDP_WriteProperty(tex->id.properties, wd); /* direct data */ - if(tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin); + if(tex->type == TEX_PLUGIN && tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin); if(tex->coba) writestruct(wd, DATA, "ColorBand", 1, tex->coba); - if(tex->env) writestruct(wd, DATA, "EnvMap", 1, tex->env); + if(tex->type == TEX_ENVMAP && tex->env) writestruct(wd, DATA, "EnvMap", 1, tex->env); /* nodetree is integral part of texture, no libdata */ if(tex->nodetree) { -- cgit v1.2.3 From 5e44eba342190fe39332591a1e897a35658951c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Mar 2009 03:53:20 +0000 Subject: fix for [18443] Object.GetSelected() returns empty when run from command line --- source/blender/python/api2_2x/Object.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 1282b9bd82c..fd2301bfae4 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -945,17 +945,13 @@ static PyObject *M_Object_GetSelected( PyObject * self_unused ) PyObject *blen_object; PyObject *list; Base *base_iter; - + unsigned int lay = G.vd ? G.vd->lay : G.scene->lay; + list = PyList_New( 0 ); - - if( G.vd == NULL ) { - /* No 3d view has been initialized yet, simply return an empty list */ - return list; - } if( ( G.scene->basact ) && ( ( G.scene->basact->flag & SELECT ) && - ( G.scene->basact->lay & G.vd->lay ) ) ) { + ( G.scene->basact->lay & lay ) ) ) { /* Active object is first in the list. */ blen_object = Object_CreatePyObject( G.scene->basact->object ); @@ -970,7 +966,7 @@ static PyObject *M_Object_GetSelected( PyObject * self_unused ) base_iter = G.scene->base.first; while( base_iter ) { if( ( ( base_iter->flag & SELECT ) && - ( base_iter->lay & G.vd->lay ) ) && + ( base_iter->lay & lay ) ) && ( base_iter != G.scene->basact ) ) { blen_object = Object_CreatePyObject( base_iter->object ); -- cgit v1.2.3 From 688db0f25169a4270c2d7250a7eb200bf2ab0ae0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Mar 2009 09:09:10 +0000 Subject: [#18260] FMOD Removal from Jorg Muller (nexyon) also removed references to CVS in install --- source/blender/include/BIF_editsound.h | 1 - source/blender/src/buttons_scene.c | 8 +----- source/blender/src/editsound.c | 52 ++-------------------------------- 3 files changed, 3 insertions(+), 58 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BIF_editsound.h b/source/blender/include/BIF_editsound.h index 6561b3e6849..e04bd43307e 100644 --- a/source/blender/include/BIF_editsound.h +++ b/source/blender/include/BIF_editsound.h @@ -39,7 +39,6 @@ struct hdaudio; void sound_init_audio(void); void sound_initialize_sounds(void); void sound_exit_audio(void); -int sound_get_mixrate(void); void* sound_get_audiodevice(void); void* sound_get_listener(void); diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index be988c5a68a..aa072285556 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -296,17 +296,11 @@ void do_soundbuts(unsigned short event) static void sound_panel_listener(void) { uiBlock *block; - int xco= 100, yco=100, mixrate; - char mixrateinfo[256]; + int xco= 100, yco=100; block= uiNewBlock(&curarea->uiblocks, "sound_panel_listener", UI_EMBOSS, UI_HELV, curarea->win); if(uiNewPanel(curarea, block, "Listener", "Sound", 320, 0, 318, 204)==0) return; - mixrate = sound_get_mixrate(); - sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate); - uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, ""); - - yco -= 30; uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, ""); yco -= 30; diff --git a/source/blender/src/editsound.c b/source/blender/src/editsound.c index 95b3a3d3021..71187f6bd8b 100644 --- a/source/blender/src/editsound.c +++ b/source/blender/src/editsound.c @@ -530,38 +530,11 @@ static int sound_get_filetype_from_header(bSound *sound, PackedFile *pf) filetype = SAMPLE_WAV; } else - /* only fmod supports compressed wav */ -#ifdef USE_FMOD { - /* and only valid publishers may use compressed wav */ - switch (shortbuf) - { - case SND_WAVE_FORMAT_ADPCM: - case SND_WAVE_FORMAT_ALAW: - case SND_WAVE_FORMAT_MULAW: - case SND_WAVE_FORMAT_DIALOGIC_OKI_ADPCM: - case SND_WAVE_FORMAT_CONTROL_RES_VQLPC: - case SND_WAVE_FORMAT_GSM_610: - case SND_WAVE_FORMAT_MPEG3: - filetype = SAMPLE_WAV; - break; - default: -#endif - { - filetype = SAMPLE_INVALID; - if (G.f & G_DEBUG) printf("Unsupported wav compression\n"); - } - } -#ifdef USE_FMOD + filetype = SAMPLE_INVALID; + if (G.f & G_DEBUG) printf("Unsupported wav compression\n"); } } - else if (!memcmp(buffer, "OggS", 4)) { - filetype = SAMPLE_OGG_VORBIS; - } - else if ((!memcmp(buffer, "ID3", 3)) || (!memcmp(buffer, "", 2))) { - filetype = SAMPLE_MP3; - } -#endif else { filetype = SAMPLE_INVALID; if (G.f & G_DEBUG) printf("Unsupported sound format: %s\n", sound->name); @@ -583,21 +556,6 @@ static int check_filetype(bSound *sound, PackedFile *pf) // a simple check to see what kind of sample we're dealing with if (stricmp(pdest, ".wav") == 0) sound->sample->type = SAMPLE_WAV; - -#ifdef USE_FMOD - if (stricmp(pdest, ".mp2") == 0) - sound->sample->type = SAMPLE_MP2; - if (stricmp(pdest, ".mp3") == 0) - sound->sample->type = SAMPLE_MP3; - if (stricmp(pdest, ".ogg") == 0) - sound->sample->type = SAMPLE_OGG_VORBIS; - if (stricmp(pdest, ".raw") == 0) - sound->sample->type = SAMPLE_RAW; - if (stricmp(pdest, ".wma") == 0) - sound->sample->type = SAMPLE_WMA; - if (stricmp(pdest, ".asf") == 0) - sound->sample->type = SAMPLE_ASF; -#endif */ sound->sample->type = sound_get_filetype_from_header(sound, pf); @@ -1061,12 +1019,6 @@ void sound_init_audio(void) } -int sound_get_mixrate(void) -{ - return MIXRATE; -} - - void sound_exit_audio(void) { if(ghSoundScene) { -- cgit v1.2.3 From dbe675195d8f78fb3a5f9b89d0c6b89a47513198 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 24 Mar 2009 13:39:50 +0000 Subject: Fix for bug #18438: TEX_valToNormal.c array size error. Error pointed out by Dan Eicher, thanks! --- source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c index f63f5682030..0d24652a8f6 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c @@ -45,7 +45,7 @@ static void normalfn(float *out, float *coord, bNode *node, bNodeStack **in, sho float nabla = tex_input_value(in[1], coord, thread); float val; - float nor[2]; + float nor[3]; val = tex_input_value(in[0], coord, thread); -- cgit v1.2.3 From 5d48e0430763e1d6cb790606e1c06d7a2190ca88 Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Tue, 24 Mar 2009 18:51:21 +0000 Subject: Renumbered the texture nodes because they were clashing with the other nodes. This will break compatibility with previous texnode testing builds (but not with any released versions) --- source/blender/blenkernel/BKE_node.h | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 3f04330f2a3..184b28b2cd2 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -385,32 +385,32 @@ void free_compbuf(struct CompBuf *cbuf); /* internal...*/ struct TexResult; -#define TEX_NODE_OUTPUT 101 -#define TEX_NODE_CHECKER 102 -#define TEX_NODE_TEXTURE 103 -#define TEX_NODE_BRICKS 104 -#define TEX_NODE_MATH 105 -#define TEX_NODE_MIX_RGB 106 -#define TEX_NODE_RGBTOBW 107 -#define TEX_NODE_VALTORGB 108 -#define TEX_NODE_IMAGE 109 -#define TEX_NODE_CURVE_RGB 110 -#define TEX_NODE_INVERT 111 -#define TEX_NODE_HUE_SAT 112 -#define TEX_NODE_CURVE_TIME 113 -#define TEX_NODE_ROTATE 114 -#define TEX_NODE_VIEWER 115 -#define TEX_NODE_TRANSLATE 116 -#define TEX_NODE_COORD 117 -#define TEX_NODE_DISTANCE 118 -#define TEX_NODE_COMPOSE 119 -#define TEX_NODE_DECOMPOSE 120 -#define TEX_NODE_VALTONOR 121 -#define TEX_NODE_SCALE 122 +#define TEX_NODE_OUTPUT 401 +#define TEX_NODE_CHECKER 402 +#define TEX_NODE_TEXTURE 403 +#define TEX_NODE_BRICKS 404 +#define TEX_NODE_MATH 405 +#define TEX_NODE_MIX_RGB 406 +#define TEX_NODE_RGBTOBW 407 +#define TEX_NODE_VALTORGB 408 +#define TEX_NODE_IMAGE 409 +#define TEX_NODE_CURVE_RGB 410 +#define TEX_NODE_INVERT 411 +#define TEX_NODE_HUE_SAT 412 +#define TEX_NODE_CURVE_TIME 413 +#define TEX_NODE_ROTATE 414 +#define TEX_NODE_VIEWER 415 +#define TEX_NODE_TRANSLATE 416 +#define TEX_NODE_COORD 417 +#define TEX_NODE_DISTANCE 418 +#define TEX_NODE_COMPOSE 419 +#define TEX_NODE_DECOMPOSE 420 +#define TEX_NODE_VALTONOR 421 +#define TEX_NODE_SCALE 422 /* 201-299 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ -#define TEX_NODE_PROC 200 -#define TEX_NODE_PROC_MAX 300 +#define TEX_NODE_PROC 500 +#define TEX_NODE_PROC_MAX 600 extern struct ListBase node_all_textures; -- cgit v1.2.3 From 6020d2cb45322c0dfa3d9548cca62318b7a6491c Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Tue, 24 Mar 2009 19:39:02 +0000 Subject: Changed missing line ending style for TEX_ files in sculptmode.c move initalization of a var to fix an issue where index of array could be -1. Found by coverity. Kent --- source/blender/src/sculptmode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index c534a8b3cab..ca049523928 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -1175,7 +1175,7 @@ void sculptmode_update_tex() { SculptData *sd= sculpt_data(); SculptSession *ss= sculpt_session(); - MTex *mtex = sd->mtex[sd->texact]; + MTex *mtex; TexResult texres = {0}; float x, y, step=2.0/TC_SIZE, co[3]; int hasrgb, ix, iy; @@ -1183,6 +1183,8 @@ void sculptmode_update_tex() /* Skip Default brush shape and non-textures */ if(sd->texact == -1 || !sd->mtex[sd->texact]) return; + mtex = sd->mtex[sd->texact]; + if(ss->texcache) { MEM_freeN(ss->texcache); ss->texcache= NULL; -- cgit v1.2.3 From 616897d0db674275b0f8d962f220f8d722a976d5 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 24 Mar 2009 19:39:43 +0000 Subject: Bad crash in volume snapping code when duplis where involved. Found out using Coverity's scan report. --- source/blender/src/transform_snap.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/transform_snap.c b/source/blender/src/transform_snap.c index bedfaf60b77..b43984af1a6 100644 --- a/source/blender/src/transform_snap.c +++ b/source/blender/src/transform_snap.c @@ -1563,11 +1563,21 @@ int peelObjects(ListBase *depth_peels, short mval[2]) Object *ob = dupli_ob->ob; if (ob->type == OB_MESH) { - DerivedMesh *dm; - int editmesh = 0; + DerivedMesh *dm = NULL; int val; - val = peelDerivedMesh(ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels); + if (ob != G.obedit) + { + dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH); + + val = peelDerivedMesh(ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels); + } + else + { + dm = editmesh_get_derived_cage(CD_MASK_BAREMESH); + + val = peelDerivedMesh(ob, dm, dupli_ob->mat, ray_start, ray_normal, mval, depth_peels); + } retval = retval || val; -- cgit v1.2.3 From bba2bdf41e064c4c6602aa5e6c6c79364f51b08d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Mar 2009 01:42:01 +0000 Subject: Added attributes for Ipo Actuator settings (replacing all methods) --- source/blender/render/intern/source/convertblender.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 4e4e27fe286..601acc881de 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1988,12 +1988,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem part->bb_align,part->draw&PART_DRAW_BB_LOCK, a,totpart+totchild,part->bb_uv_split,part->bb_anim,part->bb_split_offset,random,pa_time,part->bb_offset,uv); } - else if(strandbuf) { + else if(strandbuf) { if(svert) { VECCOPY(svert->co, loc); svert->strandco= -1.0f + 2.0f*time; svert++; strand->totvert++; - } + } } else{ if(k==1){ VECSUB(loc0,loc1,loc); -- cgit v1.2.3 From e392eb4d9c9eb98730a841cb4317835122d69287 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Fri, 27 Mar 2009 16:27:48 +0000 Subject: Fixed a couple of null issues spotted by coverity. CIDS: 42 and 470 Kent --- source/blender/blenkernel/intern/anim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 731c2a18c55..87d7bfc4853 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -223,14 +223,16 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK cu= ob->data; if(cu->path==NULL || cu->path->data==NULL) { printf("no path!\n"); + return 0; } path= cu->path; fp= path->data; /* test for cyclic */ bl= cu->bev.first; + if (!bl) return 0; if (!bl->nr) return 0; - if(bl && bl->poly> -1) cycl= 1; + if(bl->poly> -1) cycl= 1; ctime *= (path->len-1); -- cgit v1.2.3 From f61ce664bce8799dead8c746806a045bca3d67d1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Mar 2009 04:25:21 +0000 Subject: Tooltip fix, there is no such thing as "Tadius interpolation" --- source/blender/src/buttons_editing.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 7b564bdd7a3..134f794af93 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -3527,12 +3527,12 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu) 450,90,72, 18, 0, 0, 0, 0, 0, ""); /* KEY_LINEAR, KEY_CARDINAL, KEY_BSPLINE */ uiDefButS(block, MENU, B_TILTINTERP, "Tilt Interpolation %t|Linear%x0|Cardinal%x1|BSpline %x2|Ease%x3", - 495,90,66, 18, &(nu->tilt_interp), 0, 0, 0, 0, "Tadius interpolation for 3D curves"); + 495,90,66, 18, &(nu->tilt_interp), 0, 0, 0, 0, "Tilt interpolation for 3D, bezier curves"); uiDefBut(block, LABEL, 0, "Radius", 450,70,72, 18, 0, 0, 0, 0, 0, ""); uiDefButS(block, MENU, B_TILTINTERP, "Radius Interpolation %t|Linear%x0|Cardinal%x1|BSpline %x2|Ease%x3", - 495,70,66, 18, &(nu->radius_interp), 0, 0, 0, 0, "Radius interpolation"); + 495,70,66, 18, &(nu->radius_interp), 0, 0, 0, 0, "Radius interpolation for bezier curves"); } uiBlockBeginAlign(block); -- cgit v1.2.3 From 6fd597b30446f23513ce6481219863c4abed3b7e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Mar 2009 05:51:18 +0000 Subject: removed unneeded arg from makeknots() and replaced some numbers with defines --- source/blender/blenkernel/BKE_curve.h | 2 +- source/blender/blenkernel/intern/curve.c | 14 +++--- source/blender/python/api2_2x/CurNurb.c | 8 ++-- source/blender/python/api2_2x/SurfNurb.c | 14 +++--- source/blender/src/buttons_editing.c | 8 ++-- source/blender/src/drawobject.c | 4 +- source/blender/src/drawview.c | 2 +- source/blender/src/editcurve.c | 80 ++++++++++++++++---------------- source/blender/src/editobject.c | 4 +- 9 files changed, 68 insertions(+), 68 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 25d6d78c4aa..a6619958797 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -63,7 +63,7 @@ void duplicateNurblist( struct ListBase *lb1, struct ListBase *lb2); void test2DNurb( struct Nurb *nu); void minmaxNurb( struct Nurb *nu, float *min, float *max); -void makeknots( struct Nurb *nu, short uv, short type); +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); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 7fa4f406c7b..e303f78b163 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -554,8 +554,8 @@ static void makecyclicknots(float *knots, short pnts, short order) } -/* type - 0: uniform, 1: endpoints, 2: bezier, note, cyclic nurbs are always uniform */ -void makeknots(Nurb *nu, short uv, short type) + +void makeknots(Nurb *nu, short uv) { if( (nu->type & 7)==CU_NURBS ) { if(uv == 1) { @@ -566,7 +566,7 @@ void makeknots(Nurb *nu, short uv, short type) calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu); } else { - calcknots(nu->knotsu, nu->pntsu, nu->orderu, type); + calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu>>1); } } else nu->knotsu= NULL; @@ -579,7 +579,7 @@ void makeknots(Nurb *nu, short uv, short type) calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv); } else { - calcknots(nu->knotsv, nu->pntsv, nu->orderv, type); + calcknots(nu->knotsv, nu->pntsv, nu->orderv, nu->flagv>>1); } } else nu->knotsv= NULL; @@ -2333,7 +2333,7 @@ void sethandlesNurb(short code) if(code==1 || code==2) { nu= editNurb.first; while(nu) { - if( (nu->type & 7)==1) { + if( (nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { @@ -2363,7 +2363,7 @@ void sethandlesNurb(short code) } else { /* Toggle */ while(nu) { - if( (nu->type & 7)==1) { + if( (nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { @@ -2380,7 +2380,7 @@ void sethandlesNurb(short code) } nu= editNurb.first; while(nu) { - if( (nu->type & 7)==1) { + if( (nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c index 456f11e4a54..a32fce8cc48 100644 --- a/source/blender/python/api2_2x/CurNurb.c +++ b/source/blender/python/api2_2x/CurNurb.c @@ -564,7 +564,7 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * value ) tmp->radius = radius; tmp->weight = 0.0; /* softbody weight TODO - add access to this, is zero elsewhere but through blender is 1.0 by default */ - makeknots( nurb, 1, nurb->flagu >> 1 ); + makeknots(nurb, 1); } else { /* bail with error */ @@ -649,7 +649,7 @@ static int CurNurb_setFlagU( BPy_CurNurb * self, PyObject * args ) if( self->nurb->flagu != value ) { self->nurb->flagu = (short)value; - makeknots( self->nurb, 1, self->nurb->flagu >> 1 ); + makeknots(self->nurb, 1); } return 0; @@ -698,7 +698,7 @@ static int CurNurb_setFlagV( BPy_CurNurb * self, PyObject * args ) if( self->nurb->flagv != value ) { self->nurb->flagv = (short)value; - makeknots( self->nurb, 2, self->nurb->flagv >> 1 ); + makeknots( self->nurb, 2); } return 0; @@ -728,7 +728,7 @@ static int CurNurb_setOrderU( BPy_CurNurb * self, PyObject * args ) order = self->nurb->pntsu; self->nurb->orderu = (short)order; - makeknots( self->nurb, 1, self->nurb->flagu >> 1 ); + makeknots(self->nurb, 1); return 0; } diff --git a/source/blender/python/api2_2x/SurfNurb.c b/source/blender/python/api2_2x/SurfNurb.c index deee6c07793..e75bb340272 100644 --- a/source/blender/python/api2_2x/SurfNurb.c +++ b/source/blender/python/api2_2x/SurfNurb.c @@ -195,7 +195,7 @@ static PyObject *SurfNurb_appendPointToNurb( Nurb * nurb, PyObject * args ) nurb->bp[npoints].alfa = 0.0f; } - makeknots( nurb, 1, nurb->flagu >> 1 ); + makeknots(nurb, 1); } else { return EXPP_ReturnPyObjError( PyExc_TypeError, @@ -322,7 +322,7 @@ static int SurfNurb_setFlagU( BPy_SurfNurb * self, PyObject * args ) flagu = (flagu << 1) | (self->nurb->flagu & CU_CYCLIC); if( self->nurb->flagu != flagu ) { self->nurb->flagu = (short)flagu; - makeknots( self->nurb, 1, self->nurb->flagu >> 1 ); + makeknots(self->nurb, 1); } return 0; @@ -366,7 +366,7 @@ static int SurfNurb_setFlagV( BPy_SurfNurb * self, PyObject * args ) flagv = (flagv << 1) | (self->nurb->flagv & CU_CYCLIC); if( self->nurb->flagv != flagv ) { self->nurb->flagv = (short)flagv; - makeknots( self->nurb, 2, self->nurb->flagv >> 1 ); + makeknots(self->nurb, 2); } return 0; @@ -402,7 +402,7 @@ static int SurfNurb_setOrderU( BPy_SurfNurb * self, PyObject * args ) order = self->nurb->pntsu; self->nurb->orderu = (short)order; - makeknots( self->nurb, 1, self->nurb->flagu >> 1 ); + makeknots(self->nurb, 1); return 0; } @@ -431,7 +431,7 @@ static int SurfNurb_setOrderV( BPy_SurfNurb * self, PyObject * args ) order = self->nurb->pntsv; self->nurb->orderv = (short)order; - makeknots( self->nurb, 2, self->nurb->flagv >> 1 ); + makeknots(self->nurb, 2); return 0; } @@ -467,7 +467,7 @@ static int SurfNurb_setCyclicU( BPy_SurfNurb * self, PyObject * value ) self->nurb->flagu |= CU_CYCLIC; else self->nurb->flagu &= ~CU_CYCLIC; - makeknots( self->nurb, 1, self->nurb->flagu >> 1 ); + makeknots(self->nurb, 1); return 0; } @@ -482,7 +482,7 @@ static int SurfNurb_setCyclicV( BPy_SurfNurb * self, PyObject * value ) self->nurb->flagv |= CU_CYCLIC; else self->nurb->flagv &= ~CU_CYCLIC; - makeknots( self->nurb, 2, self->nurb->flagv >> 1 ); + makeknots(self->nurb, 2); return 0; } diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 134f794af93..2f77e3659ee 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -3311,13 +3311,13 @@ void do_curvebuts(unsigned short event) nu->flagu &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */ nu->flagu |= ((event-B_UNIFU)<<1); clamp_nurb_order_u(nu); - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } else if(nu->pntsv>1) { nu->flagv &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */ nu->flagv |= ((event-B_UNIFV)<<1); clamp_nurb_order_v(nu); - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); } } } @@ -3359,11 +3359,11 @@ void do_curvebuts(unsigned short event) if(clamp_nurb_order_u(nu)) { scrarea_queue_winredraw(curarea); } - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); if(clamp_nurb_order_v(nu)) { scrarea_queue_winredraw(curarea); } - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); } BIF_undo_push("Make knots"); DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 43991194658..2063ac42bb1 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -3777,7 +3777,7 @@ static void tekenhandlesN(Nurb *nu, short sel) glBegin(GL_LINES); - if( (nu->type & 7)==1) { + if( (nu->type & 7)==CU_BEZIER) { if(sel) col= nurbcol+4; else col= nurbcol; @@ -3834,7 +3834,7 @@ static void tekenvertsN(Nurb *nu, short sel) bglBegin(GL_POINTS); - if((nu->type & 7)==1) { + if((nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 2cc8a9510a6..cd40b5e0ae2 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -1773,7 +1773,7 @@ static void v3d_editvertex_buts(uiBlock *block, Object *ob, float lim) nu= editNurb.first; while(nu) { - if((nu->type & 7)==1) { + if((nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c index 594ff816ec1..0e697c5c5c4 100644 --- a/source/blender/src/editcurve.c +++ b/source/blender/src/editcurve.c @@ -691,7 +691,7 @@ void deleteflagNurb(short flag) nu->bp= newbp; clamp_nurb_order_v(nu); - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); } else { /* is the nurb in V direction selected */ @@ -737,7 +737,7 @@ void deleteflagNurb(short flag) nu->pntsu= newu; clamp_nurb_order_u(nu); } - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } } } @@ -785,7 +785,7 @@ short extrudeflagNurb(int flag) nu->pntsv= 2; nu->orderv= 2; - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); } } else { @@ -828,7 +828,7 @@ short extrudeflagNurb(int flag) MEM_freeN(nu->bp); nu->bp= newbp; nu->pntsv++; - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); } else if(v==0 || v== nu->pntsu-1) { /* collumn in v-direction selected */ ok= 1; @@ -855,7 +855,7 @@ short extrudeflagNurb(int flag) MEM_freeN(nu->bp); nu->bp= newbp; nu->pntsu++; - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } } } @@ -949,7 +949,7 @@ void adduplicateflagNurb(short flag) /* knots */ newnu->knotsu= NULL; - makeknots(newnu, 1, newnu->flagu>>1); + makeknots(newnu, 1); } bp++; } @@ -1013,14 +1013,14 @@ void adduplicateflagNurb(short flag) if(nu->pntsu==newnu->pntsu && nu->knotsu) { newnu->knotsu= MEM_dupallocN( nu->knotsu ); } else { - makeknots(newnu, 1, newnu->flagu>>1); + makeknots(newnu, 1); } } if (check_valid_nurb_v(newnu)) { if(nu->pntsv==newnu->pntsv && nu->knotsv) { newnu->knotsv= MEM_dupallocN( nu->knotsv ); } else { - makeknots(newnu, 2, newnu->flagv>>1); + makeknots(newnu, 2); } } } @@ -1779,8 +1779,8 @@ void subdivideNurb() nu->bp= bpnew; nu->pntsu+= amount; - if(nu->type & 4) { - makeknots(nu, 1, nu->flagu>>1); + if(nu->type & CU_NURBS) { + makeknots(nu, 1); } } } /* End of 'else if(nu->pntsv==1)' */ @@ -1891,8 +1891,8 @@ void subdivideNurb() nu->bp= bpnew; nu->pntsu= 2*nu->pntsu-1; nu->pntsv= 2*nu->pntsv-1; - makeknots(nu, 1, nu->flagu>>1); - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 1); + makeknots(nu, 2); } /* End of 'if(sel== nu->pntsu*nu->pntsv)' (subdivide entire NURB) */ else { /* subdivide in v direction? */ @@ -1935,7 +1935,7 @@ void subdivideNurb() MEM_freeN(nu->bp); nu->bp= bpnew; nu->pntsv+= sel; - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); } else { /* or in u direction? */ @@ -1975,7 +1975,7 @@ void subdivideNurb() MEM_freeN(nu->bp); nu->bp= bpnew; nu->pntsu+= sel; - makeknots(nu, 1, nu->flagu>>1); /* shift knots + makeknots(nu, 1); /* shift knots forward */ } } @@ -2119,7 +2119,7 @@ int convertspline(short type, Nurb *nu) BPoint *bp; int a, c, nr; - if((nu->type & 7)==0) { /* Poly */ + if((nu->type & 7)==CU_POLY) { if(type==CU_BEZIER) { /* to Bezier with vecthandles */ nr= nu->pntsu; bezt = @@ -2140,16 +2140,16 @@ int convertspline(short type, Nurb *nu) nu->bp= 0; nu->pntsu= nr; nu->type &= ~7; - nu->type |= 1; + nu->type |= CU_BEZIER; calchandlesNurb(nu); } else if(type==CU_NURBS) { nu->type &= ~7; - nu->type+= 4; + nu->type |= CU_NURBS; nu->orderu= 4; nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */ nu->flagu += 4; - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); a= nu->pntsu*nu->pntsv; bp= nu->bp; while(a--) { @@ -2203,7 +2203,7 @@ int convertspline(short type, Nurb *nu) if(type== 4) { nu->flagu &= CU_CYCLIC; /* disable all flags except for cyclic */ nu->flagu += 4; - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } } } @@ -2245,7 +2245,7 @@ int convertspline(short type, Nurb *nu) nu->knotsu= NULL; nu->pntsu= nr; nu->type &= ~7; - nu->type+= 1; + nu->type |= CU_BEZIER; } } } @@ -2493,12 +2493,12 @@ void merge_2_nurb(Nurb *nu1, Nurb *nu2) } } - if((nu1->type & 7)==4) { + if((nu1->type & 7)==CU_NURBS) { /* merge knots */ - makeknots(nu1, 1, nu1->flagu>>1); + makeknots(nu1, 1); /* make knots, for merged curved for example */ - makeknots(nu1, 2, nu1->flagv>>1); + makeknots(nu1, 2); } MEM_freeN(temp); @@ -2681,9 +2681,9 @@ void addsegment_nurb() BLI_remlink(&editNurb, nu2); /* now join the knots */ - if((nu1->type & 7)==4) { + if((nu1->type & 7)==CU_NURBS) { if(nu1->knotsu==NULL) { - makeknots(nu1, 1, nu1->flagu>>1); + makeknots(nu1, 1); } else { fp= MEM_mallocN(sizeof(float)*KNOTSU(nu1), "addsegment3"); @@ -2879,7 +2879,7 @@ static void spin_nurb(float *dvec, short mode) if(isNurbsel(nu)) { nu->orderv= 4; nu->flagv |= CU_CYCLIC; - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); } } } @@ -2993,7 +2993,7 @@ void addvert_Nurb(int mode) if(bp) { nu->pntsu++; - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); if(mode=='e') { VECCOPY(newbp->vec, bp->vec); @@ -3070,7 +3070,7 @@ void makecyclicNurb() for(nu= editNurb.first; nu; nu= nu->next) { if( nu->pntsu>1 || nu->pntsv>1) { - if( (nu->type & 7)==0 ) { + if( (nu->type & 7)==CU_POLY ) { a= nu->pntsu; bp= nu->bp; while(a--) { @@ -3100,7 +3100,7 @@ void makecyclicNurb() while(a--) { if( bp->f1 & SELECT ) { nu->flagu ^= CU_CYCLIC; - makeknots(nu, 1, nu->flagu>>1); /* 1==u type is ignored for cyclic curves */ + makeknots(nu, 1); /* 1==u type is ignored for cyclic curves */ break; } bp++; @@ -3119,11 +3119,11 @@ void makecyclicNurb() if( bp->f1 & SELECT) { if(cyclmode==1 && nu->pntsu>1) { nu->flagu ^= CU_CYCLIC; - makeknots(nu, 1, nu->flagu>>1); /* 1==u type is ignored for cyclic curves */ + makeknots(nu, 1); /* 1==u type is ignored for cyclic curves */ } if(cyclmode==2 && nu->pntsv>1) { nu->flagv ^= CU_CYCLIC; - makeknots(nu, 2, nu->flagv>>1); /* 2==v type is ignored for cyclic curves */ + makeknots(nu, 2); /* 2==v type is ignored for cyclic curves */ } break; } @@ -3760,7 +3760,7 @@ void delNurb() clamp_nurb_order_u(nu); }*/ } - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } nu= next; } @@ -4148,9 +4148,9 @@ Nurb *addNurbprim(int type, int stype, int newname) bp= nu->bp; for(a=0;a<4;a++, bp++) Mat3MulVecfl(imat,bp->vec); - if((type & 7)==4) { + if((type & 7)==CU_NURBS) { nu->knotsu= 0; /* makeknots allocates */ - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } } @@ -4185,7 +4185,7 @@ Nurb *addNurbprim(int type, int stype, int newname) if((type & 7)==4) { nu->knotsu= 0; /* makeknots allocates */ - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } break; @@ -4270,7 +4270,7 @@ Nurb *addNurbprim(int type, int stype, int newname) bp++; } - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); } break; case 2: /* 4x4 patch */ @@ -4307,8 +4307,8 @@ Nurb *addNurbprim(int type, int stype, int newname) } } - makeknots(nu, 1, nu->flagu>>1); - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 1); + makeknots(nu, 2); } break; case 3: /* tube */ @@ -4370,7 +4370,7 @@ Nurb *addNurbprim(int type, int stype, int newname) bp++; } nu->flagu= 4; - makeknots(nu, 1, nu->flagu>>1); + makeknots(nu, 1); BLI_addtail(&editNurb, nu); /* temporal for spin */ if(newname && (U.flag & USER_ADD_VIEWALIGNED) == 0) @@ -4378,7 +4378,7 @@ Nurb *addNurbprim(int type, int stype, int newname) else spin_nurb(0, 0); - makeknots(nu, 2, nu->flagv>>1); + makeknots(nu, 2); a= nu->pntsu*nu->pntsv; bp= nu->bp; diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 2a1d508bf59..bb9be49c347 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -2034,7 +2034,7 @@ void docenter(int centermode) nu= nu1; while(nu) { - if( (nu->type & 7)==1) { + if( (nu->type & 7)==CU_BEZIER) { a= nu->pntsu; while (a--) { VecSubf(nu->bezt[a].vec[0], nu->bezt[a].vec[0], cent); @@ -4076,7 +4076,7 @@ static void apply_objects_internal( int apply_scale, int apply_rot ) nu= cu->nurb.first; while(nu) { - if( (nu->type & 7)==1) { + if( (nu->type & 7)==CU_BEZIER) { a= nu->pntsu; bezt= nu->bezt; while(a--) { -- cgit v1.2.3 From b182778e7155abe09bd2101b851fb1178c9babb8 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 29 Mar 2009 19:54:05 +0000 Subject: Applied patch #18446, to do versions on damping Re-enable vertex welding, only for soft bodies. They require it. Future versions could expose such vertexWeldingThreshold. --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenloader/intern/readfile.c | 10 ++++++ source/blender/src/buttons_logic.c | 50 +++++++++++++++-------------- 3 files changed, 37 insertions(+), 25 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index a6334e665d1..db6d4762b17 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -41,7 +41,7 @@ struct ListBase; struct MemFile; #define BLENDER_VERSION 248 -#define BLENDER_SUBVERSION 2 +#define BLENDER_SUBVERSION 3 #define BLENDER_MINVERSION 245 #define BLENDER_MINSUBVERSION 15 diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2c6a2f2bb3a..c2eaae011c8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8024,6 +8024,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW; } } + + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { + Object *ob; + + /* Adjustments needed after Bullets update */ + for(ob = main->object.first; ob; ob= ob->id.next) { + ob->damping *= 0.635f; + ob->rdamping = 0.1 + (0.59f * ob->rdamping); + } + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 01520061a19..cf6d29da0d3 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -3122,30 +3122,32 @@ static uiBlock *advanced_bullet_menu(void *arg_ob) "Collision margin"); yco -= 20; - uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_X_AXIS, 0, "Lock X Axis", - xco, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, - "Disable simulation of linear motion along the X axis"); - uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_X_ROT_AXIS, 0, "Lock X Rot Xxis", - xco+=180, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, - "Disable simulation of angular motion along the X axis"); - yco -= 20; - xco=0; - uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Y_AXIS, 0, "Lock Y Axis", - xco, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, - "Disable simulation of linear motion along the Y axis"); - uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Y_ROT_AXIS, 0, "Lock Y Rot Axis", - xco+=180, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, - "Disable simulation of angular motion along the Y axis"); - - yco -= 20; - xco=0; - uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Z_AXIS, 0, "Lock Z Axis", - xco, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, - "Disable simulation of linear motion along the Z axis"); - uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Z_ROT_AXIS, 0, "Lock Z Rot Axis", - xco+=180, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, - "Disable simulation of angular motion along the Z axis"); - + if (ob->gameflag & OB_RIGID_BODY) + { + uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_X_AXIS, 0, "Lock X Axis", + xco, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, + "Disable simulation of linear motion along the X axis"); + uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_X_ROT_AXIS, 0, "Lock X Rot Xxis", + xco+=180, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, + "Disable simulation of angular motion along the X axis"); + yco -= 20; + xco=0; + uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Y_AXIS, 0, "Lock Y Axis", + xco, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, + "Disable simulation of linear motion along the Y axis"); + uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Y_ROT_AXIS, 0, "Lock Y Rot Axis", + xco+=180, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, + "Disable simulation of angular motion along the Y axis"); + + yco -= 20; + xco=0; + uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Z_AXIS, 0, "Lock Z Axis", + xco, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, + "Disable simulation of linear motion along the Z axis"); + uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Z_ROT_AXIS, 0, "Lock Z Rot Axis", + xco+=180, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, + "Disable simulation of angular motion along the Z axis"); + } /* uiDefButBitI(block, TOG, OB_BSB_COL_CL_RS, 0, "Cluster Collision RS", xco, yco, 180, 19, &ob->bsoft->collisionflags, 0, 0, 0, 0, -- cgit v1.2.3 From ac2de0f28dd674bdd151bcb945e5f67250902cff Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 30 Mar 2009 15:26:14 +0000 Subject: Hide full retarget panels behind rt -1 (not ready for large scale use and not too well documented yet. Doesn't affect etch-a-ton. --- source/blender/src/buttons_editing.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 2f77e3659ee..80495b9ff80 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -6858,9 +6858,12 @@ void editing_panels() uiNewPanelTabbed("Mesh Tools 1", "Editing"); #ifdef WITH_BF_REEB - editing_panel_mesh_skgen(ob, ob->data); - editing_panel_mesh_skgen_retarget(ob, ob->data); - editing_panel_mesh_skgen_display(ob, ob->data); + if (G.rt == -1) + { + editing_panel_mesh_skgen(ob, ob->data); + editing_panel_mesh_skgen_retarget(ob, ob->data); + editing_panel_mesh_skgen_display(ob, ob->data); + } #endif editing_panel_mesh_uvautocalculation(); -- cgit v1.2.3 From 22ad99783a811e60ee75288c6864331c4be26b4d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Mar 2009 00:58:02 +0000 Subject: [#18277] Segfault crash by editing mesh with subsurf+ParticleInstance modifiers Marked as fixed but was still using uninitialized variables. --- source/blender/blenkernel/intern/modifier.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 566a139f72c..b3892a515af 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6382,6 +6382,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier( if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED)){ float min_r[3], max_r[3]; + INIT_MINMAX(min_r, max_r); dm->getMinMax(dm, min_r, max_r); min_co=min_r[track]; max_co=max_r[track]; -- cgit v1.2.3 From 97af551cb738a6c27bd53acdffd0eba04470f8c6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Mar 2009 06:22:25 +0000 Subject: [#18439] Controlling the bevel shape for a text object with a curve no longer works. own fault, broke rev16702. Curves created by fonts didnt have their radius set. Forgot do do this when making radius calculated with the curve (like tilt) --- source/blender/blenkernel/BKE_curve.h | 4 ++++ source/blender/blenkernel/intern/curve.c | 4 ++-- source/blender/blenlib/intern/freetypefont.c | 2 ++ source/blender/blenlib/intern/psfont.c | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index a6619958797..a8d4ece7a21 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -46,6 +46,10 @@ 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_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || cu->bevobj) ? 1:0) + + void unlink_curve( struct Curve *cu); void free_curve( struct Curve *cu); struct Curve *add_curve(char *name, int type); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index e303f78b163..0d6382a8d37 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1535,8 +1535,8 @@ void makeBevelList(Object *ob) while(nu) { /* check if we will calculate tilt data */ - do_tilt = ((nu->type & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1; - do_radius = (do_tilt || cu->bevobj) ? 1 : 0; /* normal display uses the radius, better just to calculate them */ + do_tilt = CU_DO_TILT(cu, nu); + do_radius = CU_DO_RADIUS(cu, nu); /* normal display uses the radius, better just to calculate them */ /* check we are a single point? also check we are not a surface and that the orderu is sane, * enforced in the UI but can go wrong possibly */ diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 48a40db6a72..a97f2460ba1 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -178,6 +178,7 @@ void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) bezt->vec[2][1] = (dy + (2 * ftoutline.points[l+1].y)* scale) / 3.0; bezt->h1= bezt->h2= HD_ALIGN; + bezt->radius= 1.0f; bezt++; } } @@ -264,6 +265,7 @@ void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) { bezt->h1= bezt->h2= HD_ALIGN; } + bezt->radius= 1.0f; bezt++; } } diff --git a/source/blender/blenlib/intern/psfont.c b/source/blender/blenlib/intern/psfont.c index 54d7f8ec1af..39d38e4cf3a 100644 --- a/source/blender/blenlib/intern/psfont.c +++ b/source/blender/blenlib/intern/psfont.c @@ -2094,6 +2094,7 @@ static VFontData *objfnt_to_vfontdata(objfnt *fnt) while(a--) { if(bezt->h1!=HD_ALIGN && bezt->h2==HD_ALIGN) bezt->h2= 0; else if(bezt->h2!=HD_ALIGN && bezt->h1==HD_ALIGN) bezt->h1= 0; + bezt->radius= 1.0f; bezt++; } -- cgit v1.2.3 From 74e6231ff45dfe09d213a4deb72641e8138e260c Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 31 Mar 2009 14:29:58 +0000 Subject: == etch-a-ton == Correct joint-guided roll to use the previous bone, not the following (that was silly). Also made first bone use view axis (since it has no previous), this is much nicer that using rotation correction only. Using the joint roll option makes it MUCH more orientation independant. --- source/blender/src/editarmature_retarget.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/editarmature_retarget.c b/source/blender/src/editarmature_retarget.c index ad114868a69..f42fed06757 100644 --- a/source/blender/src/editarmature_retarget.c +++ b/source/blender/src/editarmature_retarget.c @@ -201,12 +201,12 @@ float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], } } -float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float qroll[4]) +float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float qroll[4], float up_axis[3]) { if (previous == NULL) { - QuatOne(qroll); - return rollBoneByQuat(edge->bone, edge->up_axis, qrot); + /* default to up_axis if no previous */ + return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis); } else { @@ -223,9 +223,8 @@ float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float } else { - /* SHOULDN'T BE HERE */ - QuatOne(qroll); - return rollBoneByQuat(edge->bone, edge->up_axis, qrot); + /* default to up_axis if first bone in the chain is an offset */ + return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis); } VecSubf(vec_second, edge->bone->tail, edge->bone->head); @@ -1846,7 +1845,7 @@ static void repositionBone(RigGraph *rigg, RigEdge *edge, float vec0[3], float v } else if (G.scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_JOINT) { - bone->roll = rollBoneByQuatJoint(edge, edge->next, qrot, qroll); + bone->roll = rollBoneByQuatJoint(edge, edge->prev, qrot, qroll, up_axis); } else { -- cgit v1.2.3 From 1f0e5f5807f796a6c90aadf9e86916bd69c89a23 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 31 Mar 2009 19:39:17 +0000 Subject: [#18455] The new FFMPEG version gives the wrong color ffmpeg format switched from RGBA32 to BGR32, it's no longer needed to swap color planes. NOTE: this commit also attempts to fix the big endian case, but since I don't have a machine to test it, I'd appreciate if someone else would. --- source/blender/blenkernel/intern/writeffmpeg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 378e4319223..c3d8ed855a2 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -315,9 +315,9 @@ static AVFrame* generate_video_frame(uint8_t* pixels) uint8_t* end = src + width * 4; while (src != end) { target[3] = src[3]; - target[2] = src[0]; + target[2] = src[2]; target[1] = src[1]; - target[0] = src[2]; + target[0] = src[0]; target += 4; src += 4; @@ -331,9 +331,9 @@ static AVFrame* generate_video_frame(uint8_t* pixels) uint8_t* src = rendered_frame + width * 4 * y; uint8_t* end = src + width * 4; while (src != end) { - target[3] = src[2]; + target[3] = src[0]; target[2] = src[1]; - target[1] = src[0]; + target[1] = src[2]; target[0] = src[3]; target += 4; -- cgit v1.2.3 From 441f26a1702444d256a54e5baf67bc7c07d75af5 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Tue, 31 Mar 2009 22:34:34 +0000 Subject: Clean up for the imminent migration from SVN to GIT. --- source/blender/blenkernel/BKE_bmesh.h | 2 +- source/blender/blenkernel/BKE_bmeshCustomData.h | 2 +- source/blender/blenkernel/BKE_cloth.h | 2 +- source/blender/blenkernel/BKE_collision.h | 2 +- source/blender/blenkernel/BKE_particle.h | 2 +- source/blender/blenkernel/BKE_suggestions.h | 2 +- source/blender/blenkernel/intern/BME_Customdata.c | 2 +- source/blender/blenkernel/intern/BME_conversions.c | 2 +- source/blender/blenkernel/intern/BME_eulers.c | 2 +- source/blender/blenkernel/intern/BME_mesh.c | 2 +- source/blender/blenkernel/intern/BME_structure.c | 2 +- source/blender/blenkernel/intern/BME_tools.c | 2 +- source/blender/blenkernel/intern/bmesh_private.h | 2 +- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/suggestions.c | 2 +- source/blender/imbuf/intern/IMB_jp2.h | 2 +- source/blender/imbuf/intern/dds/Makefile | 2 +- source/blender/include/BDR_sketch.h | 2 +- source/blender/include/BIF_editparticle.h | 2 +- source/blender/include/BIF_generate.h | 2 +- source/blender/include/BIF_radialcontrol.h | 2 +- source/blender/include/BIF_retarget.h | 2 +- source/blender/include/BIF_sketch.h | 2 +- source/blender/include/BSE_editaction_types.h | 2 +- source/blender/makesdna/DNA_cloth_types.h | 2 +- source/blender/makesdna/DNA_particle_types.h | 2 +- source/blender/nodes/TEX_node.h | 2 +- source/blender/nodes/intern/CMP_nodes/CMP_normalize.c | 2 +- source/blender/nodes/intern/SHD_nodes/SHD_invert.c | 2 +- source/blender/nodes/intern/TEX_nodes/Makefile | 2 +- source/blender/nodes/intern/TEX_nodes/TEX_image.c | 2 +- source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c | 2 +- source/blender/python/api2_2x/doc/epy_docgen.sh | 0 source/blender/render/intern/source/raytrace.c | 2 +- source/blender/src/editarmature_generate.c | 2 +- source/blender/src/editarmature_sketch.c | 2 +- source/blender/src/editparticle.c | 2 +- source/blender/src/radialcontrol.c | 2 +- 39 files changed, 38 insertions(+), 38 deletions(-) mode change 100644 => 100755 source/blender/python/api2_2x/doc/epy_docgen.sh (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h index 8ec7144faf6..04ffc0a4092 100644 --- a/source/blender/blenkernel/BKE_bmesh.h +++ b/source/blender/blenkernel/BKE_bmesh.h @@ -3,7 +3,7 @@ * * BMesh modeler structure and functions. * - * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/BKE_bmeshCustomData.h b/source/blender/blenkernel/BKE_bmeshCustomData.h index 4f5f2641f54..e910fc13ed4 100644 --- a/source/blender/blenkernel/BKE_bmeshCustomData.h +++ b/source/blender/blenkernel/BKE_bmeshCustomData.h @@ -3,7 +3,7 @@ * * BMesh modeler structure and functions. * - * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index f3c13d3d820..28c826d17c3 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -1,7 +1,7 @@ /** * BKE_cloth.h * - * $Id: BKE_cloth.h,v 1.1 2007/08/01 02:07:27 daniel Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/BKE_collision.h b/source/blender/blenkernel/BKE_collision.h index c483148e4de..5e6485d48a3 100644 --- a/source/blender/blenkernel/BKE_collision.h +++ b/source/blender/blenkernel/BKE_collision.h @@ -1,7 +1,7 @@ /** * BKE_cloth.h * - * $Id: BKE_cloth.h,v 1.1 2007/08/01 02:07:27 daniel Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index caba63ef8ce..ecc97dd5d3b 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -1,7 +1,7 @@ /* BKE_particle.h * * - * $Id: BKE_particle.h $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/BKE_suggestions.h b/source/blender/blenkernel/BKE_suggestions.h index d58b8f58bf5..473e3f547f2 100644 --- a/source/blender/blenkernel/BKE_suggestions.h +++ b/source/blender/blenkernel/BKE_suggestions.h @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/BME_Customdata.c b/source/blender/blenkernel/intern/BME_Customdata.c index 1fc8a4071dc..ea149e03959 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -3,7 +3,7 @@ * * Custom Data functions for Bmesh * - * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index daf0de5b748..39af580969f 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -3,7 +3,7 @@ * * BMesh mesh level functions. * - * $Id: BME_eulers.c,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index 801e0b8bdec..d0b4ab6a9ca 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -3,7 +3,7 @@ * * BMesh Euler construction API. * - * $Id: BME_eulers.c,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index ad46a7c1eb7..f635cfcfcd2 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -3,7 +3,7 @@ * * BMesh mesh level functions. * - * $Id: BME_eulers.c,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index ca27f5efd10..22ee48e4f7e 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -3,7 +3,7 @@ * * Low level routines for manipulating the BMesh structure. * - * $Id: BME_structure.c,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 90259031e5c..f3e4add34e9 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -3,7 +3,7 @@ * * Functions for changing the topology of a mesh. * - * $Id: BME_eulers.c,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/bmesh_private.h b/source/blender/blenkernel/intern/bmesh_private.h index f34ef0090f3..dd7d20bcf15 100644 --- a/source/blender/blenkernel/intern/bmesh_private.h +++ b/source/blender/blenkernel/intern/bmesh_private.h @@ -3,7 +3,7 @@ * * low level, 'private' function prototypes for bmesh kernel. * - * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 44ee5c236fa..c2304c86bee 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1,7 +1,7 @@ /* particle.c * * - * $Id: particle.c $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 8a964c5b32e..7bda29ebcaf 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1,7 +1,7 @@ /* particle_system.c * * - * $Id: particle_system.c $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index 6530909336c..dee33656332 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/imbuf/intern/IMB_jp2.h b/source/blender/imbuf/intern/IMB_jp2.h index fcdd4589fca..abc6b78357c 100644 --- a/source/blender/imbuf/intern/IMB_jp2.h +++ b/source/blender/imbuf/intern/IMB_jp2.h @@ -1,7 +1,7 @@ /* * IMB_jp2.h * - * $Id: IMB_bmp.h 14444 2008-04-16 22:40:48Z hos $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/imbuf/intern/dds/Makefile b/source/blender/imbuf/intern/dds/Makefile index 28f9e24c947..e14f9320d19 100644 --- a/source/blender/imbuf/intern/dds/Makefile +++ b/source/blender/imbuf/intern/dds/Makefile @@ -1,5 +1,5 @@ # -# $Id: Makefile 7037 2006-03-12 14:11:23Z ton $ +# $Id$ # # ***** BEGIN GPL LICENSE BLOCK ***** # diff --git a/source/blender/include/BDR_sketch.h b/source/blender/include/BDR_sketch.h index 55d6e1d80cf..d64f763eccd 100644 --- a/source/blender/include/BDR_sketch.h +++ b/source/blender/include/BDR_sketch.h @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/include/BIF_editparticle.h b/source/blender/include/BIF_editparticle.h index 2db9aacc96b..9abf4e6c2b4 100644 --- a/source/blender/include/BIF_editparticle.h +++ b/source/blender/include/BIF_editparticle.h @@ -1,7 +1,7 @@ /* BIF_editparticle.h * * - * $Id: BIF_editparticle.h $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/include/BIF_generate.h b/source/blender/include/BIF_generate.h index e64edf99bdc..fa70c10ac2c 100644 --- a/source/blender/include/BIF_generate.h +++ b/source/blender/include/BIF_generate.h @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/include/BIF_radialcontrol.h b/source/blender/include/BIF_radialcontrol.h index 81181a3a91e..a23b9c7aa61 100644 --- a/source/blender/include/BIF_radialcontrol.h +++ b/source/blender/include/BIF_radialcontrol.h @@ -1,5 +1,5 @@ /* - * $Id: multires.h 13015 2007-12-27 07:27:03Z nicholasbishop $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/include/BIF_retarget.h b/source/blender/include/BIF_retarget.h index 9de10fb2a38..0a58f298990 100644 --- a/source/blender/include/BIF_retarget.h +++ b/source/blender/include/BIF_retarget.h @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/include/BIF_sketch.h b/source/blender/include/BIF_sketch.h index 9cd7393633e..2419d915b14 100644 --- a/source/blender/include/BIF_sketch.h +++ b/source/blender/include/BIF_sketch.h @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/include/BSE_editaction_types.h b/source/blender/include/BSE_editaction_types.h index be210415973..c0842d405e3 100644 --- a/source/blender/include/BSE_editaction_types.h +++ b/source/blender/include/BSE_editaction_types.h @@ -1,5 +1,5 @@ /** - * $Id: BIF_editaction.h 10519 2007-04-13 11:15:08Z aligorith $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index c99dc44cd5e..311a70c93ca 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -1,5 +1,5 @@ /** -* $Id: DNA_cloth_types.h,v 1.1 2007/08/01 02:28:34 daniel Exp $ +* $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 7dd69b2151c..52d427eda4e 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -1,7 +1,7 @@ /* DNA_particle_types.h * * - * $Id: DNA_particle_types.h $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/nodes/TEX_node.h b/source/blender/nodes/TEX_node.h index c52fc757507..d298f062143 100644 --- a/source/blender/nodes/TEX_node.h +++ b/source/blender/nodes/TEX_node.h @@ -1,5 +1,5 @@ /** - * $Id: CMP_node.h 12429 2007-10-29 14:37:19Z bebraw $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c b/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c index a62e4be4015..846aec490c2 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_normalize.c @@ -1,5 +1,5 @@ /** - * $Id: CMP_normalize.c,v 1.0 2007/03/24 06:57:29 scourage Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_invert.c b/source/blender/nodes/intern/SHD_nodes/SHD_invert.c index 72ee1483ecf..fbab7f64cb3 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_invert.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_invert.c @@ -1,5 +1,5 @@ /** - * $Id: SHD_math.c,v 1.4 2007/04/04 13:58:12 jesterking Exp $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/nodes/intern/TEX_nodes/Makefile b/source/blender/nodes/intern/TEX_nodes/Makefile index 7fad19a772c..ac741280478 100644 --- a/source/blender/nodes/intern/TEX_nodes/Makefile +++ b/source/blender/nodes/intern/TEX_nodes/Makefile @@ -1,5 +1,5 @@ # -# $Id: Makefile 12796 2007-12-05 16:58:52Z sirdude $ +# $Id$ # # ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** # diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c index f9477fef12b..b84088da154 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c @@ -1,5 +1,5 @@ /** - * $Id: TEX_image.c 10456 2007-04-04 13:58:12Z jesterking $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c index ec59769fdfd..71d9cb07e18 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c @@ -1,5 +1,5 @@ /** - * $Id: SHD_valToRgb.c 10456 2007-04-04 13:58:12Z jesterking $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh old mode 100644 new mode 100755 diff --git a/source/blender/render/intern/source/raytrace.c b/source/blender/render/intern/source/raytrace.c index ec47df74d04..09d3711885a 100644 --- a/source/blender/render/intern/source/raytrace.c +++ b/source/blender/render/intern/source/raytrace.c @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/src/editarmature_generate.c b/source/blender/src/editarmature_generate.c index 189a823ab98..ad312f079bd 100644 --- a/source/blender/src/editarmature_generate.c +++ b/source/blender/src/editarmature_generate.c @@ -1,5 +1,5 @@ /** - * $Id: editarmature_generate.c $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/src/editarmature_sketch.c b/source/blender/src/editarmature_sketch.c index 1452a3d0441..38e44319b47 100644 --- a/source/blender/src/editarmature_sketch.c +++ b/source/blender/src/editarmature_sketch.c @@ -1,5 +1,5 @@ /** - * $Id: $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/src/editparticle.c b/source/blender/src/editparticle.c index 0538bcb98d7..d48b84789d8 100644 --- a/source/blender/src/editparticle.c +++ b/source/blender/src/editparticle.c @@ -1,7 +1,7 @@ /* editparticle.c * * - * $Id: editparticle.c $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/src/radialcontrol.c b/source/blender/src/radialcontrol.c index 404aac225c6..b61a150bada 100644 --- a/source/blender/src/radialcontrol.c +++ b/source/blender/src/radialcontrol.c @@ -1,5 +1,5 @@ /* - * $Id: multires.c 13015 2007-12-27 07:27:03Z nicholasbishop $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From 655177aebdb51bb0572f093bcb25503f1427685a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Apr 2009 06:39:09 +0000 Subject: [#18452] Particle children API for python. from Alberto Santos (dnakhain) "This patch adds a few new variables relationated with Particle System children such as children amount, render amount, child clumping..." --- source/blender/python/api2_2x/Particle.c | 215 ++++++++++++++++++++++++++ source/blender/python/api2_2x/doc/Particle.py | 23 +++ 2 files changed, 238 insertions(+) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/Particle.c b/source/blender/python/api2_2x/Particle.c index bbdc3942fc7..c3f2e0f89c0 100644 --- a/source/blender/python/api2_2x/Particle.c +++ b/source/blender/python/api2_2x/Particle.c @@ -134,6 +134,24 @@ static PyObject *Part_getRenderStep( BPy_PartSys * self ); static PyObject *Part_getDupOb( BPy_PartSys * self ); static PyObject *Part_getDrawAs( BPy_PartSys * self ); static PyObject *Part_GetAge( BPy_PartSys * self, PyObject * args ); +static int Part_setChildAmount( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildAmount( BPy_PartSys * self ); +static int Part_setChildType( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildType( BPy_PartSys * self ); +static int Part_setChildRenderAmount( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRenderAmount( BPy_PartSys * self ); +static int Part_setChildRadius( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRadius( BPy_PartSys * self ); +static int Part_setChildRoundness( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRoundness( BPy_PartSys * self ); +static int Part_setChildClumping( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildClumping( BPy_PartSys * self ); +static int Part_setChildShape( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildShape( BPy_PartSys * self ); +static int Part_setChildSize( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildSize( BPy_PartSys * self ); +static int Part_setChildRandom( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRandom( BPy_PartSys * self ); /*****************************************************************************/ /* Python Effect_Type callback function prototypes: */ @@ -316,6 +334,43 @@ static PyGetSetDef BPy_ParticleSys_getseters[] = { (getter)Part_getDrawAs, NULL, "Get draw type Particle.DRAWAS([ 'NONE' | 'OBJECT' | 'POINT' | ... ] )", NULL}, +/* Children */ + {"childAmount", + (getter)Part_getChildAmount, (setter)Part_setChildAmount, + "The total number of children", + NULL}, + {"childType", + (getter)Part_getChildType, (setter)Part_setChildType, + "Type of childrens ( Particle.CHILDTYPE[ 'FACES' | 'PARTICLES' | 'NONE' ] )", + NULL}, + {"childRenderAmount", + (getter)Part_getChildRenderAmount, (setter)Part_setChildRenderAmount, + "Amount of children/parent for rendering", + NULL}, + {"childRadius", + (getter)Part_getChildRadius, (setter)Part_setChildRadius, + "Radius of children around parent", + NULL}, + {"childRound", + (getter)Part_getChildRoundness, (setter)Part_setChildRoundness, + "Roundness of children around parent", + NULL}, + {"childClump", + (getter)Part_getChildClumping, (setter)Part_setChildClumping, + "Amount of clumpimg", + NULL}, + {"childShape", + (getter)Part_getChildShape, (setter)Part_setChildShape, + "Shape of clumpimg", + NULL}, + {"childSize", + (getter)Part_getChildSize, (setter)Part_setChildSize, + "A multiplier for the child particle size", + NULL}, + {"childRand", + (getter)Part_getChildRandom, (setter)Part_setChildRandom, + "Random variation to the size of the child particles", + NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; @@ -710,6 +765,26 @@ static PyObject *Particle_ReactOnDict( void ) return ReactOn; } + +/* create the Blender.Particle.ChildType constant dict */ + +static PyObject *Particle_ChildTypeDict( void ) +{ + PyObject *ChildTypes = PyConstant_New( ); + + if( ChildTypes ) { + BPy_constant *c = ( BPy_constant * ) ChildTypes; + + PyConstant_Insert( c, "FACES", + PyInt_FromLong( 2 ) ); + PyConstant_Insert( c, "PARTICLES", + PyInt_FromLong( 1 ) ); + PyConstant_Insert( c, "NONE", + PyInt_FromLong( 0 ) ); + } + return ChildTypes; +} + static PyObject *Particle_DrawAs( void ) { PyObject *DrawAs = PyConstant_New( ); @@ -756,6 +831,8 @@ PyObject *ParticleSys_Init( void ){ PyObject *EmitFrom; PyObject *Dist; PyObject *DrawAs; + PyObject *ChildTypes; + if( PyType_Ready( &ParticleSys_Type ) < 0) return NULL; @@ -765,6 +842,7 @@ PyObject *ParticleSys_Init( void ){ EmitFrom = Particle_EmitFrom(); DrawAs = Particle_DrawAs(); Dist = Particle_DistrDict(); + ChildTypes = Particle_ChildTypeDict(); submodule = Py_InitModule3( "Blender.Particle", M_ParticleSys_methods, M_ParticleSys_doc ); @@ -779,6 +857,8 @@ PyObject *ParticleSys_Init( void ){ PyModule_AddObject( submodule, "DISTRIBUTION", Dist ); if( DrawAs ) PyModule_AddObject( submodule, "DRAWAS", DrawAs ); + if( ChildTypes ) + PyModule_AddObject( submodule, "CHILDTYPE", ChildTypes ); return ( submodule ); } @@ -2010,3 +2090,138 @@ static PyObject *Part_getDrawAs( BPy_PartSys * self ) { return PyInt_FromLong( (long)( self->psys->part->draw_as ) ); } + +static int Part_setChildAmount( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setIValueRange( args, &self->psys->part->child_nbr, + 0, MAX_PART_CHILDREN, 'i' ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildAmount( BPy_PartSys * self ) +{ + return PyInt_FromLong( ((int)( self->psys->part->child_nbr )) ); +} + +static int Part_setChildType( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setIValueRange( args, &self->psys->part->childtype, + 0, 2, 'h' ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildType( BPy_PartSys * self ) +{ + return PyInt_FromLong( (short)( self->psys->part->childtype ) ); +} + +static int Part_setChildRenderAmount( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setIValueRange( args, &self->psys->part->ren_child_nbr, + 0, MAX_PART_CHILDREN, 'i' ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRenderAmount( BPy_PartSys * self ) +{ + return PyInt_FromLong( ((int)( self->psys->part->ren_child_nbr )) ); +} + +static int Part_setChildRadius( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->childrad, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRadius( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->childrad )) ); +} + +static int Part_setChildRoundness( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->childflat, + 0.0, 1.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRoundness( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->childflat )) ); +} + +static int Part_setChildClumping( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->clumpfac, + -1.0, 1.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildClumping( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->clumpfac )) ); +} + +static int Part_setChildShape( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->clumppow, + -0.999, 0.999 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildShape( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->clumppow )) ); +} + +static int Part_setChildSize( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->childsize, + 0.01, 100.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildSize( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->childsize )) ); +} + +static int Part_setChildRandom( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->childrandsize, + 0.0, 1.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRandom( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->childrandsize )) ); +} diff --git a/source/blender/python/api2_2x/doc/Particle.py b/source/blender/python/api2_2x/doc/Particle.py index cf662d9147a..47bcc7c88a3 100644 --- a/source/blender/python/api2_2x/doc/Particle.py +++ b/source/blender/python/api2_2x/doc/Particle.py @@ -42,6 +42,11 @@ This module provides access to the B{Particle} in Blender. - OBJECT: Draw object - GROUP: Draw goup - BILLBOARD: Draw as billboard +@type CHILDTYPE: readonly dictionary +@var CHILDTYPE: Constant dict used for whith L{Particle.CHILDTYPE} + - NONE: set no children + - PARTICLES: set children born from particles + - FACES: set children born from faces """ class Particle: @@ -118,6 +123,24 @@ class Particle: @type duplicateObject: Blender Object @ivar drawAs: Get draw type Particle.DRAWAS([ 'NONE' | 'OBJECT' | 'POINT' | ... ]). @type drawAs: int + @ivar childAmount: The total number of children + @type childAmount: int + @ivar childType: Type of childrens ( Particle.CHILDTYPE[ 'FACES' | 'PARTICLES' | 'NONE' ] ) + @type childType: int + @ivar childRenderAmount: Amount of children/parent for rendering + @type childRenderAmount: int + @ivar childRadius: Radius of children around parent + @type childRadius: float + @ivar childRound: Roundness of children around parent + @type childRound: float + @ivar childClump: Amount of clumpimg + @type childClump: float + @ivar childShape: Shape of clumpimg + @type childShape: float + @ivar childSize: A multiplier for the child particle size + @type childSize: float + @ivar childRand: Random variation to the size of the child particles + @type childRand: float """ def freeEdit(): -- cgit v1.2.3 From 8ca30120a206c8b78645dd3d45c9891acaeebac1 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Fri, 3 Apr 2009 03:16:31 +0000 Subject: made grease pencil delete a frame if you delete all the strokes in it. --- source/blender/include/BDR_gpencil.h | 2 +- source/blender/src/drawgpencil.c | 2 +- source/blender/src/gpencil.c | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BDR_gpencil.h b/source/blender/include/BDR_gpencil.h index 6af156775be..6848be2a481 100644 --- a/source/blender/include/BDR_gpencil.h +++ b/source/blender/include/BDR_gpencil.h @@ -65,7 +65,7 @@ struct bGPdata *gpencil_data_getactive(struct ScrArea *sa); short gpencil_data_setactive(struct ScrArea *sa, struct bGPdata *gpd); struct ScrArea *gpencil_data_findowner(struct bGPdata *gpd); -void gpencil_frame_delete_laststroke(struct bGPDframe *gpf); +void gpencil_frame_delete_laststroke(struct bGPDframe *gpf, bGPDlayer *gpl); struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, short addnew); void gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf); diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c index 1b3d869b2f8..914a604de44 100644 --- a/source/blender/src/drawgpencil.c +++ b/source/blender/src/drawgpencil.c @@ -140,7 +140,7 @@ void gp_ui_delstroke_cb (void *gpd, void *gpl) bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); gpencil_layer_setactive(gpd, gpl); - gpencil_frame_delete_laststroke(gpf); + gpencil_frame_delete_laststroke(gpf, gpl); scrarea_queue_winredraw(curarea); } diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c index f4cfc0c0dd6..fa502a1af59 100644 --- a/source/blender/src/gpencil.c +++ b/source/blender/src/gpencil.c @@ -484,7 +484,7 @@ ScrArea *gpencil_data_findowner (bGPdata *gpd) /* -------- GP-Frame API ---------- */ /* delete the last stroke of the given frame */ -void gpencil_frame_delete_laststroke (bGPDframe *gpf) +void gpencil_frame_delete_laststroke (bGPDframe *gpf, bGPDlayer *gpl) { bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL; @@ -495,6 +495,11 @@ void gpencil_frame_delete_laststroke (bGPDframe *gpf) /* free the stroke and its data */ MEM_freeN(gps->points); BLI_freelinkN(&gpf->strokes, gps); + + if (gpf->strokes.first == NULL) { + gpencil_layer_delframe(gpl, gpf); + gpencil_layer_getframe(gpl, CFRA, 0); + } } /* -------- GP-Layer API ---------- */ @@ -603,6 +608,7 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) else if (found) gpl->actframe= gpf; else { + gpl->actframe = gpl->frames.first; /* unresolved errogenous situation! */ printf("Error: cannot find appropriate gp-frame \n"); /* gpl->actframe should still be NULL */ @@ -696,7 +702,7 @@ void gpencil_delete_laststroke (bGPdata *gpd) bGPDlayer *gpl= gpencil_layer_getactive(gpd); bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); - gpencil_frame_delete_laststroke(gpf); + gpencil_frame_delete_laststroke(gpf, gpl); } /* delete the active frame */ -- cgit v1.2.3 From 60bd7d12fcde42ff048a0c83684b1b53dfec6f93 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Fri, 3 Apr 2009 04:36:38 +0000 Subject: fix for last commit, needed some additional checks --- source/blender/src/drawgpencil.c | 2 ++ source/blender/src/gpencil.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'source/blender') diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c index 914a604de44..3c6cef469a2 100644 --- a/source/blender/src/drawgpencil.c +++ b/source/blender/src/drawgpencil.c @@ -139,6 +139,8 @@ void gp_ui_delstroke_cb (void *gpd, void *gpl) { bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + if (gpf->framenum != CFRA) return; + gpencil_layer_setactive(gpd, gpl); gpencil_frame_delete_laststroke(gpf, gpl); diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c index fa502a1af59..c7e453c416c 100644 --- a/source/blender/src/gpencil.c +++ b/source/blender/src/gpencil.c @@ -702,6 +702,8 @@ void gpencil_delete_laststroke (bGPdata *gpd) bGPDlayer *gpl= gpencil_layer_getactive(gpd); bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + if (gpf->framenum != CFRA) return; + gpencil_frame_delete_laststroke(gpf, gpl); } -- cgit v1.2.3 From 5934757089af90438ac82235d4db5f040454e10b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Apr 2009 14:41:31 +0000 Subject: Bug fix: hair or child particles didn't react to density texture. --- source/blender/blenkernel/intern/particle.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index c2304c86bee..b1ed165fedd 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2050,9 +2050,10 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, ptex.clump=1.0; ptex.kink=1.0; ptex.rough= 1.0; + ptex.exist= 1.0; get_cpa_texture(ctx->dm,ctx->ma,cpa_num,cpa_fuv,orco,&ptex, - MAP_PA_LENGTH|MAP_PA_CLUMP|MAP_PA_KINK|MAP_PA_ROUGH); + MAP_PA_DENS|MAP_PA_LENGTH|MAP_PA_CLUMP|MAP_PA_KINK|MAP_PA_ROUGH); pa_length=ptex.length; pa_clump=ptex.clump; @@ -2062,6 +2063,11 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, pa_roughe=ptex.rough; pa_effector= 1.0f; + if(ptex.exist < cpa->rand[1]) { + keys->steps = -1; + return; + } + if(ctx->vg_length) pa_length*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_length); if(ctx->vg_clump) @@ -3165,6 +3171,8 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float ptex->kink= texture_value_blend(def,ptex->kink,value,var,blend,neg & MAP_PA_KINK); if((event & mtex->pmapto) & MAP_PA_ROUGH) ptex->rough= texture_value_blend(def,ptex->rough,value,var,blend,neg & MAP_PA_ROUGH); + if((event & mtex->pmapto) & MAP_PA_DENS) + ptex->exist= texture_value_blend(def,ptex->exist,value,var,blend,neg & MAP_PA_DENS); } } if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); } @@ -3172,6 +3180,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); } if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); } if(event & MAP_PA_ROUGH) { CLAMP(ptex->rough,0.0,1.0); } + if(event & MAP_PA_DENS) { CLAMP(ptex->exist,0.0,1.0); } } void psys_get_texture(Object *ob, Material *ma, ParticleSystemModifierData *psmd, ParticleSystem *psys, ParticleData *pa, ParticleTexture *ptex, int event) { @@ -3859,4 +3868,3 @@ void psys_get_dupli_path_transform(Object *ob, ParticleSystem *psys, ParticleSys *scale= len; } - -- cgit v1.2.3 From e30cb79aaa8d9a25b66c57aa08fb79bf591b6be4 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Apr 2009 14:50:54 +0000 Subject: Major cleanup of particle render & drawing code. No new features and hopefully no new bugs. --- source/blender/blenkernel/BKE_particle.h | 15 + source/blender/blenkernel/intern/particle.c | 73 ++ .../blender/render/intern/source/convertblender.c | 934 ++++++++++----------- source/blender/src/drawobject.c | 350 +++----- 4 files changed, 659 insertions(+), 713 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index ecc97dd5d3b..5dbfe2fe520 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -188,6 +188,19 @@ typedef struct ParticleThread { int num, tot; } ParticleThread; +typedef struct ParticleBillboardData +{ + struct Object *ob; + float vec[3], vel[3]; + float offset[2]; + float size, tilt, random, time; + int uv[3]; + int lock, num; + int totnum; + short align, uv_split, anim, split_offset; +} +ParticleBillboardData; + /* ----------- functions needed outside particlesystem ---------------- */ /* particle.c */ int count_particles(struct ParticleSystem *psys); @@ -260,6 +273,8 @@ void psys_threads_free(ParticleThread *threads); void psys_thread_distribute_particle(ParticleThread *thread, struct ParticleData *pa, struct ChildParticle *cpa, int p); void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, ParticleCacheKey *keys, int i); +void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]); + /* particle_system.c */ int psys_count_keyed_targets(struct Object *ob, struct ParticleSystem *psys); void psys_get_reactor_target(struct Object *ob, struct ParticleSystem *psys, struct Object **target_ob, struct ParticleSystem **target_psys); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index b1ed165fedd..4eabb82f6cb 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3868,3 +3868,76 @@ void psys_get_dupli_path_transform(Object *ob, ParticleSystem *psys, ParticleSys *scale= len; } + +void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]) +{ + float onevec[3] = {0.0f,0.0f,0.0f}, tvec[3], tvec2[3]; + + xvec[0] = 1.0f; xvec[1] = 0.0f; xvec[2] = 0.0f; + yvec[0] = 0.0f; yvec[1] = 1.0f; yvec[2] = 0.0f; + + if(bb->align < PART_BB_VIEW) + onevec[bb->align]=1.0f; + + if(bb->lock && (bb->align == PART_BB_VIEW)) { + VECCOPY(xvec, bb->ob->obmat[0]); + Normalize(xvec); + + VECCOPY(yvec, bb->ob->obmat[1]); + Normalize(yvec); + + VECCOPY(zvec, bb->ob->obmat[2]); + Normalize(zvec); + } + else if(bb->align == PART_BB_VEL) { + float temp[3]; + + VECCOPY(temp, bb->vel); + Normalize(temp); + + VECSUB(zvec, bb->ob->obmat[3], bb->vec); + + if(bb->lock) { + float fac = -Inpf(zvec, temp); + + VECADDFAC(zvec, zvec, temp, fac); + } + Normalize(zvec); + + Crossf(xvec,temp,zvec); + Normalize(xvec); + + Crossf(yvec,zvec,xvec); + } + else { + VECSUB(zvec, bb->ob->obmat[3], bb->vec); + if(bb->lock) + zvec[bb->align] = 0.0f; + Normalize(zvec); + + if(bb->align < PART_BB_VIEW) + Crossf(xvec, onevec, zvec); + else + Crossf(xvec, bb->ob->obmat[1], zvec); + Normalize(xvec); + + Crossf(yvec,zvec,xvec); + } + + VECCOPY(tvec, xvec); + VECCOPY(tvec2, yvec); + + VecMulf(xvec, cos(bb->tilt * (float)M_PI)); + VecMulf(tvec2, sin(bb->tilt * (float)M_PI)); + VECADD(xvec, xvec, tvec2); + + VecMulf(yvec, cos(bb->tilt * (float)M_PI)); + VecMulf(tvec, -sin(bb->tilt * (float)M_PI)); + VECADD(yvec, yvec, tvec); + + VecMulf(xvec, bb->size); + VecMulf(yvec, bb->size); + + VECADDFAC(center, bb->vec, xvec, bb->offset[0]); + VECADDFAC(center, center, yvec, bb->offset[1]); +} \ No newline at end of file diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 601acc881de..9e474c19619 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -947,11 +947,17 @@ static Material *give_render_material(Render *re, Object *ob, int nr) /* ------------------------------------------------------------------------- */ /* Particles */ /* ------------------------------------------------------------------------- */ - +typedef struct ParticleStrandData +{ + struct MCol *mcol; + float *orco, *uvco, *surfnor; + float time, adapt_angle, adapt_pix, size; + int totuv, totcol; + int first, line, adapt, override_uv; +} +ParticleStrandData; /* future thread problem... */ -static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, float *orco, float *surfnor, - float *uvco, int totuv, MCol *mcol, int totcol, float *vec, float *vec1, float ctime, - int first, int line, int adapt, float adapt_angle, float adapt_pix, int override_uv) +static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, ParticleStrandData *sd, float *vec, float *vec1) { static VertRen *v1= NULL, *v2= NULL; VlakRen *vlr; @@ -974,11 +980,11 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo float fac; if(ma->strand_ease!=0.0f) { if(ma->strand_ease<0.0f) - fac= pow(ctime, 1.0+ma->strand_ease); + fac= pow(sd->time, 1.0+ma->strand_ease); else - fac= pow(ctime, 1.0/(1.0f-ma->strand_ease)); + fac= pow(sd->time, 1.0/(1.0f-ma->strand_ease)); } - else fac= ctime; + else fac= sd->time; width= ((1.0f-fac)*ma->strand_sta + (fac)*ma->strand_end); @@ -1010,7 +1016,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo flag |= R_STRAND; /* single face line */ - if(line) { + if(sd->line) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= RE_findOrAddVert(obr, obr->totvert++); @@ -1021,25 +1027,25 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo VECCOPY(vlr->v1->co, vec); VecAddf(vlr->v1->co, vlr->v1->co, cross); VECCOPY(vlr->v1->n, nor); - vlr->v1->orco= orco; + vlr->v1->orco= sd->orco; vlr->v1->accum= -1.0f; // accum abuse for strand texco VECCOPY(vlr->v2->co, vec); VecSubf(vlr->v2->co, vlr->v2->co, cross); VECCOPY(vlr->v2->n, nor); - vlr->v2->orco= orco; + vlr->v2->orco= sd->orco; vlr->v2->accum= vlr->v1->accum; VECCOPY(vlr->v4->co, vec1); VecAddf(vlr->v4->co, vlr->v4->co, cross); VECCOPY(vlr->v4->n, nor); - vlr->v4->orco= orco; + vlr->v4->orco= sd->orco; vlr->v4->accum= 1.0f; // accum abuse for strand texco VECCOPY(vlr->v3->co, vec1); VecSubf(vlr->v3->co, vlr->v3->co, cross); VECCOPY(vlr->v3->n, nor); - vlr->v3->orco= orco; + vlr->v3->orco= sd->orco; vlr->v3->accum= vlr->v4->accum; CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); @@ -1047,23 +1053,23 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo vlr->mat= ma; vlr->ec= ME_V2V3; - if(surfnor) { + if(sd->surfnor) { float *snor= RE_vlakren_get_surfnor(obr, vlr, 1); - VECCOPY(snor, surfnor); + VECCOPY(snor, sd->surfnor); } - if(uvco){ - for(i=0; iuvco){ + for(i=0; itotuv; i++){ MTFace *mtf; mtf=RE_vlakren_get_tface(obr,vlr,i,NULL,1); mtf->uv[0][0]=mtf->uv[1][0]= - mtf->uv[2][0]=mtf->uv[3][0]=(uvco+2*i)[0]; + mtf->uv[2][0]=mtf->uv[3][0]=(sd->uvco+2*i)[0]; mtf->uv[0][1]=mtf->uv[1][1]= - mtf->uv[2][1]=mtf->uv[3][1]=(uvco+2*i)[1]; + mtf->uv[2][1]=mtf->uv[3][1]=(sd->uvco+2*i)[1]; } - if(override_uv>=0){ + if(sd->override_uv>=0){ MTFace *mtf; - mtf=RE_vlakren_get_tface(obr,vlr,override_uv,NULL,0); + mtf=RE_vlakren_get_tface(obr,vlr,sd->override_uv,NULL,0); mtf->uv[0][0]=mtf->uv[3][0]=0.0f; mtf->uv[1][0]=mtf->uv[2][0]=1.0f; @@ -1072,18 +1078,18 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo mtf->uv[2][1]=mtf->uv[3][1]=1.0f; } } - if(mcol){ - for(i=0; imcol){ + for(i=0; itotcol; i++){ MCol *mc; mc=RE_vlakren_get_mcol(obr,vlr,i,NULL,1); - mc[0]=mc[1]=mc[2]=mc[3]=mcol[i]; - mc[0]=mc[1]=mc[2]=mc[3]=mcol[i]; + mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i]; + mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i]; } } } /* first two vertices of a strand */ - else if(first) { - if(adapt){ + else if(sd->first) { + if(sd->adapt){ VECCOPY(anor, nor); VECCOPY(avec, vec); second=1; @@ -1095,18 +1101,18 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo VECCOPY(v1->co, vec); VecAddf(v1->co, v1->co, cross); VECCOPY(v1->n, nor); - v1->orco= orco; + v1->orco= sd->orco; v1->accum= -1.0f; // accum abuse for strand texco VECCOPY(v2->co, vec); VecSubf(v2->co, v2->co, cross); VECCOPY(v2->n, nor); - v2->orco= orco; + v2->orco= sd->orco; v2->accum= v1->accum; } /* more vertices & faces to strand */ else { - if(adapt==0 || second){ + if(sd->adapt==0 || second){ vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= v1; @@ -1118,14 +1124,14 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo v2= vlr->v3; // cycle - if(adapt){ + if(sd->adapt){ second=0; VECCOPY(anor,nor); VECCOPY(avec,vec); } } - else if(adapt){ + else if(sd->adapt){ float dvec[3],pvec[3]; VecSubf(dvec,avec,vec); Projf(pvec,dvec,vec); @@ -1135,7 +1141,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo dx= re->winx*dvec[0]*re->winmat[0][0]/w; dy= re->winy*dvec[1]*re->winmat[1][1]/w; w= sqrt(dx*dx + dy*dy); - if(Inpf(anor,nor)adapt_pix){ + if(Inpf(anor,nor)adapt_angle && w>sd->adapt_pix){ vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= v1; @@ -1157,13 +1163,13 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo VECCOPY(vlr->v4->co, vec); VecAddf(vlr->v4->co, vlr->v4->co, cross); VECCOPY(vlr->v4->n, nor); - vlr->v4->orco= orco; - vlr->v4->accum= -1.0f + 2.0f*ctime; // accum abuse for strand texco + vlr->v4->orco= sd->orco; + vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco VECCOPY(vlr->v3->co, vec); VecSubf(vlr->v3->co, vlr->v3->co, cross); VECCOPY(vlr->v3->n, nor); - vlr->v3->orco= orco; + vlr->v3->orco= sd->orco; vlr->v3->accum= vlr->v4->accum; CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); @@ -1171,23 +1177,23 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo vlr->mat= ma; vlr->ec= ME_V2V3; - if(surfnor) { + if(sd->surfnor) { float *snor= RE_vlakren_get_surfnor(obr, vlr, 1); - VECCOPY(snor, surfnor); + VECCOPY(snor, sd->surfnor); } - if(uvco){ - for(i=0; iuvco){ + for(i=0; itotuv; i++){ MTFace *mtf; mtf=RE_vlakren_get_tface(obr,vlr,i,NULL,1); mtf->uv[0][0]=mtf->uv[1][0]= - mtf->uv[2][0]=mtf->uv[3][0]=(uvco+2*i)[0]; + mtf->uv[2][0]=mtf->uv[3][0]=(sd->uvco+2*i)[0]; mtf->uv[0][1]=mtf->uv[1][1]= - mtf->uv[2][1]=mtf->uv[3][1]=(uvco+2*i)[1]; + mtf->uv[2][1]=mtf->uv[3][1]=(sd->uvco+2*i)[1]; } - if(override_uv>=0){ + if(sd->override_uv>=0){ MTFace *mtf; - mtf=RE_vlakren_get_tface(obr,vlr,override_uv,NULL,0); + mtf=RE_vlakren_get_tface(obr,vlr,sd->override_uv,NULL,0); mtf->uv[0][0]=mtf->uv[3][0]=0.0f; mtf->uv[1][0]=mtf->uv[2][0]=1.0f; @@ -1196,12 +1202,12 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, flo mtf->uv[2][1]=mtf->uv[3][1]=(vlr->v3->accum+1.0f)/2.0f; } } - if(mcol){ - for(i=0; imcol){ + for(i=0; itotcol; i++){ MCol *mc; mc=RE_vlakren_get_mcol(obr,vlr,i,NULL,1); - mc[0]=mc[1]=mc[2]=mc[3]=mcol[i]; - mc[0]=mc[1]=mc[2]=mc[3]=mcol[i]; + mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i]; + mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i]; } } } @@ -1254,17 +1260,13 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float } } -static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Object *bb_ob, float *vec, float *vel, float size, float tilt, short align, - int lock, int p, int totpart, short uv_split, short anim, short split_offset, float random, float pa_time, float offset[2], int uv[3]) + +static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, ParticleBillboardData *bb) { VlakRen *vlr; MTFace *mtf; - float xvec[3]={1.0f,0.0f,0.0f}, yvec[3]={0.0f,1.0f,0.0f}, zvec[3]; - float onevec[3]={0.0f,0.0f,0.0f}, tvec[3],tvec2[3], bb_center[3]; - float uvx=0.0f, uvy=0.0f, uvdx=1.0f, uvdy=1.0f, time=0.0f; - - if(aligntotvlak++); vlr->v1= RE_findOrAddVert(obr, obr->totvert++); @@ -1272,74 +1274,23 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Object vlr->v3= RE_findOrAddVert(obr, obr->totvert++); vlr->v4= RE_findOrAddVert(obr, obr->totvert++); - if(lock && align==PART_BB_VIEW){ - VECCOPY(xvec,bb_ob->obmat[0]); - Normalize(xvec); - VECCOPY(yvec,bb_ob->obmat[1]); - Normalize(yvec); - VECCOPY(zvec,bb_ob->obmat[2]); - Normalize(zvec); - } - else if(align==PART_BB_VEL){ - float temp[3]; - VECCOPY(temp,vel); - Normalize(temp); - VECSUB(zvec,bb_ob->obmat[3],vec); - if(lock){ - float fac=-Inpf(zvec,temp); - VECADDFAC(zvec,zvec,temp,fac); - } - Normalize(zvec); - Crossf(xvec,temp,zvec); - Normalize(xvec); - Crossf(yvec,zvec,xvec); - } - else{ - VECSUB(zvec,bb_ob->obmat[3],vec); - if(lock) - zvec[align]=0.0f; - Normalize(zvec); - - if(alignobmat[1],zvec); - Normalize(xvec); - Crossf(yvec,zvec,xvec); - } - - VECCOPY(tvec,xvec); - VECCOPY(tvec2,yvec); - - VecMulf(xvec,cos(tilt*(float)M_PI)); - VecMulf(tvec2,sin(tilt*(float)M_PI)); - VECADD(xvec,xvec,tvec2); - - VecMulf(yvec,cos(tilt*(float)M_PI)); - VecMulf(tvec,-sin(tilt*(float)M_PI)); - VECADD(yvec,yvec,tvec); - - VecMulf(xvec,size); - VecMulf(yvec,size); + psys_make_billboard(bb, xvec, yvec, zvec, bb_center); - VECADDFAC(bb_center,vec,xvec,offset[0]); - VECADDFAC(bb_center,bb_center,yvec,offset[1]); + VECADD(vlr->v1->co, bb_center, xvec); + VECADD(vlr->v1->co, vlr->v1->co, yvec); + MTC_Mat4MulVecfl(re->viewmat, vlr->v1->co); - VECADD(vlr->v1->co,bb_center,xvec); - VECADD(vlr->v1->co,vlr->v1->co,yvec); - MTC_Mat4MulVecfl(re->viewmat,vlr->v1->co); + VECSUB(vlr->v2->co, bb_center, xvec); + VECADD(vlr->v2->co, vlr->v2->co, yvec); + MTC_Mat4MulVecfl(re->viewmat, vlr->v2->co); - VECSUB(vlr->v2->co,bb_center,xvec); - VECADD(vlr->v2->co,vlr->v2->co,yvec); - MTC_Mat4MulVecfl(re->viewmat,vlr->v2->co); + VECSUB(vlr->v3->co, bb_center, xvec); + VECSUB(vlr->v3->co, vlr->v3->co, yvec); + MTC_Mat4MulVecfl(re->viewmat, vlr->v3->co); - VECSUB(vlr->v3->co,bb_center,xvec); - VECSUB(vlr->v3->co,vlr->v3->co,yvec); - MTC_Mat4MulVecfl(re->viewmat,vlr->v3->co); - - VECADD(vlr->v4->co,bb_center,xvec); - VECSUB(vlr->v4->co,vlr->v4->co,yvec); - MTC_Mat4MulVecfl(re->viewmat,vlr->v4->co); + VECADD(vlr->v4->co, bb_center, xvec); + VECSUB(vlr->v4->co, vlr->v4->co, yvec); + MTC_Mat4MulVecfl(re->viewmat, vlr->v4->co); CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); VECCOPY(vlr->v1->n,vlr->n); @@ -1350,113 +1301,141 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Object vlr->mat= ma; vlr->ec= ME_V2V3; - if(uv_split>1){ - uvdx=uvdy=1.0f/(float)uv_split; - if(anim==PART_BB_ANIM_TIME){ - if(split_offset==PART_BB_OFF_NONE) - time=pa_time; - else if(split_offset==PART_BB_OFF_LINEAR) - time=(float)fmod(pa_time+(float)p/(float)(uv_split*uv_split),1.0f); + if(bb->uv_split > 1){ + uvdx = uvdy = 1.0f / (float)bb->uv_split; + if(bb->anim == PART_BB_ANIM_TIME) { + if(bb->split_offset == PART_BB_OFF_NONE) + time = bb->time; + else if(bb->split_offset == PART_BB_OFF_LINEAR) + time = (float)fmod(bb->time + (float)bb->num / (float)(bb->uv_split * bb->uv_split), 1.0f); else /* split_offset==PART_BB_OFF_RANDOM */ - time=(float)fmod(pa_time+random,1.0f); + time = (float)fmod(bb->time + bb->random, 1.0f); } - else if(anim==PART_BB_ANIM_ANGLE){ - if(align==PART_BB_VIEW){ - time=(float)fmod((tilt+1.0f)/2.0f,1.0); + else if(bb->anim == PART_BB_ANIM_ANGLE) { + if(bb->align == PART_BB_VIEW) { + time = (float)fmod((bb->tilt + 1.0f) / 2.0f, 1.0); } else{ - float axis1[3]={0.0f,0.0f,0.0f}; - float axis2[3]={0.0f,0.0f,0.0f}; - axis1[(align+1)%3]=1.0f; - axis2[(align+2)%3]=1.0f; - if(lock==0){ - zvec[align]=0.0f; + float axis1[3] = {0.0f,0.0f,0.0f}; + float axis2[3] = {0.0f,0.0f,0.0f}; + axis1[(bb->align + 1) % 3] = 1.0f; + axis2[(bb->align + 2) % 3] = 1.0f; + if(bb->lock == 0) { + zvec[bb->align] = 0.0f; Normalize(zvec); } - time=saacos(Inpf(zvec,axis1))/(float)M_PI; - if(Inpf(zvec,axis2)<0.0f) - time=1.0f-time/2.0f; + time = saacos(Inpf(zvec, axis1)) / (float)M_PI; + if(Inpf(zvec, axis2) < 0.0f) + time = 1.0f - time / 2.0f; else - time=time/2.0f; + time = time / 2.0f; } - if(split_offset==PART_BB_OFF_LINEAR) - time=(float)fmod(pa_time+(float)p/(float)(uv_split*uv_split),1.0f); - else if(split_offset==PART_BB_OFF_RANDOM) - time=(float)fmod(pa_time+random,1.0f); + if(bb->split_offset == PART_BB_OFF_LINEAR) + time = (float)fmod(bb->time + (float)bb->num / (float)(bb->uv_split * bb->uv_split), 1.0f); + else if(bb->split_offset == PART_BB_OFF_RANDOM) + time = (float)fmod(bb->time + bb->random, 1.0f); } else{ - if(split_offset==PART_BB_OFF_NONE) - time=0.0f; - else if(split_offset==PART_BB_OFF_LINEAR) - time=(float)fmod((float)p/(float)(uv_split*uv_split),1.0f); + if(bb->split_offset == PART_BB_OFF_NONE) + time = 0.0f; + else if(bb->split_offset == PART_BB_OFF_LINEAR) + time = (float)fmod((float)bb->num /(float)(bb->uv_split * bb->uv_split) , 1.0f); else /* split_offset==PART_BB_OFF_RANDOM */ - time=random; + time = bb->random; } - uvx=uvdx*floor((float)(uv_split*uv_split)*(float)fmod((double)time,(double)uvdx)); - uvy=uvdy*floor((1.0f-time)*(float)uv_split); - if(fmod(time,1.0f/uv_split)==0.0f) - uvy-=uvdy; + uvx = uvdx * floor((float)(bb->uv_split * bb->uv_split) * (float)fmod((double)time, (double)uvdx)); + uvy = uvdy * floor((1.0f - time) * (float)bb->uv_split); + if(fmod(time, 1.0f / bb->uv_split) == 0.0f) + uvy -= uvdy; } /* normal UVs */ - if(uv[0]>=0){ - mtf=RE_vlakren_get_tface(obr,vlr,uv[0],NULL,1); - mtf->uv[0][0]=1.0f; - mtf->uv[0][1]=1.0f; - mtf->uv[1][0]=0.0f; - mtf->uv[1][1]=1.0f; - mtf->uv[2][0]=0.0f; - mtf->uv[2][1]=0.0f; - mtf->uv[3][0]=1.0f; - mtf->uv[3][1]=0.0f; + if(bb->uv[0] >= 0){ + mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[0], NULL, 1); + mtf->uv[0][0] = 1.0f; + mtf->uv[0][1] = 1.0f; + mtf->uv[1][0] = 0.0f; + mtf->uv[1][1] = 1.0f; + mtf->uv[2][0] = 0.0f; + mtf->uv[2][1] = 0.0f; + mtf->uv[3][0] = 1.0f; + mtf->uv[3][1] = 0.0f; } /* time-index UVs */ - if(uv[1]>=0){ - mtf=RE_vlakren_get_tface(obr,vlr,uv[1],NULL,1); - mtf->uv[0][0]=mtf->uv[1][0]=mtf->uv[2][0]=mtf->uv[3][0]=pa_time; - mtf->uv[0][1]=mtf->uv[1][1]=mtf->uv[2][1]=mtf->uv[3][1]=(float)p/(float)totpart; + if(bb->uv[1] >= 0){ + mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[1], NULL, 1); + mtf->uv[0][0] = mtf->uv[1][0] = mtf->uv[2][0] = mtf->uv[3][0] = bb->time; + mtf->uv[0][1] = mtf->uv[1][1] = mtf->uv[2][1] = mtf->uv[3][1] = (float)bb->num/(float)bb->totnum; } /* split UVs */ - if(uv_split>1 && uv[2]>=0){ - mtf=RE_vlakren_get_tface(obr,vlr,uv[2],NULL,1); - mtf->uv[0][0]=uvx+uvdx; - mtf->uv[0][1]=uvy+uvdy; - mtf->uv[1][0]=uvx; - mtf->uv[1][1]=uvy+uvdy; - mtf->uv[2][0]=uvx; - mtf->uv[2][1]=uvy; - mtf->uv[3][0]=uvx+uvdx; - mtf->uv[3][1]=uvy; + if(bb->uv_split > 1 && bb->uv[2] >= 0){ + mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[2], NULL, 1); + mtf->uv[0][0] = uvx + uvdx; + mtf->uv[0][1] = uvy + uvdy; + mtf->uv[1][0] = uvx; + mtf->uv[1][1] = uvy + uvdy; + mtf->uv[2][0] = uvx; + mtf->uv[2][1] = uvy; + mtf->uv[3][0] = uvx + uvdx; + mtf->uv[3][1] = uvy; } } -static void render_new_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Material *ma, int path, int first, int line, - float time, float *loc, float *loc1, float *orco, float *surfnor, int totuv, float *uvco, - int totcol, MCol *mcol, float size, int seed, int override_uv, - int adapt, float adapt_angle, float adapt_pix) +static void render_new_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Material *ma, ParticleStrandData *sd, float *loc, float *loc1, int seed) { HaloRen *har=0; - if(path){ - if(ma->mode&MA_WIRE) - static_particle_wire(obr, ma, loc, loc1, first, line); - else if(ma->mode & MA_HALO){ - har= RE_inithalo_particle(re, obr, dm, ma, loc, loc1, orco, uvco, size, 1.0, seed); - if(har) har->lay= obr->ob->lay; + + if(ma->mode&MA_WIRE) + static_particle_wire(obr, ma, loc, loc1, sd->first, sd->line); + else if(ma->mode & MA_HALO){ + har= RE_inithalo_particle(re, obr, dm, ma, loc, loc1, sd->orco, sd->uvco, sd->size, 1.0, seed); + if(har) har->lay= obr->ob->lay; + } + else + static_particle_strand(re, obr, ma, sd, loc, loc1); +} +static void get_particle_uvco_mcol(short from, DerivedMesh *dm, float *fuv, int num, ParticleStrandData *sd) +{ + int i; + + /* get uvco */ + if(sd->uvco && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { + for(i=0; itotuv; i++) { + if(num != DMCACHE_NOTFOUND) { + MFace *mface = dm->getFaceData(dm, num, CD_MFACE); + MTFace *mtface = (MTFace*)CustomData_get_layer_n(&dm->faceData, CD_MTFACE, i); + mtface += num; + + psys_interpolate_uvs(mtface, mface->v4, fuv, sd->uvco + 2 * i); + } + else { + sd->uvco[2*i] = 0.0f; + sd->uvco[2*i + 1] = 0.0f; + } } - else - static_particle_strand(re, obr, ma, orco, surfnor, uvco, totuv, mcol, totcol, loc, loc1, time, first, line, adapt, adapt_angle, adapt_pix, override_uv); } - else{ - har= RE_inithalo_particle(re, obr, dm, ma, loc, NULL, orco, uvco, size, 0.0, seed); - if(har) har->lay= obr->ob->lay; + + /* get mcol */ + if(sd->mcol && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { + for(i=0; itotcol; i++) { + if(num != DMCACHE_NOTFOUND) { + MFace *mface = dm->getFaceData(dm, num, CD_MFACE); + MCol *mc = (MCol*)CustomData_get_layer_n(&dm->faceData, CD_MCOL, i); + mc += num * 4; + + psys_interpolate_mcol(mc, mface->v4, fuv, sd->mcol + i); + } + else + memset(&sd->mcol[i], 0, sizeof(MCol)); + } } } static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem *psys, int timeoffset) { Object *ob= obr->ob; - Object *tob=0, *bb_ob=re->scene->camera; + Object *tob=0; Material *ma=0; MTFace *mtface; ParticleSystemModifierData *psmd; @@ -1466,19 +1445,20 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem ParticleKey *states=0; ParticleKey state; ParticleCacheKey *cache=0; + ParticleBillboardData bb; + ParticleStrandData sd; StrandBuffer *strandbuf=0; StrandVert *svert=0; StrandBound *sbound= 0; StrandRen *strand=0; RNG *rng= 0; - MCol *mcol= 0; float loc[3],loc1[3],loc0[3],vel[3],mat[4][4],nmat[3][3],co[3],nor[3],time; - float *orco=0,*surfnor=0,*uvco=0, strandlen=0.0f, curlen=0.0f; + float strandlen=0.0f, curlen=0.0f; float hasize, pa_size, pa_time, r_tilt, cfra=bsystem_time(ob,(float)CFRA,0.0); - float adapt_angle=0.0, adapt_pix=0.0, random, simplify[2]; - int i, a, k, max_k=0, totpart, totuv=0, totcol=0, override_uv=-1, dosimplify = 0, dosurfacecache = 0; - int path_possible=0, keys_possible=0, baked_keys=0, totchild=0; - int seed, path_nbr=0, path=0, orco1=0, adapt=0, uv[3]={0,0,0}, num; + float random, simplify[2]; + int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0; + int totchild=0; + int seed, path_nbr=0, orco1=0, num; int totface, *origindex = 0; char **uv_name=0; @@ -1505,6 +1485,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem return 1; } + /* last possibility to bail out! */ psmd= psys_get_modifier(ob,psys); if(!(psmd->modifier.mode & eModifierMode_Render)) return 0; @@ -1513,182 +1494,182 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem totchild = (int)((float)totchild * (float)part->disp / 100.0f); } - psys->flag|=PSYS_DRAWING; + psys->flag |= PSYS_DRAWING; rng= rng_new(psys->seed); - - ma= give_render_material(re, ob, part->omat); - if(part->bb_ob) - bb_ob=part->bb_ob; + totpart=psys->totpart; + + memset(&sd, 0, sizeof(ParticleStrandData)); + sd.override_uv = -1; + +/* 2.1 setup material stff */ + ma= give_render_material(re, ob, part->omat); if(ma->ipo){ calc_ipo(ma->ipo, cfra); execute_ipo((ID *)ma, ma->ipo); } + hasize = ma->hasize; + seed = ma->seed1; + + re->flag |= R_HALO; + RE_set_customdata_names(obr, &psmd->dm->faceData); - totuv=CustomData_number_of_layers(&psmd->dm->faceData,CD_MTFACE); - totcol=CustomData_number_of_layers(&psmd->dm->faceData,CD_MCOL); + sd.totuv = CustomData_number_of_layers(&psmd->dm->faceData, CD_MTFACE); + sd.totcol = CustomData_number_of_layers(&psmd->dm->faceData, CD_MCOL); - if(ma->texco & TEXCO_UV && totuv) { - uvco = MEM_callocN(totuv*2*sizeof(float),"particle_uvs"); + if(ma->texco & TEXCO_UV && sd.totuv) { + sd.uvco = MEM_callocN(sd.totuv * 2 * sizeof(float), "particle_uvs"); if(ma->strand_uvname[0]) { - override_uv= CustomData_get_named_layer_index(&psmd->dm->faceData,CD_MTFACE,ma->strand_uvname); - override_uv-= CustomData_get_layer_index(&psmd->dm->faceData,CD_MTFACE); + sd.override_uv = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, ma->strand_uvname); + sd.override_uv -= CustomData_get_layer_index(&psmd->dm->faceData, CD_MTFACE); } } + else + sd.uvco = NULL; - if(totcol) - mcol = MEM_callocN(totcol*sizeof(MCol),"particle_mcols"); + if(sd.totcol) + sd.mcol = MEM_callocN(sd.totcol * sizeof(MCol), "particle_mcols"); - if(part->draw_as==PART_DRAW_BB){ - int first_uv=CustomData_get_layer_index(&psmd->dm->faceData,CD_MTFACE); +/* 2.2 setup billboards */ + if(part->draw_as == PART_DRAW_BB) { + int first_uv = CustomData_get_layer_index(&psmd->dm->faceData, CD_MTFACE); - uv[0]=CustomData_get_named_layer_index(&psmd->dm->faceData,CD_MTFACE,psys->bb_uvname[0]); - if(uv[0]<0) - uv[0]=CustomData_get_active_layer_index(&psmd->dm->faceData,CD_MTFACE); + bb.uv[0] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[0]); + if(bb.uv[0] < 0) + bb.uv[0] = CustomData_get_active_layer_index(&psmd->dm->faceData, CD_MTFACE); - uv[1]=CustomData_get_named_layer_index(&psmd->dm->faceData,CD_MTFACE,psys->bb_uvname[1]); - //if(uv[1]<0) - // uv[1]=CustomData_get_active_layer_index(&psmd->dm->faceData,CD_MTFACE); + bb.uv[1] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[1]); - uv[2]=CustomData_get_named_layer_index(&psmd->dm->faceData,CD_MTFACE,psys->bb_uvname[2]); - //if(uv[2]<0) - // uv[2]=CustomData_get_active_layer_index(&psmd->dm->faceData,CD_MTFACE); + bb.uv[2] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[2]); - if(first_uv>=0){ - uv[0]-=first_uv; - uv[1]-=first_uv; - uv[2]-=first_uv; + if(first_uv >= 0) { + bb.uv[0] -= first_uv; + bb.uv[1] -= first_uv; + bb.uv[2] -= first_uv; } + + bb.align = part->bb_align; + bb.anim = part->bb_anim; + bb.lock = part->draw & PART_DRAW_BB_LOCK; + bb.ob = (part->bb_ob ? part->bb_ob : re->scene->camera); + bb.offset[0] = part->bb_offset[0]; + bb.offset[1] = part->bb_offset[1]; + bb.split_offset = part->bb_split_offset; + bb.totnum = totpart+totchild; + bb.uv_split = part->bb_uv_split; } - if(part->flag&PART_ABS_TIME && part->ipo){ +/* 2.3 setup time */ + if(part->flag&PART_ABS_TIME && part->ipo) { calc_ipo(part->ipo, cfra); execute_ipo((ID *)part, part->ipo); } - if(part->flag&PART_GLOB_TIME) - cfra=bsystem_time(0,(float)CFRA,0.0); + if(part->flag & PART_GLOB_TIME) + cfra = bsystem_time(0, (float)CFRA, 0.0); - if(part->type==PART_REACTOR){ +/* 2.4 setup reactors */ + if(part->type == PART_REACTOR){ psys_get_reactor_target(ob, psys, &tob, &tpsys); if(tpsys && (part->from==PART_FROM_PARTICLE || part->phystype==PART_PHYS_NO)){ - psmd=psys_get_modifier(tob,tpsys); - tpart=tpsys->part; + psmd = psys_get_modifier(tob,tpsys); + tpart = tpsys->part; } } - - hasize = ma->hasize; - seed = ma->seed1; - - re->flag |= R_HALO; +/* 2.5 setup matrices */ MTC_Mat4MulMat4(mat, ob->obmat, re->viewmat); MTC_Mat4Invert(ob->imat, mat); /* need to be that way, for imat texture */ Mat3CpyMat4(nmat, ob->imat); Mat3Transp(nmat); - totpart=psys->totpart; +/* 2.6 setup strand rendering */ + if(part->draw_as == PART_DRAW_PATH && psys->pathcache){ + path_nbr=(int)pow(2.0,(double) part->ren_step); - if(psys->pathcache){ - path_possible=1; - keys_possible=1; - } - if(part->draw_as==PART_DRAW_PATH){ - if(path_possible){ - path_nbr=(int)pow(2.0,(double) part->ren_step); - //if(part->phystype==PART_PHYS_KEYED && (psys->flag&PSYS_BAKED)==0) - // path_nbr*=psys->totkeyed; - - if(path_nbr) { - if((ma->mode & (MA_HALO|MA_WIRE))==0) { - orco= MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos"); - set_object_orco(re, psys, orco); - } - path=1; + if(path_nbr) { + if((ma->mode & (MA_HALO|MA_WIRE))==0) { + sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos"); + set_object_orco(re, psys, sd.orco); } + } - if(part->draw&PART_DRAW_REN_ADAPT) { - adapt=1; - adapt_pix=(float)part->adapt_pix; - adapt_angle=cos((float)part->adapt_angle*(float)(M_PI/180.0)); - } + if(part->draw & PART_DRAW_REN_ADAPT) { + sd.adapt = 1; + sd.adapt_pix = (float)part->adapt_pix; + sd.adapt_angle = cos((float)part->adapt_angle * (float)(M_PI / 180.0)); + } - if(re->r.renderer==R_INTERN && part->draw&PART_DRAW_REN_STRAND) { - strandbuf= RE_addStrandBuffer(obr, (totpart+totchild)*(path_nbr+1)); - strandbuf->ma= ma; - strandbuf->lay= ob->lay; - Mat4CpyMat4(strandbuf->winmat, re->winmat); - strandbuf->winx= re->winx; - strandbuf->winy= re->winy; - strandbuf->maxdepth= 2; - strandbuf->adaptcos= cos((float)part->adapt_angle*(float)(M_PI/180.0)); - strandbuf->overrideuv= override_uv; - strandbuf->minwidth= ma->strand_min; - - if(ma->strand_widthfade == 0.0f) - strandbuf->widthfade= 0.0f; - else if(ma->strand_widthfade >= 1.0f) - strandbuf->widthfade= 2.0f - ma->strand_widthfade; - else - strandbuf->widthfade= 1.0f/MAX2(ma->strand_widthfade, 1e-5f); + if(re->r.renderer==R_INTERN && part->draw&PART_DRAW_REN_STRAND) { + strandbuf= RE_addStrandBuffer(obr, (totpart+totchild)*(path_nbr+1)); + strandbuf->ma= ma; + strandbuf->lay= ob->lay; + Mat4CpyMat4(strandbuf->winmat, re->winmat); + strandbuf->winx= re->winx; + strandbuf->winy= re->winy; + strandbuf->maxdepth= 2; + strandbuf->adaptcos= cos((float)part->adapt_angle*(float)(M_PI/180.0)); + strandbuf->overrideuv= sd.override_uv; + strandbuf->minwidth= ma->strand_min; + + if(ma->strand_widthfade == 0.0f) + strandbuf->widthfade= 0.0f; + else if(ma->strand_widthfade >= 1.0f) + strandbuf->widthfade= 2.0f - ma->strand_widthfade; + else + strandbuf->widthfade= 1.0f/MAX2(ma->strand_widthfade, 1e-5f); - if(part->flag & PART_HAIR_BSPLINE) - strandbuf->flag |= R_STRAND_BSPLINE; - if(ma->mode & MA_STR_B_UNITS) - strandbuf->flag |= R_STRAND_B_UNITS; + if(part->flag & PART_HAIR_BSPLINE) + strandbuf->flag |= R_STRAND_BSPLINE; + if(ma->mode & MA_STR_B_UNITS) + strandbuf->flag |= R_STRAND_B_UNITS; - svert= strandbuf->vert; + svert= strandbuf->vert; - if(re->r.mode & R_SPEED) + if(re->r.mode & R_SPEED) + dosurfacecache= 1; + else if((re->wrld.mode & WO_AMB_OCC) && (re->wrld.ao_gather_method == WO_AOGATHER_APPROX)) + if(ma->amb != 0.0f) dosurfacecache= 1; - else if((re->wrld.mode & WO_AMB_OCC) && (re->wrld.ao_gather_method == WO_AOGATHER_APPROX)) - if(ma->amb != 0.0f) - dosurfacecache= 1; - - totface= psmd->dm->getNumFaces(psmd->dm); - origindex= psmd->dm->getFaceDataArray(psmd->dm, CD_ORIGINDEX); - if(origindex) { - for(a=0; atotbound= MAX2(strandbuf->totbound, origindex[a]); - strandbuf->totbound++; - } + + totface= psmd->dm->getNumFaces(psmd->dm); + origindex= psmd->dm->getFaceDataArray(psmd->dm, CD_ORIGINDEX); + if(origindex) { + for(a=0; atotbound= MAX2(strandbuf->totbound, origindex[a]); strandbuf->totbound++; - strandbuf->bound= MEM_callocN(sizeof(StrandBound)*strandbuf->totbound, "StrandBound"); - sbound= strandbuf->bound; - sbound->start= sbound->end= 0; } + strandbuf->totbound++; + strandbuf->bound= MEM_callocN(sizeof(StrandBound)*strandbuf->totbound, "StrandBound"); + sbound= strandbuf->bound; + sbound->start= sbound->end= 0; } } - else if(keys_possible && part->draw&PART_DRAW_KEYS){ - path_nbr=part->keys_step; - if(path_nbr==0) - baked_keys=1; - } - if(orco==0){ - orco=MEM_mallocN(3*sizeof(float),"particle orco"); - orco1=1; + if(sd.orco == 0) { + sd.orco = MEM_mallocN(3 * sizeof(float), "particle orco"); + orco1 = 1; } - if(path_nbr==0) - psys->lattice=psys_get_lattice(ob,psys); + if(path_nbr == 0) + psys->lattice = psys_get_lattice(ob, psys); /* 3. start creating renderable things */ for(a=0,pa=pars; aflag & PARS_UNEXIST) continue; pa_time=(cfra-pa->time)/pa->lifetime; - if((part->flag&PART_ABS_TIME)==0){ - if(ma->ipo){ + if((part->flag&PART_ABS_TIME) == 0) { + if(ma->ipo) { /* correction for lifetime */ - calc_ipo(ma->ipo, 100.0f*pa_time); + calc_ipo(ma->ipo, 100.0f * pa_time); execute_ipo((ID *)ma, ma->ipo); } if(part->ipo){ @@ -1703,51 +1684,25 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* get orco */ if(tpsys && (part->from==PART_FROM_PARTICLE || part->phystype==PART_PHYS_NO)){ tpa=tpsys->particles+pa->num; - psys_particle_on_emitter(psmd,tpart->from,tpa->num,pa->num_dmcache,tpa->fuv,tpa->foffset,co,nor,0,0,orco,0); + psys_particle_on_emitter(psmd,tpart->from,tpa->num,pa->num_dmcache,tpa->fuv,tpa->foffset,co,nor,0,0,sd.orco,0); } else - psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,0); + psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,sd.orco,0); + /* get uvco & mcol */ num= pa->num_dmcache; if(num == DMCACHE_NOTFOUND) if(pa->num < psmd->dm->getNumFaces(psmd->dm)) num= pa->num; - if(uvco && ELEM(part->from,PART_FROM_FACE,PART_FROM_VOLUME)){ - for(i=0; idm->getFaceData(psmd->dm,num,CD_MFACE); - mtface=(MTFace*)CustomData_get_layer_n(&psmd->dm->faceData,CD_MTFACE,i); - mtface+=num; - - psys_interpolate_uvs(mtface,mface->v4,pa->fuv,uvco+2*i); - } - else { - uvco[2*i]= 0.0f; - uvco[2*i + 1]= 0.0f; - } - } - } - if(mcol && ELEM(part->from,PART_FROM_FACE,PART_FROM_VOLUME)){ - for(i=0; idm->getFaceData(psmd->dm,num,CD_MFACE); - MCol *mc=(MCol*)CustomData_get_layer_n(&psmd->dm->faceData,CD_MCOL,i); - mc+=num*4; - - psys_interpolate_mcol(mc,mface->v4,pa->fuv,mcol+i); - } - else - memset(&mcol[i], 0, sizeof(MCol)); - } - } + get_particle_uvco_mcol(part->from, psmd->dm, pa->fuv, num, &sd); - pa_size=pa->size; + pa_size = pa->size; - r_tilt=1.0f+pa->r_ave[0]; + r_tilt = 1.0f + pa->r_ave[0]; - if(path_nbr){ + if(path_nbr) { cache = psys->pathcache[a]; max_k = (int)cache->steps; } @@ -1756,123 +1711,67 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } else { ChildParticle *cpa= psys->child+a-totpart; + + if(path_nbr) { + cache = psys->childcache[a-totpart]; + + if(cache->steps < 0) + continue; + + max_k = (int)cache->steps; + } - pa_time=psys_get_child_time(psys, cpa, cfra); + pa_time = psys_get_child_time(psys, cpa, cfra); - if((part->flag&PART_ABS_TIME)==0){ - if(ma->ipo){ + if((part->flag & PART_ABS_TIME) == 0) { + if(ma->ipo) { /* correction for lifetime */ - calc_ipo(ma->ipo, 100.0f*pa_time); + calc_ipo(ma->ipo, 100.0f * pa_time); execute_ipo((ID *)ma, ma->ipo); } - if(part->ipo){ + if(part->ipo) { /* correction for lifetime */ - calc_ipo(part->ipo, 100.0f*pa_time); + calc_ipo(part->ipo, 100.0f * pa_time); execute_ipo((ID *)part, part->ipo); } } - pa_size=psys_get_child_size(psys, cpa, cfra, &pa_time); + pa_size = psys_get_child_size(psys, cpa, cfra, &pa_time); - r_tilt=2.0f*cpa->rand[2]; + r_tilt = 2.0f * cpa->rand[2]; - num= cpa->num; + num = cpa->num; /* get orco */ if(part->childtype == PART_CHILD_FACES) { psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num,DMCACHE_ISCHILD, - cpa->fuv,cpa->foffset,co,nor,0,0,orco,0); + cpa->fuv,cpa->foffset,co,nor,0,0,sd.orco,0); } else { ParticleData *par = psys->particles + cpa->parent; psys_particle_on_emitter(psmd, part->from, par->num,DMCACHE_ISCHILD,par->fuv, - par->foffset,co,nor,0,0,orco,0); + par->foffset,co,nor,0,0,sd.orco,0); } - if(uvco){ - if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ - for(i=0; ichildtype==PART_CHILD_FACES){ - MFace *mface=psmd->dm->getFaceData(psmd->dm,cpa->num,CD_MFACE); - - mtface=(MTFace*)CustomData_get_layer_n(&psmd->dm->faceData,CD_MTFACE,i); - mtface+=cpa->num; - - psys_interpolate_uvs(mtface,mface->v4,cpa->fuv,uvco+2*i); - } - else{ - uvco[2*i]=uvco[2*i+1]=0.0f; - } - } - } - else if(ELEM(part->from,PART_FROM_FACE,PART_FROM_VOLUME)){ - ParticleData *parent = psys->particles + cpa->parent; - num= parent->num_dmcache; - - if(num == DMCACHE_NOTFOUND) - if(parent->num < psmd->dm->getNumFaces(psmd->dm)) - num= parent->num; - - for(i=0; idm->getFaceData(psmd->dm,num,CD_MFACE); - mtface=(MTFace*)CustomData_get_layer_n(&psmd->dm->faceData,CD_MTFACE,i); - mtface+=num; - psys_interpolate_uvs(mtface,mface->v4,parent->fuv,uvco+2*i); - } - else { - uvco[2*i]= 0.0f; - uvco[2*i + 1]= 0.0f; - } - } - } - } - - if(mcol){ - if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ - for(i=0; ichildtype==PART_CHILD_FACES){ - MFace *mface=psmd->dm->getFaceData(psmd->dm,cpa->num,CD_MFACE); - MCol *mc=(MCol*)CustomData_get_layer_n(&psmd->dm->faceData,CD_MCOL,i); - mc+=cpa->num*4; - - psys_interpolate_mcol(mc,mface->v4,cpa->fuv,mcol+i); - } - else - memset(&mcol[i], 0, sizeof(MCol)); - } - } - else if(ELEM(part->from,PART_FROM_FACE,PART_FROM_VOLUME)){ - ParticleData *parent = psys->particles + cpa->parent; - num= parent->num_dmcache; - - if(num == DMCACHE_NOTFOUND) - if(parent->num < psmd->dm->getNumFaces(psmd->dm)) - num= parent->num; - - for(i=0; idm->getFaceData(psmd->dm,num,CD_MFACE); - MCol *mc=(MCol*)CustomData_get_layer_n(&psmd->dm->faceData,CD_MCOL,i); - mc+=num*4; - - psys_interpolate_mcol(mc,mface->v4,parent->fuv,mcol+i); - } - else - memset(&mcol[i], 0, sizeof(MCol)); - } - } + /* get uvco & mcol */ + if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES) { + get_particle_uvco_mcol(PART_FROM_FACE, psmd->dm, cpa->fuv, cpa->num, &sd); } + else { + ParticleData *parent = psys->particles + cpa->parent; + num = parent->num_dmcache; - dosimplify= psys_render_simplify_params(psys, cpa, simplify); + if(num == DMCACHE_NOTFOUND) + if(parent->num < psmd->dm->getNumFaces(psmd->dm)) + num = parent->num; - if(path_nbr && psys->childcache) { - cache = psys->childcache[a-totpart]; - max_k = (int)cache->steps; + get_particle_uvco_mcol(part->from, psmd->dm, pa->fuv, num, &sd); } + dosimplify = psys_render_simplify_params(psys, cpa, simplify); + if(strandbuf) { if(origindex[cpa->num]+1 > sbound - strandbuf->bound) { sbound= strandbuf->bound + origindex[cpa->num]+1; @@ -1884,17 +1783,17 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* surface normal shading setup */ if(ma->mode_l & MA_STR_SURFDIFF) { Mat3MulVecfl(nmat, nor); - surfnor= nor; + sd.surfnor= nor; } else - surfnor= NULL; + sd.surfnor= NULL; /* strand render setup */ if(strandbuf) { strand= RE_findOrAddStrand(obr, obr->totstrand++); strand->buffer= strandbuf; strand->vert= svert; - VECCOPY(strand->orco, orco); + VECCOPY(strand->orco, sd.orco); if(dosimplify) { float *ssimplify= RE_strandren_get_simplify(obr, strand, 1); @@ -1902,9 +1801,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem ssimplify[1]= simplify[1]; } - if(surfnor) { + if(sd.surfnor) { float *snor= RE_strandren_get_surfnor(obr, strand, 1); - VECCOPY(snor, surfnor); + VECCOPY(snor, sd.surfnor); } if(dosurfacecache && num >= 0) { @@ -1912,20 +1811,20 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem *facenum= num; } - if(uvco) { - for(i=0; ico, (cache+k)->co); } - for(k=0; k<=path_nbr; k++){ - if(path_nbr){ + if(path_nbr) { + /* render strands */ + for(k=0; k<=path_nbr; k++){ if(k<=max_k){ - //bti->convert_bake_key(bsys,cache+k,0,(void*)&state); - //copy_particle_key(&state,cache+k,0); VECCOPY(state.co,(cache+k)->co); VECCOPY(state.vel,(cache+k)->vel); } @@ -1955,65 +1853,95 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(k > 0) curlen += VecLenf((cache+k-1)->co, (cache+k)->co); time= curlen/strandlen; - } - else{ - time=0.0f; - state.time=cfra; - if(psys_get_particle_state(ob,psys,a,&state,0)==0) - continue; + + VECCOPY(loc,state.co); + MTC_Mat4MulVecfl(re->viewmat,loc); + + if(strandbuf) { + VECCOPY(svert->co, loc); + svert->strandco= -1.0f + 2.0f*time; + svert++; + strand->totvert++; + } + else{ + sd.first = 0; + sd.time = time; + sd.size = hasize; + + if(k==1){ + sd.first = 1; + sd.time = 0.0f; + VECSUB(loc0,loc1,loc); + VECADD(loc0,loc1,loc0); + } + + if(k) + render_new_particle(re, obr, psmd->dm, ma, &sd, loc, loc1, seed); + + VECCOPY(loc1,loc); + } } + } + else { + /* render normal particles */ + time=0.0f; + state.time=cfra; + if(psys_get_particle_state(ob,psys,a,&state,0)==0) + continue; + VECCOPY(loc,state.co); if(part->draw_as!=PART_DRAW_BB) MTC_Mat4MulVecfl(re->viewmat,loc); - if(part->draw_as==PART_DRAW_LINE) { - VECCOPY(vel,state.vel); - //VECADD(vel,vel,state.co); - MTC_Mat4Mul3Vecfl(re->viewmat,vel); - //VECSUB(vel,vel,loc); - Normalize(vel); - if(part->draw & PART_DRAW_VEL_LENGTH) - VecMulf(vel,VecLength(state.vel)); - VECADDFAC(loc0,loc,vel,-part->draw_line[0]); - VECADDFAC(loc1,loc,vel,part->draw_line[1]); - - render_new_particle(re,obr,psmd->dm,ma,1,0,1,0.0f,loc0,loc1, - orco,surfnor,totuv,uvco,totcol,mcol,hasize,seed,override_uv,0,0,0); - } - else if(part->draw_as==PART_DRAW_BB) { - VECCOPY(vel,state.vel); - //MTC_Mat4Mul3Vecfl(re->viewmat,vel); - particle_billboard(re,obr,ma,bb_ob,loc,vel,pa_size,part->bb_tilt*(1.0f-part->bb_rand_tilt*r_tilt), - part->bb_align,part->draw&PART_DRAW_BB_LOCK, - a,totpart+totchild,part->bb_uv_split,part->bb_anim,part->bb_split_offset,random,pa_time,part->bb_offset,uv); - } - else if(strandbuf) { if(svert) { - VECCOPY(svert->co, loc); - svert->strandco= -1.0f + 2.0f*time; - svert++; - strand->totvert++; - } } - else{ - if(k==1){ - VECSUB(loc0,loc1,loc); - VECADD(loc0,loc1,loc0); - render_new_particle(re,obr,psmd->dm,ma,path,1,0,0.0f,loc1,loc0, - orco,surfnor,totuv,uvco,totcol,mcol,hasize,seed,override_uv, - adapt,adapt_angle,adapt_pix); - } + switch(part->draw_as) { + case PART_DRAW_LINE: + sd.line = 1; + sd.time = 0.0f; + sd.size = hasize; + + VECCOPY(vel,state.vel); + MTC_Mat4Mul3Vecfl(re->viewmat,vel); + Normalize(vel); + + if(part->draw & PART_DRAW_VEL_LENGTH) + VecMulf(vel,VecLength(state.vel)); + + VECADDFAC(loc0,loc,vel,-part->draw_line[0]); + VECADDFAC(loc1,loc,vel,part->draw_line[1]); - if(path_nbr==0 || k) - render_new_particle(re,obr,psmd->dm,ma,path,0,0,time,loc,loc1, - orco,surfnor,totuv,uvco,totcol,mcol,hasize,seed,override_uv, - adapt,adapt_angle,adapt_pix); + render_new_particle(re,obr,psmd->dm,ma,&sd,loc0,loc1,seed); - VECCOPY(loc1,loc); + break; + + case PART_DRAW_BB: + bb.random = random; + bb.size = pa_size; + bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt); + bb.time = pa_time; + bb.num = a; + VECCOPY(bb.vec, loc); + VECCOPY(bb.vel, state.vel); + + particle_billboard(re, obr, ma, &bb); + + break; + + default: + { + HaloRen *har=0; + + har = RE_inithalo_particle(re, obr, psmd->dm, ma, loc, NULL, sd.orco, sd.uvco, hasize, 0.0, seed); + + if(har) har->lay= obr->ob->lay; + + break; + } } } if(orco1==0) - orco+=3; + sd.orco+=3; if(re->test_break()) break; @@ -2026,13 +1954,13 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(ma) do_mat_ipo(ma); if(orco1) - MEM_freeN(orco); + MEM_freeN(sd.orco); - if(uvco) - MEM_freeN(uvco); + if(sd.uvco) + MEM_freeN(sd.uvco); - if(mcol) - MEM_freeN(mcol); + if(sd.mcol) + MEM_freeN(sd.mcol); if(uv_name) MEM_freeN(uv_name); @@ -2049,7 +1977,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem psys->lattice=0; } - if(path && (ma->mode_l & MA_TANGENT_STR)==0) + if(path_nbr && (ma->mode_l & MA_TANGENT_STR)==0) calc_vertexnormals(re, obr, 0, 0); return 1; diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 2063ac42bb1..c9fffa407ee 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2910,6 +2910,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) ParticleData *pars, *pa; ParticleKey state, *states=0; ParticleCacheKey *cache=0; + ParticleBillboardData bb; Material *ma; Object *bb_ob=0; float vel[3], vec[3], vec2[3], imat[4][4], onevec[3]={0.0f,0.0f,0.0f}, bb_center[3]; @@ -2917,8 +2918,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) float cfra=bsystem_time(ob,(float)CFRA,0.0); float *vdata=0, *vedata=0, *cdata=0, *ndata=0, *vd=0, *ved=0, *cd=0, *nd=0, xvec[3], yvec[3], zvec[3]; float ma_r=0.0f, ma_g=0.0f, ma_b=0.0f; - int a, k, k_max=0, totpart, totpoint=0, draw_as, path_nbr=0; - int path_possible=0, keys_possible=0, draw_keys=0, totchild=0; + int a, k, k_max=0, totpart, totpoint=0, draw_as, totchild=0; int select=ob->flag&SELECT, create_cdata=0; GLint polygonmode[2]; char val[32]; @@ -3004,18 +3004,9 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) if(part->flag&PART_GLOB_TIME) cfra=bsystem_time(0,(float)CFRA,0.0); - if(psys->pathcache){ - path_possible=1; - keys_possible=1; - } - if(draw_as==PART_DRAW_PATH && path_possible==0) + if(draw_as==PART_DRAW_PATH && psys->pathcache==NULL) draw_as=PART_DRAW_DOT; - if(draw_as!=PART_DRAW_PATH && keys_possible && part->draw&PART_DRAW_KEYS){ - path_nbr=part->keys_step; - draw_keys=1; - } - /* 3. */ switch(draw_as){ case PART_DRAW_DOT: @@ -3064,12 +3055,15 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) glPointSize(2.0); /* default dot size */ } else if(part->bb_ob) - bb_ob=part->bb_ob; + bb.ob=part->bb_ob; else - bb_ob=G.vd->camera; + bb.ob=G.vd->camera; - if(part->bb_alignbb_align]=1.0f; + bb.align = part->bb_align; + bb.anim = part->bb_anim; + bb.lock = part->draw & PART_DRAW_BB_LOCK; + bb.offset[0] = part->bb_offset[0]; + bb.offset[1] = part->bb_offset[1]; break; case PART_DRAW_PATH: break; @@ -3081,35 +3075,37 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) } /* 4. */ - if(draw_as && draw_as!=PART_DRAW_PATH){ - if(draw_as!=PART_DRAW_CIRC){ - switch(draw_as){ + if(draw_as && draw_as!=PART_DRAW_PATH) { + int tot_vec_size = (totpart + totchild) * 3 * sizeof(float); + + if(draw_as!=PART_DRAW_CIRC) { + switch(draw_as) { case PART_DRAW_AXIS: case PART_DRAW_CROSS: - if(draw_as!=PART_DRAW_CROSS || create_cdata) - cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_cdata"); - vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*6*3*sizeof(float), "particle_vdata"); + if(draw_as != PART_DRAW_CROSS || create_cdata) + cdata = MEM_callocN(tot_vec_size * 6, "particle_cdata"); + vdata = MEM_callocN(tot_vec_size * 6, "particle_vdata"); break; case PART_DRAW_LINE: if(create_cdata) - cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*2*3*sizeof(float), "particle_cdata"); - vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*2*3*sizeof(float), "particle_vdata"); + cdata = MEM_callocN(tot_vec_size * 2, "particle_cdata"); + vdata = MEM_callocN(tot_vec_size * 2, "particle_vdata"); break; case PART_DRAW_BB: if(create_cdata) - cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_cdata"); - vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_vdata"); - ndata=MEM_callocN((totpart+totchild)*(path_nbr+1)*4*3*sizeof(float), "particle_vdata"); + cdata = MEM_callocN(tot_vec_size * 4, "particle_cdata"); + vdata = MEM_callocN(tot_vec_size * 4, "particle_vdata"); + ndata = MEM_callocN(tot_vec_size * 4, "particle_vdata"); break; default: if(create_cdata) - cdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*3*sizeof(float), "particle_cdata"); - vdata=MEM_callocN((totpart+totchild)*(path_nbr+1)*3*sizeof(float), "particle_vdata"); + cdata=MEM_callocN(tot_vec_size, "particle_cdata"); + vdata=MEM_callocN(tot_vec_size, "particle_vdata"); } } - if(part->draw&PART_DRAW_VEL && draw_as!=PART_DRAW_LINE) - vedata=MEM_callocN((totpart+totchild)*2*3*(path_nbr+1)*sizeof(float), "particle_vedata"); + if(part->draw & PART_DRAW_VEL && draw_as != PART_DRAW_LINE) + vedata = MEM_callocN(tot_vec_size * 2, "particle_vedata"); vd=vdata; ved=vedata; @@ -3122,6 +3118,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) if(draw_as){ /* 5. */ for(a=0,pa=pars; adraw&PART_DRAW_PARENT)==0) continue; if(pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue; @@ -3159,11 +3156,6 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) } r_tilt=1.0f+pa->r_ave[0]; - - if(path_nbr){ - cache=psys->pathcache[a]; - k_max=(int)(cache->steps); - } } else{ ChildParticle *cpa= &psys->child[a-totpart]; @@ -3191,47 +3183,23 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) pa_size=psys_get_child_size(psys,cpa,cfra,0); r_tilt=2.0f*cpa->rand[2]; - if(path_nbr){ - cache=psys->childcache[a-totpart]; - k_max=(int)(cache->steps); - } } if(draw_as!=PART_DRAW_PATH){ - int next_pa=0; - for(k=0; k<=path_nbr; k++){ - if(draw_keys){ - state.time=(float)k/(float)path_nbr; - psys_get_particle_on_path(ob,psys,a,&state,1); - } - else if(path_nbr){ - if(k<=k_max){ - VECCOPY(state.co,(cache+k)->co); - VECCOPY(state.vel,(cache+k)->vel); - QUATCOPY(state.rot,(cache+k)->rot); - } - else - continue; - } - else{ - state.time=cfra; - if(psys_get_particle_state(ob,psys,a,&state,0)==0){ - next_pa=1; - break; - } - } - + state.time=cfra; + if(psys_get_particle_state(ob,psys,a,&state,0)){ + /* create actiual particle data */ switch(draw_as){ case PART_DRAW_DOT: + if(vd){ + VECCOPY(vd,state.co) vd+=3; + } if(cd) { cd[0]=ma_r; cd[1]=ma_g; cd[2]=ma_b; cd+=3; } - if(vd){ - VECCOPY(vd,state.co) vd+=3; - } break; case PART_DRAW_CROSS: case PART_DRAW_AXIS: @@ -3314,59 +3282,15 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) cd[2]=cd[5]=cd[8]=cd[11]=ma_b; cd+=12; } - if(part->draw&PART_DRAW_BB_LOCK && part->bb_align==PART_BB_VIEW){ - VECCOPY(xvec,bb_ob->obmat[0]); - Normalize(xvec); - VECCOPY(yvec,bb_ob->obmat[1]); - Normalize(yvec); - VECCOPY(zvec,bb_ob->obmat[2]); - Normalize(zvec); - } - else if(part->bb_align==PART_BB_VEL){ - float temp[3]; - VECCOPY(temp,state.vel); - Normalize(temp); - VECSUB(zvec,bb_ob->obmat[3],state.co); - if(part->draw&PART_DRAW_BB_LOCK){ - float fac=-Inpf(zvec,temp); - VECADDFAC(zvec,zvec,temp,fac); - } - Normalize(zvec); - Crossf(xvec,temp,zvec); - Normalize(xvec); - Crossf(yvec,zvec,xvec); - } - else{ - VECSUB(zvec,bb_ob->obmat[3],state.co); - if(part->draw&PART_DRAW_BB_LOCK) - zvec[part->bb_align]=0.0f; - Normalize(zvec); - - if(part->bb_alignobmat[1],zvec); - Normalize(xvec); - Crossf(yvec,zvec,xvec); - } - VECCOPY(vec,xvec); - VECCOPY(vec2,yvec); - - VecMulf(xvec,cos(part->bb_tilt*(1.0f-part->bb_rand_tilt*r_tilt)*(float)M_PI)); - VecMulf(vec2,sin(part->bb_tilt*(1.0f-part->bb_rand_tilt*r_tilt)*(float)M_PI)); - VECADD(xvec,xvec,vec2); - - VecMulf(yvec,cos(part->bb_tilt*(1.0f-part->bb_rand_tilt*r_tilt)*(float)M_PI)); - VecMulf(vec,-sin(part->bb_tilt*(1.0f-part->bb_rand_tilt*r_tilt)*(float)M_PI)); - VECADD(yvec,yvec,vec); - - VecMulf(xvec,pa_size); - VecMulf(yvec,pa_size); - - VECADDFAC(bb_center,state.co,xvec,part->bb_offset[0]); - VECADDFAC(bb_center,bb_center,yvec,part->bb_offset[1]); + bb.size = pa_size; + bb.tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt); + bb.time = pa_time; + VECCOPY(bb.vec, state.co); + VECCOPY(bb.vel, state.vel); + psys_make_billboard(&bb, xvec, yvec, zvec, bb_center); + VECADD(vd,bb_center,xvec); VECADD(vd,vd,yvec); vd+=3; @@ -3386,6 +3310,10 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) break; } + totpoint++; + + /* additional things to draw for each particle */ + /* (velocity, size and number) */ if(vedata){ VECCOPY(ved,state.co); ved+=3; @@ -3401,15 +3329,12 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) setlinestyle(0); } - totpoint++; - } - if(next_pa) - continue; - if(part->draw&PART_DRAW_NUM && !(G.f & G_RENDER_SHADOW)){ - /* in path drawing state.co is the end point */ - glRasterPos3f(state.co[0], state.co[1], state.co[2]); - sprintf(val," %i",a); - BMF_DrawString(G.font, val); + if(part->draw&PART_DRAW_NUM && !(G.f & G_RENDER_SHADOW)){ + /* in path drawing state.co is the end point */ + glRasterPos3f(state.co[0], state.co[1], state.co[2]); + sprintf(val," %i",a); + BMF_DrawString(G.font, val); + } } } } @@ -3418,51 +3343,39 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) glGetIntegerv(GL_POLYGON_MODE, polygonmode); glDisableClientState(GL_NORMAL_ARRAY); - if(draw_as != PART_DRAW_CIRC){ - if(draw_as==PART_DRAW_PATH){ - ParticleCacheKey **cache, *path; - float *cd2=0,*cdata2=0; - - glEnableClientState(GL_VERTEX_ARRAY); - - if(dt > OB_WIRE) { - glEnableClientState(GL_NORMAL_ARRAY); + if(draw_as==PART_DRAW_PATH){ + ParticleCacheKey **cache, *path; + float *cd2=0,*cdata2=0; - if(part->draw&PART_DRAW_MAT_COL) - glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); - glEnable(GL_LIGHTING); - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glEnable(GL_COLOR_MATERIAL); - } - else { - glDisableClientState(GL_NORMAL_ARRAY); + /* setup gl flags */ + if(dt > OB_WIRE) { + glEnableClientState(GL_NORMAL_ARRAY); - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_LIGHTING); - BIF_ThemeColor(TH_WIRE); - } + if(part->draw&PART_DRAW_MAT_COL) + glEnableClientState(GL_COLOR_ARRAY); - if(totchild && (part->draw&PART_DRAW_PARENT)==0) - totpart=0; + glEnable(GL_LIGHTING); + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + } + else { + glDisableClientState(GL_NORMAL_ARRAY); - cache=psys->pathcache; - for(a=0, pa=psys->particles; aco); + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + BIF_ThemeColor(TH_WIRE); + } - if(dt > OB_WIRE) { - glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel); - if(part->draw&PART_DRAW_MAT_COL) - glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col); - } + if(totchild && (part->draw&PART_DRAW_PARENT)==0) + totpart=0; - glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1); - } - - cache=psys->childcache; - for(a=0; apathcache; + for(a=0, pa=psys->particles; asteps > 0) { glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co); if(dt > OB_WIRE) { @@ -3473,68 +3386,85 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys, int dt) glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1); } + } + + /* draw child particles */ + cache=psys->childcache; + for(a=0; aco); if(dt > OB_WIRE) { + glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel); if(part->draw&PART_DRAW_MAT_COL) - glDisable(GL_COLOR_ARRAY); - glDisable(GL_COLOR_MATERIAL); + glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col); } - if(cdata2) - MEM_freeN(cdata2); - cd2=cdata2=0; + glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1); + } - glLineWidth(1.0f); - /* draw particle edit mode key points*/ + /* restore & clean up */ + if(dt > OB_WIRE) { + if(part->draw&PART_DRAW_MAT_COL) + glDisable(GL_COLOR_ARRAY); + glDisable(GL_COLOR_MATERIAL); } - if(draw_as!=PART_DRAW_PATH){ - glDisableClientState(GL_COLOR_ARRAY); + if(cdata2) + MEM_freeN(cdata2); + cd2=cdata2=0; - if(vdata){ - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, vdata); - } - else - glDisableClientState(GL_VERTEX_ARRAY); + glLineWidth(1.0f); + } + else if(draw_as!=PART_DRAW_CIRC){ + glDisableClientState(GL_COLOR_ARRAY); - if(ndata && dt>OB_WIRE){ - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, 0, ndata); - glEnable(GL_LIGHTING); - } - else{ - glDisableClientState(GL_NORMAL_ARRAY); - glDisable(GL_LIGHTING); - } + /* setup created data arrays */ + if(vdata){ + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, vdata); + } + else + glDisableClientState(GL_VERTEX_ARRAY); - if(cdata){ - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(3, GL_FLOAT, 0, cdata); - } + if(ndata && dt>OB_WIRE){ + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(GL_FLOAT, 0, ndata); + glEnable(GL_LIGHTING); + } + else{ + glDisableClientState(GL_NORMAL_ARRAY); + glDisable(GL_LIGHTING); + } - switch(draw_as){ - case PART_DRAW_AXIS: - case PART_DRAW_CROSS: - glDrawArrays(GL_LINES, 0, 6*totpoint); - break; - case PART_DRAW_LINE: - glDrawArrays(GL_LINES, 0, 2*totpoint); - break; - case PART_DRAW_BB: - if(dt<=OB_WIRE) - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - - glDrawArrays(GL_QUADS, 0, 4*totpoint); - break; - default: - glDrawArrays(GL_POINTS, 0, totpoint); - break; - } + if(cdata){ + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(3, GL_FLOAT, 0, cdata); } + + /* draw created data arrays */ + switch(draw_as){ + case PART_DRAW_AXIS: + case PART_DRAW_CROSS: + glDrawArrays(GL_LINES, 0, 6*totpoint); + break; + case PART_DRAW_LINE: + glDrawArrays(GL_LINES, 0, 2*totpoint); + break; + case PART_DRAW_BB: + if(dt<=OB_WIRE) + glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + + glDrawArrays(GL_QUADS, 0, 4*totpoint); + break; + default: + glDrawArrays(GL_POINTS, 0, totpoint); + break; + } } + if(vedata){ glDisableClientState(GL_COLOR_ARRAY); cpack(0xC0C0C0); -- cgit v1.2.3 From bc789af5a9ee62978412b67fbe3313d6636b5499 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Apr 2009 14:54:29 +0000 Subject: Cleanup of particle object visualization code. No new features and hopefully no new bugs. --- source/blender/blenkernel/intern/anim.c | 104 ++++++++++++--------------- source/blender/makesdna/DNA_particle_types.h | 2 +- source/blender/src/buttons_object.c | 5 +- source/blender/src/edit.c | 10 +-- 4 files changed, 51 insertions(+), 70 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 87d7bfc4853..79c4d15b88e 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -747,7 +747,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_ float ctime, pa_time, scale = 1.0f; float tmat[4][4], mat[4][4], pamat[4][4], size=0.0; float (*obmat)[4], (*oldobmat)[4]; - int lay, a, b, k, step_nbr = 0, counter, hair = 0; + int lay, a, b, k, counter, hair = 0; int totpart, totchild, totgroup=0, pa_num; if(psys==0) return; @@ -775,11 +775,6 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_ if((part->draw_as == PART_DRAW_OB && part->dup_ob) || (part->draw_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first)) { - if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) && part->draw & PART_DRAW_KEYS) - step_nbr = part->keys_step; - else - step_nbr = 0; - /* if we have a hair particle system, use the path cache */ if(part->type == PART_HAIR) { if(psys->flag & PSYS_HAIR_DONE) @@ -859,76 +854,65 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_ oldobmat= obcopy.obmat; } - for(k=0; k<=step_nbr; k++, counter++) { - if(hair) { - /* hair we handle separate and compute transform based on hair keys */ - if(a < totpart) { - cache = psys->pathcache[a]; - psys_get_dupli_path_transform(par, psys, psmd, pa, 0, cache, pamat, &scale); - } - else { - cache = psys->childcache[a-totpart]; - psys_get_dupli_path_transform(par, psys, psmd, 0, cpa, cache, pamat, &scale); - } - - VECCOPY(pamat[3], cache->co); - pamat[3][3]= 1.0f; - - } - else if(step_nbr) { - /* other keys */ - state.time = (float)k / (float)step_nbr; - psys_get_particle_on_path(par, psys, a, &state, 0); - - QuatToMat4(state.rot, pamat); - VECCOPY(pamat[3], state.co); - pamat[3][3]= 1.0f; + if(hair) { + /* hair we handle separate and compute transform based on hair keys */ + if(a < totpart) { + cache = psys->pathcache[a]; + psys_get_dupli_path_transform(par, psys, psmd, pa, 0, cache, pamat, &scale); } else { - /* first key */ - state.time = -1.0; - if(psys_get_particle_state(par, psys, a, &state, 0) == 0) - continue; - - QuatToMat4(state.rot, pamat); - VECCOPY(pamat[3], state.co); - pamat[3][3]= 1.0f; + cache = psys->childcache[a-totpart]; + psys_get_dupli_path_transform(par, psys, psmd, 0, cpa, cache, pamat, &scale); } - if(part->draw_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { - for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) { - Mat4MulMat4(tmat, oblist[b]->obmat, pamat); - Mat4MulFloat3((float *)tmat, size*scale); - if(par_space_mat) - Mat4MulMat4(mat, tmat, par_space_mat); - else - Mat4CpyMat4(mat, tmat); + VECCOPY(pamat[3], cache->co); + pamat[3][3]= 1.0f; + + } + else { + /* first key */ + state.time = ctime; + if(psys_get_particle_state(par, psys, a, &state, 0) == 0) + continue; - dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); - Mat4CpyMat4(dob->omat, obcopylist[b].obmat); - if(G.rendering) - psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco); - } - } - else { - /* to give ipos in object correct offset */ - where_is_object_time(ob, ctime-pa_time); - - Mat4CpyMat4(mat, pamat); + QuatToMat4(state.rot, pamat); + VECCOPY(pamat[3], state.co); + pamat[3][3]= 1.0f; + } - Mat4MulMat4(tmat, obmat, mat); + if(part->draw_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { + for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) { + Mat4MulMat4(tmat, oblist[b]->obmat, pamat); Mat4MulFloat3((float *)tmat, size*scale); if(par_space_mat) Mat4MulMat4(mat, tmat, par_space_mat); else Mat4CpyMat4(mat, tmat); - dob= new_dupli_object(lb, ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); - Mat4CpyMat4(dob->omat, oldobmat); + dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); + Mat4CpyMat4(dob->omat, obcopylist[b].obmat); if(G.rendering) psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco); } } + else { + /* to give ipos in object correct offset */ + where_is_object_time(ob, ctime-pa_time); + + Mat4CpyMat4(mat, pamat); + + Mat4MulMat4(tmat, obmat, mat); + Mat4MulFloat3((float *)tmat, size*scale); + if(par_space_mat) + Mat4MulMat4(mat, tmat, par_space_mat); + else + Mat4CpyMat4(mat, tmat); + + dob= new_dupli_object(lb, ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); + Mat4CpyMat4(dob->omat, oldobmat); + if(G.rendering) + psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco); + } } /* restore objects since they were changed in where_is_object_time */ diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 52d427eda4e..e68f8515af1 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -304,7 +304,7 @@ typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in #define PART_DRAW_ANG 2 #define PART_DRAW_SIZE 4 #define PART_DRAW_EMITTER 8 /* render emitter also */ -#define PART_DRAW_KEYS 16 +//#define PART_DRAW_KEYS 16 /* not used anywhere */ #define PART_DRAW_ADAPT 32 #define PART_DRAW_COS 64 #define PART_DRAW_BB_LOCK 128 diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 6162a12d06d..04aa54f2526 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -4433,7 +4433,10 @@ static void object_panel_particle_visual(Object *ob) block= uiNewBlock(&curarea->uiblocks, "object_panel_particle_visual", UI_EMBOSS, UI_HELV, curarea->win); if(uiNewPanel(curarea, block, "Visualization", "Particle", 640, 0, 318, 204)==0) return; - uiDefButS(block, MENU, B_PART_RECALC, "Billboard %x9|Group %x8|Object %x7|Path %x6|Line %x5|Axis %x4|Cross %x3|Circle %x2|Point %x1|None %x0", butx,buty,butw,buth, &part->draw_as, 14.0, 0.0, 0, 0, "How particles are visualized"); + if(part->type==PART_HAIR) + uiDefButS(block, MENU, B_PART_RECALC, "Group %x8|Object %x7|Path %x6|None %x0", butx,buty,butw,buth, &part->draw_as, 14.0, 0.0, 0, 0, "How hair is visualized"); + else + uiDefButS(block, MENU, B_PART_RECALC, "Billboard %x9|Group %x8|Object %x7|Path %x6|Line %x5|Axis %x4|Cross %x3|Circle %x2|Point %x1|None %x0", butx,buty,butw,buth, &part->draw_as, 14.0, 0.0, 0, 0, "How particles are visualized"); if(part->draw_as==PART_DRAW_NOT) { uiDefButBitS(block, TOG, PART_DRAW_EMITTER, B_PART_REDRAW, "Render emitter", butx,(buty-=2*buth),butw,buth, &part->draw, 0, 0, 0, 0, "Render emitter object"); diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index f681b65925f..202d8a813f1 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -792,19 +792,13 @@ void countall() if(ob->transflag & OB_DUPLIPARTS) { ParticleSystem *psys; ParticleSettings *part; - int step_nbr; for(psys=ob->particlesystem.first; psys; psys=psys->next){ part=psys->part; - - //if(psys->flag&PSYS_BAKED && part->draw&PART_DRAW_KEYS) - // step_nbr=part->keys_step; - //else - step_nbr=1; if(part->draw_as==PART_DRAW_OB && part->dup_ob){ int tot=count_particles(psys); - count_object(part->dup_ob, 0, tot*step_nbr); + count_object(part->dup_ob, 0, tot); } else if(part->draw_as==PART_DRAW_GR && part->dup_group){ GroupObject *go; @@ -818,7 +812,7 @@ void countall() go= part->dup_group->gobject.first; while(go){ tot=count_particles_mod(psys,totgroup,cur); - count_object(go->ob, 0, tot*step_nbr); + count_object(go->ob, 0, tot); cur++; go=go->next; } -- cgit v1.2.3 From 3b2322406141bca2585d579152ba4f993f7920d0 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Apr 2009 18:13:51 +0000 Subject: Fix for [#18372] object-particle in other layer not editable correctly. --- source/blender/blenkernel/intern/anim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 79c4d15b88e..50be417c8ef 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -908,7 +908,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Object *par, float par_ else Mat4CpyMat4(mat, tmat); - dob= new_dupli_object(lb, ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); + dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated); Mat4CpyMat4(dob->omat, oldobmat); if(G.rendering) psys_get_dupli_texture(par, part, psmd, pa, cpa, dob->uv, dob->orco); -- cgit v1.2.3 From d84dc44835e817ee4b4324b1627cf5290cd9c8be Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 4 Apr 2009 12:48:40 +0000 Subject: Fix for [#18017] reactor particles affected by a curve guide emit at a wrong position. --- source/blender/blenkernel/intern/particle_system.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 7bda29ebcaf..2728addeddd 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1734,6 +1734,8 @@ void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifi VECSUB(p_vel,pa->r_ve,p_vel); Normalize(p_vel); VecMulf(p_vel,speed); + + VECCOPY(pa->fuv,loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */ } else{ /* get precise emitter matrix if particle is born */ @@ -2483,7 +2485,12 @@ static void precalc_effectors(Object *ob, ParticleSystem *psys, ParticleSystemMo ec->locations=MEM_callocN(totpart*3*sizeof(float),"particle locations"); for(p=0,pa=psys->particles; pfrom,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,0,0,0,0,0); + if(part->from == PART_FROM_PARTICLE) { + VECCOPY(loc, pa->fuv); + } + else + psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,0,0,0,0,0); + Mat4MulVecfl(ob->obmat,loc); ec->distances[p]=VecLenf(loc,vec); VECSUB(loc,loc,vec); -- cgit v1.2.3 From 9982217a727f2714808aafbb8f56eb959c25fed9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 4 Apr 2009 14:34:39 +0000 Subject: Fix for: [#18273] reactor particle spowns to earlier. Particle life "rand" value could be set above "1.0" allowing for negative particle lifetimes. --- source/blender/src/buttons_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 04aa54f2526..6f871527ab7 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -4899,7 +4899,7 @@ static void object_panel_particle_system(Object *ob) if(part->type!=PART_HAIR) { uiDefButF(block, NUM, B_PART_INIT, "Life:", butx,(buty-=buth),butw,buth, &part->lifetime, 1.0, MAXFRAMEF, 100, 1, "Specify the life span of the particles"); - uiDefButF(block, NUM, B_PART_INIT, "Rand:", butx,(buty-=buth),butw,buth, &part->randlife, 0.0, 2.0, 10, 1, "Give the particle life a random variation"); + uiDefButF(block, NUM, B_PART_INIT, "Rand:", butx,(buty-=buth),butw,buth, &part->randlife, 0.0, 1.0, 10, 1, "Give the particle life a random variation"); } uiBlockEndAlign(block); -- cgit v1.2.3 From 3fa7717b57f5d0c9667caec856e214c7597ce42c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 5 Apr 2009 06:54:47 +0000 Subject: 2.4x - Grease Pencil: Swapping the order of args for gpencil_frame_delete_laststroke() to be more consistent with the rest of the Grease Pencil API. --- source/blender/include/BDR_gpencil.h | 2 +- source/blender/src/drawgpencil.c | 2 +- source/blender/src/gpencil.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BDR_gpencil.h b/source/blender/include/BDR_gpencil.h index 6848be2a481..2835e414d1c 100644 --- a/source/blender/include/BDR_gpencil.h +++ b/source/blender/include/BDR_gpencil.h @@ -65,7 +65,7 @@ struct bGPdata *gpencil_data_getactive(struct ScrArea *sa); short gpencil_data_setactive(struct ScrArea *sa, struct bGPdata *gpd); struct ScrArea *gpencil_data_findowner(struct bGPdata *gpd); -void gpencil_frame_delete_laststroke(struct bGPDframe *gpf, bGPDlayer *gpl); +void gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf); struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, short addnew); void gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf); diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c index 3c6cef469a2..5cabb38887a 100644 --- a/source/blender/src/drawgpencil.c +++ b/source/blender/src/drawgpencil.c @@ -142,7 +142,7 @@ void gp_ui_delstroke_cb (void *gpd, void *gpl) if (gpf->framenum != CFRA) return; gpencil_layer_setactive(gpd, gpl); - gpencil_frame_delete_laststroke(gpf, gpl); + gpencil_frame_delete_laststroke(gpl, gpf); scrarea_queue_winredraw(curarea); } diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c index c7e453c416c..4f50a83a3f2 100644 --- a/source/blender/src/gpencil.c +++ b/source/blender/src/gpencil.c @@ -484,7 +484,7 @@ ScrArea *gpencil_data_findowner (bGPdata *gpd) /* -------- GP-Frame API ---------- */ /* delete the last stroke of the given frame */ -void gpencil_frame_delete_laststroke (bGPDframe *gpf, bGPDlayer *gpl) +void gpencil_frame_delete_laststroke (bGPDlayer *gpl, bGPDframe *gpf) { bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL; @@ -704,7 +704,7 @@ void gpencil_delete_laststroke (bGPdata *gpd) if (gpf->framenum != CFRA) return; - gpencil_frame_delete_laststroke(gpf, gpl); + gpencil_frame_delete_laststroke(gpl, gpf); } /* delete the active frame */ -- cgit v1.2.3 From b4e4ccf92ddc8a7d4ed3da13c589b2f7c44baa0d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 5 Apr 2009 19:37:13 +0000 Subject: BGE PyAPI can now import text (within the blend-file) Previously this only worked with the Blender API. - bpy_internal_import small C file that Blender scripting and the game engine use. - Tested with blender, blenderplayer, loading files - Needed to use a hack to override the Main struct since the game engine doesn't set G.main - when the sandbox is set, only internal scripts can be imported. --- source/blender/python/BPY_interface.c | 177 +--------------- .../blender/python/api2_2x/bpy_internal_import.c | 230 +++++++++++++++++++++ .../blender/python/api2_2x/bpy_internal_import.h | 48 +++++ 3 files changed, 281 insertions(+), 174 deletions(-) create mode 100644 source/blender/python/api2_2x/bpy_internal_import.c create mode 100644 source/blender/python/api2_2x/bpy_internal_import.h (limited to 'source/blender') diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index ec81de1f5e8..4de7942666c 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -71,6 +71,7 @@ #include "api2_2x/Registry.h" #include "api2_2x/Pose.h" #include "api2_2x/bpy.h" /* for the new "bpy" module */ +#include "api2_2x/bpy_internal_import.h" /*these next two are for pyconstraints*/ #include "api2_2x/IDProp.h" @@ -164,10 +165,8 @@ static PyObject *RunPython( Text * text, PyObject * globaldict ); static PyObject *CreateGlobalDictionary( void ); static void ReleaseGlobalDictionary( PyObject * dict ); static void DoAllScriptsFromList( ListBase * list, short event ); -static PyObject *importText( char *name ); static void init_ourImport( void ); static void init_ourReload( void ); -static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * kw); static void BPY_Err_Handle( char *script_name ); @@ -2821,91 +2820,11 @@ static void DoAllScriptsFromList( ListBase * list, short event ) return; } -static PyObject *importText( char *name ) -{ - Text *text; - char txtname[22]; /* 21+NULL */ - char *buf = NULL; - int namelen = strlen( name ); - - if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */ - - memcpy( txtname, name, namelen ); - memcpy( &txtname[namelen], ".py", 4 ); - - for(text = G.main->text.first; text; text = text->id.next) { - if( !strcmp( txtname, text->id.name+2 ) ) - break; - } - - if( !text ) - return NULL; - - if( !text->compiled ) { - buf = txt_to_buf( text ); - text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); - MEM_freeN( buf ); - - if( PyErr_Occurred( ) ) { - PyErr_Print( ); - BPY_free_compiled_text( text ); - return NULL; - } - } - - return PyImport_ExecCodeModule( name, text->compiled ); -} - -static PyMethodDef bimport[] = { - {"blimport", blender_import, METH_KEYWORDS, "our own import"} -}; - -static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * kw) -{ - PyObject *exception, *err, *tb; - char *name; - PyObject *globals = NULL, *locals = NULL, *fromlist = NULL; - PyObject *m; - - //PyObject_Print(args, stderr, 0); -#if (PY_VERSION_HEX >= 0x02060000) - int dummy_val; /* what does this do?*/ - static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; - - if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bimport", kwlist, - &name, &globals, &locals, &fromlist, &dummy_val) ) - return NULL; -#else - static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0}; - - if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bimport", kwlist, - &name, &globals, &locals, &fromlist ) ) - return NULL; -#endif - m = PyImport_ImportModuleEx( name, globals, locals, fromlist ); - - if( m ) - return m; - else - PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ - - m = importText( name ); - if( m ) { /* found module, ignore above exception */ - PyErr_Clear( ); - Py_XDECREF( exception ); - Py_XDECREF( err ); - Py_XDECREF( tb ); - printf( "imported from text buffer...\n" ); - } else { - PyErr_Restore( exception, err, tb ); - } - return m; -} static void init_ourImport( void ) { PyObject *m, *d; - PyObject *import = PyCFunction_New( bimport, NULL ); + PyObject *import = PyCFunction_New( bpy_import, NULL ); m = PyImport_AddModule( "__builtin__" ); d = PyModule_GetDict( m ); @@ -2913,100 +2832,10 @@ static void init_ourImport( void ) EXPP_dict_set_item_str( d, "__import__", import ); } -/* - * find in-memory module and recompile - */ - -static PyObject *reimportText( PyObject *module ) -{ - Text *text; - char *txtname; - char *name; - char *buf = NULL; - - /* get name, filename from the module itself */ - - txtname = PyModule_GetFilename( module ); - name = PyModule_GetName( module ); - if( !txtname || !name) - return NULL; - - /* look up the text object */ - text = ( Text * ) & ( G.main->text.first ); - while( text ) { - if( !strcmp( txtname, text->id.name+2 ) ) - break; - text = text->id.next; - } - - /* uh-oh.... didn't find it */ - if( !text ) - return NULL; - - /* if previously compiled, free the object */ - /* (can't see how could be NULL, but check just in case) */ - if( text->compiled ){ - Py_DECREF( (PyObject *)text->compiled ); - } - - /* compile the buffer */ - buf = txt_to_buf( text ); - text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); - MEM_freeN( buf ); - - /* if compile failed.... return this error */ - if( PyErr_Occurred( ) ) { - PyErr_Print( ); - BPY_free_compiled_text( text ); - return NULL; - } - - /* make into a module */ - return PyImport_ExecCodeModule( name, text->compiled ); -} - -/* - * our reload() module, to handle reloading in-memory scripts - */ - -static PyObject *blender_reload( PyObject * self, PyObject * args ) -{ - PyObject *exception, *err, *tb; - PyObject *module = NULL; - PyObject *newmodule = NULL; - - /* check for a module arg */ - if( !PyArg_ParseTuple( args, "O:breload", &module ) ) - return NULL; - - /* try reimporting from file */ - newmodule = PyImport_ReloadModule( module ); - if( newmodule ) - return newmodule; - - /* no file, try importing from memory */ - PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ - - newmodule = reimportText( module ); - if( newmodule ) { /* found module, ignore above exception */ - PyErr_Clear( ); - Py_XDECREF( exception ); - Py_XDECREF( err ); - Py_XDECREF( tb ); - } else - PyErr_Restore( exception, err, tb ); - - return newmodule; -} - -static PyMethodDef breload[] = { - {"blreload", blender_reload, METH_VARARGS, "our own reload"} -}; - static void init_ourReload( void ) { PyObject *m, *d; - PyObject *reload = PyCFunction_New( breload, NULL ); + PyObject *reload = PyCFunction_New( bpy_reload, NULL ); m = PyImport_AddModule( "__builtin__" ); d = PyModule_GetDict( m ); diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c new file mode 100644 index 00000000000..fe69950f8c9 --- /dev/null +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -0,0 +1,230 @@ +/* + * $Id: bpy_types.h 14444 2008-04-16 22:40:48Z hos $ + * ***** 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. + * + * This is a new part of Blender. + * + * Contributor(s): Willian P. Germano + * + * ***** END GPL LICENSE BLOCK ***** +*/ + +#include "bpy_internal_import.h" +#include "DNA_text_types.h" +#include "DNA_ID.h" + +#include "BKE_global.h" +#include "MEM_guardedalloc.h" +#include "BKE_text.h" /* txt_to_buf */ +#include "BKE_main.h" + +static Main *bpy_import_main= NULL; + +static void free_compiled_text(Text *text) +{ + if(text->compiled) { + Py_DECREF(text->compiled); + } + text->compiled= NULL; +} + +struct Main *bpy_import_main_get(void) +{ + return bpy_import_main; +} + +void bpy_import_main_set(struct Main *maggie) +{ + bpy_import_main= maggie; +} + + +PyObject *importText( char *name ) +{ + Text *text; + char txtname[22]; /* 21+NULL */ + char *buf = NULL; + int namelen = strlen( name ); + Main *maggie= bpy_import_main ? bpy_import_main:G.main; + + if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */ + + memcpy( txtname, name, namelen ); + memcpy( &txtname[namelen], ".py", 4 ); + + for(text = maggie->text.first; text; text = text->id.next) { + fprintf(stderr, "%s | %s\n", txtname, text->id.name+2); + if( !strcmp( txtname, text->id.name+2 ) ) + break; + } + + if( !text ) + return NULL; + + if( !text->compiled ) { + buf = txt_to_buf( text ); + text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); + MEM_freeN( buf ); + + if( PyErr_Occurred( ) ) { + PyErr_Print( ); + free_compiled_text( text ); + return NULL; + } + } + + return PyImport_ExecCodeModule( name, text->compiled ); +} + + +/* + * find in-memory module and recompile + */ + +PyObject *reimportText( PyObject *module ) +{ + Text *text; + char *txtname; + char *name; + char *buf = NULL; + Main *maggie= bpy_import_main ? bpy_import_main:G.main; + + /* get name, filename from the module itself */ + + txtname = PyModule_GetFilename( module ); + name = PyModule_GetName( module ); + if( !txtname || !name) + return NULL; + + /* look up the text object */ + text = ( Text * ) & ( maggie->text.first ); + while( text ) { + if( !strcmp( txtname, text->id.name+2 ) ) + break; + text = text->id.next; + } + + /* uh-oh.... didn't find it */ + if( !text ) + return NULL; + + /* if previously compiled, free the object */ + /* (can't see how could be NULL, but check just in case) */ + if( text->compiled ){ + Py_DECREF( (PyObject *)text->compiled ); + } + + /* compile the buffer */ + buf = txt_to_buf( text ); + text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); + MEM_freeN( buf ); + + /* if compile failed.... return this error */ + if( PyErr_Occurred( ) ) { + PyErr_Print( ); + free_compiled_text( text ); + return NULL; + } + + /* make into a module */ + return PyImport_ExecCodeModule( name, text->compiled ); +} + + +static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * kw) +{ + PyObject *exception, *err, *tb; + char *name; + PyObject *globals = NULL, *locals = NULL, *fromlist = NULL; + PyObject *m; + + //PyObject_Print(args, stderr, 0); +#if (PY_VERSION_HEX >= 0x02060000) + int dummy_val; /* what does this do?*/ + static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; + + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import", kwlist, + &name, &globals, &locals, &fromlist, &dummy_val) ) + return NULL; +#else + static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0}; + + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import", kwlist, + &name, &globals, &locals, &fromlist ) ) + return NULL; +#endif + m = PyImport_ImportModuleEx( name, globals, locals, fromlist ); + + if( m ) + return m; + else + PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ + + m = importText( name ); + if( m ) { /* found module, ignore above exception */ + PyErr_Clear( ); + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + printf( "imported from text buffer...\n" ); + } else { + PyErr_Restore( exception, err, tb ); + } + return m; +} + + +/* + * our reload() module, to handle reloading in-memory scripts + */ + +static PyObject *blender_reload( PyObject * self, PyObject * args ) +{ + PyObject *exception, *err, *tb; + PyObject *module = NULL; + PyObject *newmodule = NULL; + + /* check for a module arg */ + if( !PyArg_ParseTuple( args, "O:bpy_reload", &module ) ) + return NULL; + + /* try reimporting from file */ + newmodule = PyImport_ReloadModule( module ); + if( newmodule ) + return newmodule; + + /* no file, try importing from memory */ + PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ + + newmodule = reimportText( module ); + if( newmodule ) { /* found module, ignore above exception */ + PyErr_Clear( ); + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + } else + PyErr_Restore( exception, err, tb ); + + return newmodule; +} + +PyMethodDef bpy_import[] = { {"bpy_import", blender_import, METH_KEYWORDS, "blenders import"} }; +PyMethodDef bpy_reload[] = { {"bpy_reload", blender_reload, METH_VARARGS, "blenders reload"} }; + diff --git a/source/blender/python/api2_2x/bpy_internal_import.h b/source/blender/python/api2_2x/bpy_internal_import.h new file mode 100644 index 00000000000..773749b10f9 --- /dev/null +++ b/source/blender/python/api2_2x/bpy_internal_import.h @@ -0,0 +1,48 @@ +/* + * $Id: bpy_types.h 14444 2008-04-16 22:40:48Z hos $ + * ***** 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. + * + * This is a new part of Blender. + * + * Contributor(s): Willian P. Germano, Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** +*/ + +/* Note, the BGE needs to use this too, keep it minimal */ + +#ifndef EXPP_bpy_import_h +#define EXPP_bpy_import_h + +#include +#include "compile.h" /* for the PyCodeObject */ +#include "eval.h" /* for PyEval_EvalCode */ + +PyObject *importText( char *name ); +PyObject *reimportText( PyObject *module ); +extern PyMethodDef bpy_import[]; +extern PyMethodDef bpy_reload[]; + +/* The game engine has its own Main struct, if this is set search this rather then G.main */ +struct Main *bpy_import_main_get(void); +void bpy_import_main_set(struct Main *maggie); + + +#endif /* EXPP_bpy_import_h */ -- cgit v1.2.3 From 9a1e1912e173262436598efe62f4ff0134ea04a7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 6 Apr 2009 00:04:04 +0000 Subject: 2.4x Bugfix - #18188: "Clear user transform" does not work as described For the record, "Clear user transform" is supposed to restore selected bones to the transforms defined by Actions/NLA, not back to rest position. --- source/blender/include/BIF_poseobject.h | 1 + source/blender/src/header_view3d.c | 6 +----- source/blender/src/poseobject.c | 30 +++++++++++++++++++++++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BIF_poseobject.h b/source/blender/include/BIF_poseobject.h index ab96f7ec03e..ba7ad8c4e77 100644 --- a/source/blender/include/BIF_poseobject.h +++ b/source/blender/include/BIF_poseobject.h @@ -80,6 +80,7 @@ void pose_activate_flipped_bone(void); void pose_movetolayer(void); void pose_relax(void); void pose_flipquats(void); +void pose_clear_user_transforms(void); #endif diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 8171fe2e527..6d72e434e67 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -4123,8 +4123,6 @@ static uiBlock *view3d_edit_armaturemenu(void *arg_unused) static void do_view3d_pose_armature_transformmenu(void *arg, int event) { - Object *ob= OBACT; - switch(event) { case 0: /* clear origin */ clear_object('o'); @@ -4139,9 +4137,7 @@ static void do_view3d_pose_armature_transformmenu(void *arg, int event) clear_object('g'); break; case 4: /* clear user transform */ - rest_pose(ob->pose); - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - BIF_undo_push("Pose, Clear User Transform"); + pose_clear_user_transforms(); break; } allqueue(REDRAWVIEW3D, 0); diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index c2a2be80e89..c081bcbcb45 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -568,9 +568,7 @@ void pose_special_editmenu(void) pose_clear_paths(ob); } else if(nr==5) { - rest_pose(ob->pose); - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - BIF_undo_push("Clear User Transform Pose"); + pose_clear_user_transforms(); } else if(nr==6) { pose_relax(); @@ -1740,4 +1738,30 @@ void pose_flipquats(void) autokeyframe_pose_cb_func(ob, TFM_ROTATION, 0); } +/* Restore selected pose-bones to 'action'-defined pose */ +void pose_clear_user_transforms (void) +{ + Object *ob = OBACT; + bArmature *arm= ob->data; + bPoseChannel *pchan; + + if (ob->pose == NULL) + return; + + /* find selected bones */ + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + if (pchan->bone && (pchan->bone->flag & BONE_SELECTED) && (pchan->bone->layer & arm->layer)) { + /* just clear the BONE_UNKEYED flag, allowing this bone to get overwritten by actions again */ + pchan->bone->flag &= ~BONE_UNKEYED; + } + } + + /* clear pose locking flag + * - this will only clear the user-defined pose in the selected bones, where BONE_UNKEYED has been cleared + */ + ob->pose->flag |= POSE_DO_UNLOCK; + + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + BIF_undo_push("Clear User Transform"); +} -- cgit v1.2.3 From 58b1e04fe0a026d57c3f456393468bd0d596054b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 6 Apr 2009 00:10:52 +0000 Subject: Fix for: [#18371] VParent breaks fur effects. -Virtual parents were not randomly selected due to optimization in child particle distribution code. -Wave-kink had a wrong matrix multiplication. -Amount of virtual parents wasn't scaled properly to the amount of children rendered. -Calculating virtual parents is now thread safe. --- source/blender/blenkernel/BKE_particle.h | 2 +- source/blender/blenkernel/intern/particle.c | 56 +++++++++++++++++----- source/blender/blenkernel/intern/particle_system.c | 3 +- 3 files changed, 48 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 5dbfe2fe520..5f5635bae1f 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -173,7 +173,7 @@ typedef struct ParticleThreadContext { /* path caching */ int editupdate, between, steps; - int totchild, totparent; + int totchild, totparent, parent_pass; float cfra; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 4eabb82f6cb..3fea9e44acb 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1461,7 +1461,7 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo case PART_KINK_WAVE: vec[axis]=1.0; if(obmat) - Mat4MulVecfl(obmat,vec); + Mat4Mul3Vecfl(obmat,vec); if(par_rot) QuatMulVecf(par_rot,vec); @@ -1805,10 +1805,13 @@ void psys_find_parents(Object *ob, ParticleSystemModifierData *psmd, ParticleSys int from=PART_FROM_FACE; totparent=(int)(totchild*part->parents*0.3); + if(G.rendering && part->child_nbr && part->ren_child_nbr) + totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; + tree=BLI_kdtree_new(totparent); for(p=0,cpa=psys->child; pnum,-1,cpa->fuv,cpa->foffset,co,0,0,0,orco,0); + psys_particle_on_emitter(psmd,from,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co,0,0,0,orco,0); BLI_kdtree_insert(tree, p, orco, NULL); } @@ -1872,6 +1875,10 @@ int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate) if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ totparent=(int)(totchild*part->parents*0.3); + + if(G.rendering && part->child_nbr && part->ren_child_nbr) + totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; + /* part->parents could still be 0 so we can't test with totparent */ between=1; } @@ -1904,6 +1911,7 @@ int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate) ctx->steps= steps; ctx->totchild= totchild; ctx->totparent= totparent; + ctx->parent_pass= 0; ctx->cfra= cfra; psys->lattice = psys_get_lattice(ob, psys); @@ -1941,14 +1949,14 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, ParticleCacheKey *state, *par = NULL, *key[4]; ParticleData *pa=NULL; ParticleTexture ptex; - float *cpa_fuv=0; + float *cpa_fuv=0, *par_rot=0; float co[3], orco[3], ornor[3], t, rough_t, cpa_1st[3], dvec[3]; float branch_begin, branch_end, branch_prob, branchfac, rough_rand; float pa_rough1, pa_rough2, pa_roughe; float length, pa_length, pa_clump, pa_kink, pa_effector; float max_length = 1.0f, cur_length = 0.0f; float eff_length, eff_vec[3]; - int k, cpa_num, guided=0; + int k, cpa_num, guided = 0; short cpa_from; if(part->flag & PART_BRANCHING) { @@ -2138,15 +2146,16 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, t=(float)k/(float)ctx->steps; if(ctx->totparent){ - if(i>=ctx->totparent) - /* this is not threadsafe, but should only happen for - * branching particles particles, which are not threaded */ + if(i>=ctx->totparent) { + /* this is now threadsafe, virtual parents are calculated before rest of children */ par = cache[cpa->parent] + k; + } else par=0; } else if(cpa->parent>=0){ par=pcache[cpa->parent]+k; + par_rot = par->rot; } /* apply different deformations to the child path */ @@ -2156,7 +2165,7 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, if(guided==0){ if(part->kink) - do_prekink((ParticleKey*)state, (ParticleKey*)par, par->rot, t, + do_prekink((ParticleKey*)state, (ParticleKey*)par, par_rot, t, part->kink_freq * pa_kink, part->kink_shape, part->kink_amp, part->kink, part->kink_axis, ob->obmat); do_clump((ParticleKey*)state, (ParticleKey*)par, t, part->clumpfac, part->clumppow, pa_clump); @@ -2255,10 +2264,15 @@ static void *exec_child_path_cache(void *data) ParticleSystem *psys= ctx->psys; ParticleCacheKey **cache= psys->childcache; ChildParticle *cpa; - int i, totchild= ctx->totchild; + int i, totchild= ctx->totchild, first= 0; + + if(thread->tot > 1){ + first= ctx->parent_pass? 0 : ctx->totparent; + totchild= ctx->parent_pass? ctx->totparent : ctx->totchild; + } - cpa= psys->child + thread->num; - for(i=thread->num; itot, cpa+=thread->tot) + cpa= psys->child + first + thread->num; + for(i=first+thread->num; itot, cpa+=thread->tot) psys_thread_create_path(thread, cpa, cache[i], i); return 0; @@ -2297,6 +2311,22 @@ void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int ed totthread= pthreads[0].tot; if(totthread > 1) { + + /* make virtual child parents thread safe by calculating them first */ + if(totparent) { + BLI_init_threads(&threads, exec_child_path_cache, totthread); + + for(i=0; iparent_pass = 1; + BLI_insert_thread(&threads, &pthreads[i]); + } + + BLI_end_threads(&threads); + + for(i=0; iparent_pass = 0; + } + BLI_init_threads(&threads, exec_child_path_cache, totthread); for(i=0; ifrom!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ totparent=(int)(totchild*part->parents*0.3); + + if(G.rendering && part->child_nbr && part->ren_child_nbr) + totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; + /* part->parents could still be 0 so we can't test with totparent */ between=1; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 2728addeddd..8720edf6c24 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1301,7 +1301,8 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm MEM_freeN(sum); /* for hair, sort by origindex, allows optimizations in rendering */ - if(part->type == PART_HAIR) { + /* however with virtual parents the children need to be in random order */ + if(part->type == PART_HAIR && !(part->childtype==PART_CHILD_FACES && part->parents!=0.0)) { COMPARE_ORIG_INDEX= dm->getFaceDataArray(dm, CD_ORIGINDEX); if(COMPARE_ORIG_INDEX) qsort(index, totpart, sizeof(int), compare_orig_index); -- cgit v1.2.3 From ab467e72382c125642e7f7d03308a6913ec9c716 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 6 Apr 2009 00:22:58 +0000 Subject: 2.4x Bugfix #18279 - Copy Vertex Group Location doesn't work with subsurf modifier --- source/blender/blenkernel/intern/constraint.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b668a1f214d..db98c200566 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -540,6 +540,7 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3]; float imat[3][3], tmat[3][3]; int dgroup; + short freeDM = 0; /* initialize target matrix using target matrix */ Mat4CpyMat4(mat, ob->obmat); @@ -552,10 +553,19 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) if ((G.obedit == ob) && (G.editMesh)) { /* target is in editmode, so get a special derived mesh */ dm = CDDM_from_editmesh(G.editMesh, ob->data); + freeDM= 1; } else { - /* when not in EditMode, this should exist */ - dm = (DerivedMesh *)ob->derivedFinal; + /* when not in EditMode, use the 'final' derived mesh + * - check if the custom data masks for derivedFinal mean that we can just use that + * (this is more effficient + sufficient for most cases) + */ + if (ob->lastDataMask != CD_MASK_DERIVEDMESH) { + dm = mesh_get_derived_final(ob, CD_MASK_DERIVEDMESH); + freeDM= 1; + } + else + dm = (DerivedMesh *)ob->derivedFinal; } /* only continue if there's a valid DerivedMesh */ @@ -620,10 +630,9 @@ static void contarget_get_mesh_mat (Object *ob, char *substring, float mat[][4]) } } - /* free temporary DerivedMesh created (in EditMode case) */ - if (G.editMesh) { - if (dm) dm->release(dm); - } + /* free temporary DerivedMesh created */ + if (dm && freeDM) + dm->release(dm); } /* function that sets the given matrix based on given vertex group in lattice */ -- cgit v1.2.3 From fe562f0dd4be9c9aecffc777a9a91a57540eb8c6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 6 Apr 2009 00:43:59 +0000 Subject: Fix for: [#18482] Mixed object and halo visualization for particles needs "Emitter" to be activated. --- source/blender/render/intern/source/convertblender.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'source/blender') diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 9e474c19619..06ba8f16a3b 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4374,24 +4374,8 @@ void RE_Database_Free(Render *re) static int allow_render_object(Object *ob, int nolamps, int onlyselected, Object *actob) { /* override not showing object when duplis are used with particles */ - if(ob->transflag & OB_DUPLIPARTS){ - int allow= 0; - - if(ob->particlesystem.first) { - ParticleSystem *psys; - ParticleSettings *part; - - for(psys=ob->particlesystem.first; psys; psys=psys->next){ - part=psys->part; - - if(part->draw & PART_DRAW_EMITTER) - allow= 1; - } - } - - if(!allow) - return 0; - } + if(ob->transflag & OB_DUPLIPARTS) + ; /* let particle system(s) handle showing vs. not showing */ else if((ob->transflag & OB_DUPLI) && !(ob->transflag & OB_DUPLIFRAMES)) return 0; -- cgit v1.2.3 From a95f97cb2832296fc02cb2cb236cbb69d51a3cf1 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 6 Apr 2009 01:43:01 +0000 Subject: cast needed to get things compiling again on my machine. Kent --- source/blender/python/api2_2x/bpy_internal_import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c index fe69950f8c9..1423ffe522b 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.c +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -40,7 +40,7 @@ static Main *bpy_import_main= NULL; static void free_compiled_text(Text *text) { if(text->compiled) { - Py_DECREF(text->compiled); + Py_DECREF(( PyObject * )text->compiled); } text->compiled= NULL; } -- cgit v1.2.3 From fdceee008867179e36028853d85356c034f48e23 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 6 Apr 2009 09:05:37 +0000 Subject: Bugfix #18266 Mipmap creation for render crashed, in this case: - use Curves tool on an Image, which is UV mapped on object - Save the image to disk, under new name - Render (F12) This fix is only for the crash, there's something not well coded for Curves tool, how it manages float buffers. That's for 2.5. --- source/blender/imbuf/intern/scaling.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 8257eb4643e..807b0c84e90 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -299,7 +299,6 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1) if (ibuf1->rect==NULL && ibuf1->rect_float==NULL) return (0); do_rect= (ibuf1->rect != NULL); - do_float= (ibuf1->rect_float != NULL); if (ibuf1->x <= 1) return(IMB_half_y(ibuf1)); if (ibuf1->y <= 1) return(IMB_half_x(ibuf1)); @@ -312,6 +311,8 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1) p1 = (uchar *) ibuf1->rect; dest=(uchar *) ibuf2->rect; + do_float= (ibuf1->rect_float != NULL && ibuf2->rect_float != NULL); + for(y=ibuf2->y;y>0;y--){ if (do_rect) p2 = p1 + (ibuf1->x << 2); if (do_float) p2f = p1f + (ibuf1->x << 2); -- cgit v1.2.3 From 64fe09ab20ce4f80f627d4c868f2b12936c2168c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Apr 2009 12:47:15 +0000 Subject: - remove debug printf - remove test for importing the module rather then creating a new one (didnt mean to commit) - added constants for the mouse sensor to use. --- source/blender/python/api2_2x/bpy_internal_import.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c index 1423ffe522b..d8280d4d609 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.c +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -70,7 +70,6 @@ PyObject *importText( char *name ) memcpy( &txtname[namelen], ".py", 4 ); for(text = maggie->text.first; text; text = text->id.next) { - fprintf(stderr, "%s | %s\n", txtname, text->id.name+2); if( !strcmp( txtname, text->id.name+2 ) ) break; } -- cgit v1.2.3 From 445ca000bcdc732de3c1af8d98f726bd71b96423 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 6 Apr 2009 18:08:15 +0000 Subject: bugfix #18398 When using 'angle' display for camera, the 'lens' ipo didn't update this button. Implementation still lacks a bit... having both variables in the camera struct is asking for troubles. Put on the re-think list for 2.5! --- source/blender/src/buttons_editing.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender') diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 80495b9ff80..8b249815b6f 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -3727,6 +3727,9 @@ static void editing_panel_camera_type(Object *ob, Camera *cam) 10, 160, 150, 20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera"); } else { if(cam->flag & CAM_ANGLETOGGLE) { + /* ensure animated lens value is always copied */ + do_lenstoangleconversion_cb(&cam->lens, &cam->angle); + but= uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", 10, 160, 130, 20, &cam->angle, 7.323871, 172.847331, 100, 0, "Specify the lens of the camera in degrees"); uiButSetFunc(but,do_angletolensconversion_cb, &cam->lens, &cam->angle); -- cgit v1.2.3 From 30ce01f23ffb2c926e5bbaaabf07c63611f7ea89 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 6 Apr 2009 19:32:23 +0000 Subject: Fix for: [#18354] Controlling with a texture the particles DENSITY parameter doesn't work. If the density texture was taken into account with hair parent particles there were cases when there weren't any parents left to interpolate children from. Now a density texture is only taken into account for hair child particles. --- source/blender/blenkernel/intern/particle_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 8720edf6c24..0ffdd11c37a 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1616,7 +1616,7 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps NormalQuat(pa->r_rot); - if(part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){ + if(part->type!=PART_HAIR && part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){ /* any unique random number will do (r_ave[0]) */ if(ptex.exist < 0.5*(1.0+pa->r_ave[0])) pa->flag |= PARS_UNEXIST; -- cgit v1.2.3 From b8270db75c8aa6898794c482bff933f50f21381a Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 6 Apr 2009 23:23:36 +0000 Subject: Harmonic effector force wasn't working properly at all. A silly vector normalization where it shouldn't have been. --- source/blender/blenkernel/intern/effect.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 0338ec92414..a6514ae7b87 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -442,14 +442,11 @@ void do_physical_effector(Object *ob, float *opco, short type, float force_val, else VecCopyf(mag_vec,vec_to_part); - Normalize(mag_vec); - VecMulf(mag_vec,force_val*falloff); VecSubf(field,field,mag_vec); VecCopyf(mag_vec,velocity); - /* 1.9 is an experimental value to get critical damping at damp=1.0 */ - VecMulf(mag_vec,damp*1.9f*(float)sqrt(force_val)); + VecMulf(mag_vec,damp*2.0f*(float)sqrt(force_val)); VecSubf(field,field,mag_vec); break; case PFIELD_CHARGE: -- cgit v1.2.3 From 7e23b7dc54f8c59eb3ccbf13839552a3b24a9c5b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 7 Apr 2009 00:15:58 +0000 Subject: Texture effector nabla didn't have a correct initial value and it's button explanation needed some work. --- source/blender/src/buttons_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 6f871527ab7..5c41390b150 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3360,6 +3360,7 @@ static void object_panel_fields(Object *ob) ob->pd->pdef_sbdamp = 0.1f; ob->pd->pdef_sbift = 0.2f; ob->pd->pdef_sboft = 0.02f; + ob->pd->tex_nabla = 0.025f; } if(ob->pd) { @@ -3467,7 +3468,7 @@ static void object_panel_fields(Object *ob) else if(pd->forcefield==PFIELD_TEXTURE){ uiDefButS(block, MENU, B_FIELD_CHANGE, "Texture mode%t|RGB%x0|Gradient%x1|Curl%x2", 10,50,140,20, &pd->tex_mode, 0.0, 0.0, 0, 0, "How the texture effect is calculated (RGB & Curl need a RGB texture else Gradient will be used instead)"); - uiDefButF(block, NUM, B_FIELD_CHANGE, "Nabla:", 10,30,140,20, &pd->tex_nabla, 0.0001f, 1.0, 1, 0, "Specify the dimension of the area for gradient and curl calculation"); + uiDefButF(block, NUM, B_FIELD_CHANGE, "Nabla:", 10,30,140,20, &pd->tex_nabla, 0.0001f, 1.0, 1, 0, "Defines size of derivative offset used for calculating gradient and curl"); } else if(particles==0 && ELEM(pd->forcefield,PFIELD_VORTEX,PFIELD_WIND)==0){ //uiDefButF(block, NUM, B_FIELD_CHANGE, "Distance: ", 10,20,140,20, &pd->f_dist, 0, 1000.0, 10, 0, "Falloff power (real gravitational fallof = 2)"); -- cgit v1.2.3 From a127f259da8f443b5f727528bca5e89d3ac7a48d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 7 Apr 2009 03:00:32 +0000 Subject: Fix for: [#18027] Strange behaviour of Explode modifier in combination with SubSurf - Explode didn't use the dmcache index for getting the particles emitter position. - One "tri or quad"-comparison tested the wrong index. Leading to one quad converting into a tri. --- source/blender/blenkernel/intern/modifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index b3892a515af..d182e3124fc 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -7193,7 +7193,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, pa= pars+i; /* get particle state */ - psys_particle_on_emitter(psmd,part->from,pa->num,-1,pa->fuv,pa->foffset,loc0,nor,0,0,0,0); + psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,0,0,0,0); Mat4MulVecfl(ob->obmat,loc0); state.time=cfra; @@ -7249,7 +7249,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, *mf = source; - test_index_face(mf, &explode->faceData, i, (mf->v4 ? 4 : 3)); + test_index_face(mf, &explode->faceData, i, (orig_v4 ? 4 : 3)); } MEM_printmemlist_stats(); -- cgit v1.2.3 From 885fa49aa4cd49a552bfe6210e3cb4701c4a5d04 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Apr 2009 06:23:45 +0000 Subject: BGE Joystick Sensor - Raised limit of 2 axis to 4 axis pairs (4==8 joysticks axis pairs) - Added a new Joystick Sensor type "Single Axis", so you can detect horizontal or vertical movement, rather then just Up/Down/Left/Right - added Python attribute "axisSingle" so you can get the value from the selected axis (rather then getting it out of the axis list) - renamed Py attribute "axisPosition" to "axisValues" (was never in a release) If we need to increase the axis limit again just change JOYAXIS_MAX and the button limits. --- source/blender/makesdna/DNA_sensor_types.h | 11 +++--- source/blender/src/buttons_logic.c | 56 ++++++++++++++++++------------ 2 files changed, 40 insertions(+), 27 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesdna/DNA_sensor_types.h b/source/blender/makesdna/DNA_sensor_types.h index 2cae2cc8ccb..7a358ad0694 100644 --- a/source/blender/makesdna/DNA_sensor_types.h +++ b/source/blender/makesdna/DNA_sensor_types.h @@ -166,7 +166,8 @@ typedef struct bJoystickSensor { char type; char joyindex; short flag; - int axis; + short axis; + short axis_single; int axisf; int button; int hat; @@ -255,20 +256,22 @@ typedef struct bJoystickSensor { #define SENS_JOY_ANY_EVENT 1 -#define SENS_JOY_BUTTON 0 +#define SENS_JOY_BUTTON 0 /* axis type */ #define SENS_JOY_BUTTON_PRESSED 0 #define SENS_JOY_BUTTON_RELEASED 1 -#define SENS_JOY_AXIS 1 +#define SENS_JOY_AXIS 1 /* axis type */ #define SENS_JOY_X_AXIS 0 #define SENS_JOY_Y_AXIS 1 #define SENS_JOY_NEG_X_AXIS 2 #define SENS_JOY_NEG_Y_AXIS 3 #define SENS_JOY_PRECISION 4 -#define SENS_JOY_HAT 2 +#define SENS_JOY_HAT 2 /* axis type */ #define SENS_JOY_HAT_DIR 0 +#define SENS_JOY_AXIS_SINGLE 3 /* axis type */ + #define SENS_DELAY_REPEAT 1 // should match JOYINDEX_MAX in SCA_JoystickDefines.h */ diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index cf6d29da0d3..94790ac0f40 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1457,32 +1457,33 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short &joy->joyindex, 0, SENS_JOY_MAXINDEX-1, 100, 0, "Specify which joystick to use"); - str= "Type %t|Button %x0|Axis %x1|Hat%x2"; + str= "Type %t|Button %x0|Axis %x1|Single Axis %x3|Hat%x2"; uiDefButC(block, MENU, B_REDR, str, xco+87, yco-44, 0.26 * (width-20), 19, &joy->type, 0, 31, 0, 0, "The type of event this joystick sensor is triggered on."); - if (joy->flag & SENS_JOY_ANY_EVENT) { - switch (joy->type) { - case SENS_JOY_AXIS: - str = "All Axis Events"; - break; - case SENS_JOY_BUTTON: - str = "All Button Events"; - break; - default: - str = "All Hat Events"; - break; + if (joy->type != SENS_JOY_AXIS_SINGLE) { + if (joy->flag & SENS_JOY_ANY_EVENT) { + switch (joy->type) { + case SENS_JOY_AXIS: + str = "All Axis Events"; + break; + case SENS_JOY_BUTTON: + str = "All Button Events"; + break; + default: + str = "All Hat Events"; + break; + } + } else { + str = "All"; } - } else { - str = "All"; + + uiDefButBitS(block, TOG, SENS_JOY_ANY_EVENT, B_REDR, str, + xco+10 + 0.475 * (width-20), yco-68, ((joy->flag & SENS_JOY_ANY_EVENT) ? 0.525 : 0.12) * (width-20), 19, + &joy->flag, 0, 0, 0, 0, + "Triggered by all events on this joysticks current type (axis/button/hat)"); } - - uiDefButBitS(block, TOG, SENS_JOY_ANY_EVENT, B_REDR, str, - xco+10 + 0.475 * (width-20), yco-68, ((joy->flag & SENS_JOY_ANY_EVENT) ? 0.525 : 0.12) * (width-20), 19, - &joy->flag, 0, 0, 0, 0, - "Triggered by all events on this joysticks current type (axis/button/hat)"); - if(joy->type == SENS_JOY_BUTTON) { if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { @@ -1493,8 +1494,8 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short } else if(joy->type == SENS_JOY_AXIS) { - uiDefButI(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, - &joy->axis, 1, 2.0, 100, 0, + uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, + &joy->axis, 1, 4.0, 100, 0, "Specify which axis pair to use, 1 is useually the main direction input."); uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20),yco-44, 0.4 * (width-20), 19, @@ -1508,7 +1509,7 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short "The direction of the axis, use 'All Events' to recieve events on any direction"); } } - else + else if (joy->type == SENS_JOY_HAT) { uiDefButI(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, &joy->hat, 1, 2.0, 100, 0, @@ -1520,6 +1521,15 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short "Specify hat direction"); } } + else { /* (joy->type == SENS_JOY_AXIS_SINGLE)*/ + uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, + &joy->axis_single, 1, 8.0, 100, 0, + "Specify a single axis (verticle/horizontal/other) to detect"); + + uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20),yco-44, 0.4 * (width-20), 19, + &joy->precision, 0, 32768.0, 100, 0, + "Specify the precision of the axis"); + } yco-= ysize; break; } -- cgit v1.2.3 From 6b1ccddc0d921d096d42f5fa866ad444606da1c5 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 7 Apr 2009 07:46:58 +0000 Subject: bugfix #18196 Halos for objects (not particles) can get texture color, but they skipped the alpha mapt-to channel when that was set. Actually bug from ehh 1995! --- source/blender/render/intern/source/renderdatabase.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index d44b49cc706..621831fb341 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1032,9 +1032,11 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f har->g= (yn*tg+ zn*ma->g); har->b= (yn*tb+ zn*ma->b); } - if(mtex->texco & 16) { + if(mtex->texco & TEXCO_UV) { har->alfa= tin; } + if(mtex->mapto & MAP_ALPHA) + har->alfa= tin; } } -- cgit v1.2.3 From ca1c3be3029a7a7aada686372ca1dd6ab39f0547 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Apr 2009 18:55:35 +0000 Subject: BGE Py API - Added OpenGL access to the game engine as a module so you can import BGL directly. --- source/blender/python/api2_2x/BGL.c | 23 ++++++++++------------- source/blender/python/api2_2x/BGL.h | 1 + source/blender/python/api2_2x/Blender.c | 2 +- source/blender/python/api2_2x/modules.h | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c index 2503a66250b..e5868a82c2c 100644 --- a/source/blender/python/api2_2x/BGL.c +++ b/source/blender/python/api2_2x/BGL.c @@ -35,7 +35,6 @@ #include "BGL.h" /*This must come first */ #include "MEM_guardedalloc.h" -#include "gen_utils.h" static int type_size( int type ); static Buffer *make_buffer( int type, int ndimensions, int *dimensions ); @@ -121,8 +120,6 @@ static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\ /* #endif */ -PyObject *BGL_Init( void ); - /********/ static int type_size(int type) { @@ -185,12 +182,12 @@ static PyObject *Method_Buffer (PyObject *self, PyObject *args) int i, type; int *dimensions = 0, ndimensions = 0; - if (!PyArg_ParseTuple(args, "iO|O", &type, &length_ob, &template)) - return EXPP_ReturnPyObjError(PyExc_AttributeError, - "expected an int and one or two PyObjects"); - + if (!PyArg_ParseTuple(args, "iO|O", &type, &length_ob, &template)) { + PyErr_SetString(PyExc_AttributeError, "expected an int and one or two PyObjects"); + return NULL; + } if (type!=GL_BYTE && type!=GL_SHORT && type!=GL_INT && type!=GL_FLOAT && type!=GL_DOUBLE) { - PyErr_SetString(PyExc_AttributeError, "type"); + PyErr_SetString(PyExc_AttributeError, "invalid first argument type, should be one of GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT or GL_DOUBLE"); return NULL; } @@ -1088,19 +1085,19 @@ static struct PyMethodDef BGL_methods[] = { {NULL, NULL, 0, NULL} }; -PyObject *BGL_Init(void) +PyObject *BGL_Init(const char *from) { - PyObject *mod= Py_InitModule("Blender.BGL", BGL_methods); + PyObject *mod= Py_InitModule(from, BGL_methods); PyObject *dict= PyModule_GetDict(mod); - + PyObject *item; if( PyType_Ready( &buffer_Type) < 0) Py_RETURN_NONE; -#define EXPP_ADDCONST(x) EXPP_dict_set_item_str(dict, #x, PyInt_FromLong((int)x)) +#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, item=PyInt_FromLong((int)x)); Py_DECREF(item) /* So, for example: * EXPP_ADDCONST(GL_CURRENT_BIT) becomes - * EXPP_dict_set_item_str(dict, "GL_CURRENT_BIT", PyInt_FromLong(GL_CURRENT_BIT)) */ + * PyDict_SetItemString(dict, "GL_CURRENT_BIT", item=PyInt_FromLong(GL_CURRENT_BIT)); Py_DECREF(item) */ EXPP_ADDCONST(GL_CURRENT_BIT); EXPP_ADDCONST(GL_POINT_BIT); diff --git a/source/blender/python/api2_2x/BGL.h b/source/blender/python/api2_2x/BGL.h index 461f5bc9372..89e56811b29 100644 --- a/source/blender/python/api2_2x/BGL.h +++ b/source/blender/python/api2_2x/BGL.h @@ -43,6 +43,7 @@ #include #include "BIF_gl.h" +PyObject *BGL_Init( const char *from ); /*@ Buffer Object */ /*@ For Python access to OpenGL functions requiring a pointer. */ diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index d09506f731b..2e44f0635e5 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -1074,7 +1074,7 @@ void M_Blender_Init(void) PyDict_SetItemString(dict, "Armature", Armature_Init()); PyDict_SetItemString(dict, "BezTriple", BezTriple_Init()); - PyDict_SetItemString(dict, "BGL", BGL_Init()); + PyDict_SetItemString(dict, "BGL", BGL_Init("Blender.BGL")); PyDict_SetItemString(dict, "CurNurb", CurNurb_Init()); PyDict_SetItemString(dict, "Constraint", Constraint_Init()); PyDict_SetItemString(dict, "Curve", Curve_Init()); diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h index 8700188b2e9..0273e357d98 100644 --- a/source/blender/python/api2_2x/modules.h +++ b/source/blender/python/api2_2x/modules.h @@ -52,7 +52,7 @@ BGL is a special case. It still has data declarations in the .h file and cannot be #included until it is cleaned up. ****************************************************************************/ -PyObject *BGL_Init( void ); +PyObject *BGL_Init( const char *from ); PyObject *Library_Init( void ); PyObject *Noise_Init( void ); -- cgit v1.2.3 From d012a222a21d4a2fb7f8879484755b89f80ecbb2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Apr 2009 19:21:48 +0000 Subject: Some users have odd joysticks with more then 8 axises, increased to 16 (so 4 joysticks) Ideally there would be no limit but I dont think its worth the effort. Also had a bug in last commit for the pytyhon api's "axisSingle" attribute, UI index starts at 1 not zero. --- source/blender/src/buttons_logic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 94790ac0f40..56879f80198 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1495,7 +1495,7 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short else if(joy->type == SENS_JOY_AXIS) { uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, - &joy->axis, 1, 4.0, 100, 0, + &joy->axis, 1, 8.0, 100, 0, "Specify which axis pair to use, 1 is useually the main direction input."); uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20),yco-44, 0.4 * (width-20), 19, @@ -1523,7 +1523,7 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short } else { /* (joy->type == SENS_JOY_AXIS_SINGLE)*/ uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, - &joy->axis_single, 1, 8.0, 100, 0, + &joy->axis_single, 1, 16.0, 100, 0, "Specify a single axis (verticle/horizontal/other) to detect"); uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20),yco-44, 0.4 * (width-20), 19, -- cgit v1.2.3 From 486985762aa71b75ec1d1d0e7bbf0f777065f3a3 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 7 Apr 2009 20:05:32 +0000 Subject: etch-a-ton Use head not tail normal for bone orientation. Simplify roll to normal a bit. --- source/blender/src/editarmature_generate.c | 6 +++--- source/blender/src/editarmature_sketch.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/editarmature_generate.c b/source/blender/src/editarmature_generate.c index ad312f079bd..930ca263499 100644 --- a/source/blender/src/editarmature_generate.c +++ b/source/blender/src/editarmature_generate.c @@ -51,14 +51,14 @@ void setBoneRollFromNormal(EditBone *bone, float *no, float invmat[][4], float t { if (no != NULL && !VecIsNull(no)) { - float tangent[3], cotangent[3], normal[3]; + float tangent[3], vec[3], normal[3]; VECCOPY(normal, no); Mat3MulVecfl(tmat, normal); VecSubf(tangent, bone->tail, bone->head); - Crossf(cotangent, tangent, normal); - Crossf(normal, cotangent, tangent); + Projf(vec, tangent, normal); + VecSubf(normal, normal, vec); Normalize(normal); diff --git a/source/blender/src/editarmature_sketch.c b/source/blender/src/editarmature_sketch.c index 38e44319b47..91aadd07392 100644 --- a/source/blender/src/editarmature_sketch.c +++ b/source/blender/src/editarmature_sketch.c @@ -1011,7 +1011,22 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end) } glEnd(); - + +#if 0 + glColor3f(0, 0, 1); + glBegin(GL_LINES); + + for (i = 0; i < stk->nb_points; i++) + { + float *p = stk->points[i].p; + float *no = stk->points[i].no; + glVertex3fv(p); + glVertex3f(p[0] + no[0], p[1] + no[1], p[2] + no[2]); + } + + glEnd(); +#endif + glColor3f(0, 0, 0); glBegin(GL_POINTS); @@ -1961,7 +1976,7 @@ void sk_convertStroke(SK_Stroke *stk) Mat4MulVecfl(invmat, bone->head); Mat4MulVecfl(invmat, bone->tail); - setBoneRollFromNormal(bone, pt->no, invmat, tmat); + setBoneRollFromNormal(bone, head->no, invmat, tmat); } new_parent = bone; -- cgit v1.2.3 From 51b4145841293d4a695b7bbe88e90ebd98443fc8 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 7 Apr 2009 22:14:06 +0000 Subject: BGE Scenegraph and View frustrum culling improvement. This commit contains a number of performance improvements for the BGE in the Scenegraph (parent relation between objects in the scene) and view frustrum culling. The scenegraph improvement consists in avoiding position update if the object has not moved since last update and the removal of redundant updates and synchronization with the physics engine. The view frustrum culling improvement consists in using the DBVT broadphase facility of Bullet to build a tree of graphical objects in the scene. The elements of the tree are Aabb boxes (Aligned Axis Bounding Boxes) enclosing the objects. This provides good precision in closed and opened scenes. This new culling system is enabled by default but just in case, it can be disabled with a button in the World settings. There is no do_version in this commit but it will be added before the 2.49 release. For now you must manually enable the DBVT culling option in World settings when you open an old file. The above improvements speed up scenegraph and culling up to 5x. However, this performance improvement is only visible when you have hundreds or thousands of objects. The main interest of the DBVT tree is to allow easy occlusion culling and automatic LOD system. This will be the object of further improvements. --- source/blender/blenkernel/intern/world.c | 1 + source/blender/makesdna/DNA_world_types.h | 3 +++ source/blender/src/buttons_shading.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 2e89ce3f805..594d18f1ca7 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -106,6 +106,7 @@ World *add_world(char *name) wrld->ao_approx_error= 0.25f; wrld->physicsEngine= WOPHY_BULLET;//WOPHY_SUMO; Bullet by default + wrld->mode = WO_DBVT_CAMERA_CULLING; // DBVT culling by default wrld->preview = NULL; return wrld; diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index ab7e25190ad..a51e9704be2 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -84,6 +84,8 @@ typedef struct World { * bit 1: Do stars * bit 2: (reserved) depth of field * bit 3: (gameengine): Activity culling is enabled. + * bit 4: ambient occlusion + * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling */ short mode; int physicsEngine; /* here it's aligned */ @@ -133,6 +135,7 @@ typedef struct World { #define WO_DOF 4 #define WO_ACTIVITY_CULLING 8 #define WO_AMB_OCC 16 +#define WO_DBVT_CAMERA_CULLING 32 /* aomix */ #define WO_AOADD 0 diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index fe4649f31f4..e68c86349ce 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2181,7 +2181,7 @@ static void world_panel_mistaph(World *wrld) uiSetButLock(wrld->id.lib!=0, ERROR_LIBDATA_MESSAGE); #if GAMEBLENDER == 1 - uiDefButI(block, MENU, 1, + uiDefButI(block, MENU, B_REDR, #ifdef USE_ODE "Physics %t|None %x0|Sumo %x2|Ode %x4 |Bullet %x5", #else @@ -2198,6 +2198,8 @@ static void world_panel_mistaph(World *wrld) /* Gravitation for the game worlds */ uiDefButF(block, NUMSLI,0, "Grav ", 150,180,150,19, &(wrld->gravity), 0.0, 25.0, 0, 0, "Sets the gravitation constant of the game world"); + if (wrld->physicsEngine == WOPHY_BULLET) + uiDefButBitS(block, TOG, WO_DBVT_CAMERA_CULLING, 0, "DBVT culling", 10,160,140,19, &wrld->mode, 0, 0, 0, 0, "Toggles use of optimized Bullet DBVT tree for camera culling"); #endif uiBlockSetCol(block, TH_BUT_SETTING1); -- cgit v1.2.3 From 2074128fadbfd58ea13a68cbccaa1f6771bbd710 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 8 Apr 2009 15:06:20 +0000 Subject: Patch #18462: Fisheye (Dome) and Spherical Panoramic mode in BGE. User guide: http://wiki.blender.org/index.php/Dev:Source/GameEngine/Fisheye_Dome_Camera Fixed two bugs from original patch: - deleting a text will clear the warp field from Game framing settings - removed spurious black dots along the edge of the cube map in the gameplayer Known limitation: - resizing of the screen doesn't work in the gameplayer Known bugs: - Texture with reflexion are not rendered correctly - Spurious problems with light --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/BKE_scene.h | 2 ++ source/blender/blenkernel/intern/scene.c | 16 ++++++++++++++++ source/blender/blenloader/intern/readfile.c | 26 ++++++++++++++++++++++++-- source/blender/makesdna/DNA_scene_types.h | 9 +++++++++ source/blender/src/buttons_scene.c | 17 +++++++++++++++-- source/blender/src/header_text.c | 1 + 7 files changed, 68 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index db6d4762b17..d49a5425b61 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -41,7 +41,7 @@ struct ListBase; struct MemFile; #define BLENDER_VERSION 248 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 245 #define BLENDER_MINSUBVERSION 15 diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 2bd528ab8c8..2c3ef42c021 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -86,5 +86,7 @@ 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 diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 1727edc10fc..5def3577218 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -230,6 +230,11 @@ Scene *add_scene(char *name) sce->r.threads= 1; sce->r.stereomode = 1; // no stereo + sce->r.domeangle = 180; + sce->r.domemode = 1; + sce->r.domesize = 1.0f; + sce->r.domeres = 4; + sce->r.domeresbuf = 1.0f; sce->r.simplify_subsurf= 6; sce->r.simplify_particles= 1.0f; @@ -775,3 +780,14 @@ 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; + } +} \ No newline at end of file diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c2eaae011c8..06c8370bde2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3531,7 +3531,9 @@ static void lib_link_scene(FileData *fd, Main *main) srl->mat_override= newlibadr_us(fd, sce->id.lib, srl->mat_override); srl->light_override= newlibadr_us(fd, sce->id.lib, srl->light_override); } - + /*Game Settings: Dome Warp Text*/ + sce->r.dometext= newlibadr_us(fd, sce->id.lib, sce->r.dometext); + sce->id.flag -= LIB_NEEDLINK; } @@ -8035,6 +8037,24 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) { + Scene *sce; + World *wrld; + + /* Dome (Fisheye) default parameters */ + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->r.domeangle = 180; + sce->r.domemode = 1; + sce->r.domesize = 1.0f; + sce->r.domeres = 4; + sce->r.domeresbuf = 1.0f; + } + /* DBVT culling by default */ + for(wrld=main->world.first; wrld; wrld= wrld->id.next) { + wrld->mode |= WO_DBVT_CAMERA_CULLING; + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ @@ -8841,7 +8861,9 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) expand_doit(fd, mainvar, srl->mat_override); expand_doit(fd, mainvar, srl->light_override); } - + + if(sce->r.dometext) + expand_doit(fd, mainvar, sce->r.dometext); } static void expand_camera(FileData *fd, Main *mainvar, Camera *ca) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index b8a734b6e94..bf5b2ad3df5 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -45,6 +45,7 @@ struct World; struct Scene; struct Image; struct Group; +struct Text; struct bNodeTree; typedef struct Base { @@ -314,6 +315,14 @@ typedef struct RenderData { /* jpeg2000 */ short jp2_preset, jp2_depth; int rpad3; + + /* Dome variables */ + short domeres, domemode; + short domeangle, pad9; + float domesize; + float domeresbuf; + struct Text *dometext; + } RenderData; /* control render convert and shading engine */ diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index aa072285556..f026e5f4034 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -1766,13 +1766,13 @@ static uiBlock *edge_render_menu(void *arg_unused) static uiBlock *framing_render_menu(void *arg_unused) { uiBlock *block; - short yco = 190, xco = 0; + short yco = 267, xco = 0; int randomcolorindex = 1234; block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSS, UI_HELV, curarea->win); /* use this for a fake extra empy space around the buttons */ - uiDefBut(block, LABEL, 0, "", -5, -10, 295, 224, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "", -5, -10, 295, 300, NULL, 0, 0, 0, 0, ""); uiDefBut(block, LABEL, 0, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); @@ -1814,6 +1814,7 @@ static uiBlock *framing_render_menu(void *arg_unused) * RAS_STEREO_ANAGLYPH 5 * RAS_STEREO_SIDEBYSIDE 6 * RAS_STEREO_VINTERLACE 7 + * RAS_STEREO_DOME 8 */ uiBlockBeginAlign(block); uiDefButS(block, ROW, 0, "No Stereo", xco, yco-=30, 88, 19, &(G.scene->r.stereomode), 7.0, 1.0, 0, 0, "Disables stereo"); @@ -1825,6 +1826,18 @@ static uiBlock *framing_render_menu(void *arg_unused) uiBlockEndAlign(block); + uiBlockBeginAlign(block); + uiDefButS(block, ROW, 0, "Dome", xco-=180, yco-=30, 88, 19, &(G.scene->r.stereomode), 7.0, 8.0, 0, 0, "Enables dome camera"); + uiDefButS(block, NUM, 0, "Ang:", xco+=90, yco, 88, 19, &G.scene->r.domeangle, 90.0, 250.0, 0, 0, "Angle (Aperture) of the Dome - it only works in mode 1"); + uiDefButS(block, NUM, 0, "Mode:", xco+=90, yco, 88, 19, &G.scene->r.domemode, 1.0, 3.0, 0, 0, "Dome mode - 1 fisheye, 2 truncated, 3 spherical panoramic"); + + uiDefButF(block, NUM, 0, "Size:", xco-=180, yco-=21, 88, 19, &G.scene->r.domesize, 0.5, 3.5, 0, 0, "Size adjustments"); + uiDefButS(block, NUM, 0, "Tes:", xco+=90, yco, 88, 19, &G.scene->r.domeres, 1.0, 8.0, 0, 0, "Tesselation level - 1 to 8"); + uiDefButF(block, NUM, 0, "Res:", xco+=90, yco, 88, 19, &G.scene->r.domeresbuf, 0.1, 1.0, 0, 0, "Buffer Resolution - decrease it to increase speed"); + + uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Warp Data: ", xco-180,yco-=21,268, 19, &G.scene->r.dometext, "Custom Warp Mesh data file"); + uiBlockEndAlign(block); + uiBlockSetDirection(block, UI_TOP); return block; diff --git a/source/blender/src/header_text.c b/source/blender/src/header_text.c index 9268642db2f..050ff192df6 100644 --- a/source/blender/src/header_text.c +++ b/source/blender/src/header_text.c @@ -173,6 +173,7 @@ void do_text_buttons(unsigned short event) BPY_clear_bad_scriptlinks(text); BPY_free_pyconstraint_links(text); free_text_controllers(text); + free_dome_warp_text(text); #endif unlink_text(text); free_libblock(&G.main->text, text); -- cgit v1.2.3 From ba4ad93eada475e607831ce17883d04d1575bc32 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 9 Apr 2009 01:52:29 +0000 Subject: Python 2.3 wouldn't compile with BGL. --- source/blender/python/api2_2x/BGL.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c index e5868a82c2c..cfbb4611c6c 100644 --- a/source/blender/python/api2_2x/BGL.c +++ b/source/blender/python/api2_2x/BGL.c @@ -1091,7 +1091,7 @@ PyObject *BGL_Init(const char *from) PyObject *dict= PyModule_GetDict(mod); PyObject *item; if( PyType_Ready( &buffer_Type) < 0) - Py_RETURN_NONE; + return NULL; /* should never happen */ #define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, item=PyInt_FromLong((int)x)); Py_DECREF(item) -- cgit v1.2.3 From eacf5b5d6d406492ba79b44f9319867230585e9b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 9 Apr 2009 09:50:17 +0000 Subject: BGE Text - multi-line strings for bitmap text - keyboard sensor now logs return and pad enter as "\n" BGE std::vector use in Value.cpp and RAS_MaterialBucket.cpp The size of a new list is known before making them, reduce re-allocs, though probably not a noticeable speedup. --- source/blender/gpu/intern/gpu_draw.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/blender') diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 3c1c280a727..c0033c89d5c 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -84,6 +84,15 @@ void GPU_render_text(MTFace *tface, int mode, int characters, index, character; float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance; + /* multiline */ + float line_start= 0.0f, line_height; + if (v4) + line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - MIN4(v1[1], v2[1], v3[1], v4[2]); + else + line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], v2[1], v3[1]); + line_height *= 1.2; /* could be an option? */ + /* end multiline */ + characters = textlen; ima = (Image*)tface->tpage; @@ -97,12 +106,19 @@ void GPU_render_text(MTFace *tface, int mode, glColor3f(1.0f, 1.0f, 1.0f); glPushMatrix(); + for (index = 0; index < characters; index++) { float uv[4][2]; // lets calculate offset stuff character = textstr[index]; + if (character=='\n') { + glTranslatef(line_start, -line_height, 0.0); + line_start = 0.0f; + continue; + } + // space starts at offset 1 // character = character - ' ' + 1; matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, ¢ery, @@ -143,6 +159,7 @@ void GPU_render_text(MTFace *tface, int mode, glEnd(); glTranslatef(advance, 0.0, 0.0); + line_start -= advance; /* so we can go back to the start of the line */ } glPopMatrix(); } -- cgit v1.2.3 From c29d51f1e877f9e486aff9abb530418419ce79d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 9 Apr 2009 10:05:17 +0000 Subject: BGE Text - fix for tab drawing as an @ and not adding white space. Tab width is always space*4. --- source/blender/gpu/intern/gpu_draw.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index c0033c89d5c..7b1fc67d0c6 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -83,7 +83,9 @@ void GPU_render_text(MTFace *tface, int mode, Image* ima; int characters, index, character; float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance; - + float advance_tab; + + /* multiline */ float line_start= 0.0f, line_height; if (v4) @@ -107,6 +109,13 @@ void GPU_render_text(MTFace *tface, int mode, glPushMatrix(); + /* get the tab width */ + matrixGlyph((ImBuf *)ima->ibufs.first, ' ', & centerx, ¢ery, + &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); + + advance_tab= advance * 4; /* tab width could also be an option */ + + for (index = 0; index < characters; index++) { float uv[4][2]; @@ -118,6 +127,12 @@ void GPU_render_text(MTFace *tface, int mode, line_start = 0.0f; continue; } + else if (character=='\t') { + glTranslatef(advance_tab, 0.0, 0.0); + line_start -= advance_tab; /* so we can go back to the start of the line */ + continue; + + } // space starts at offset 1 // character = character - ' ' + 1; -- cgit v1.2.3 From 6121d4b9fe188919c3c7f971a66c421d7eb86478 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 9 Apr 2009 23:43:25 +0000 Subject: Particle effector falloff maxdist etc. didn't work like it was supposed to. --- source/blender/blenkernel/intern/effect.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index a6514ae7b87..cca5d68167e 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -298,24 +298,22 @@ static float wind_func(struct RNG *rng, float strength) return ret; } - +/* maxdist: zero effect from this distance outwards (if usemax) */ +/* mindist: full effect up to this distance (if usemin) */ +/* power: falloff with formula 1/r^power */ static float falloff_func(float fac, int usemin, float mindist, int usemax, float maxdist, float power) { - if(!usemin) - mindist= 0.0f; + /* first quick checks */ + if(usemax && fac > maxdist) + return 0.0f; - if(fac < mindist) { + if(usemin && fac < mindist) return 1.0f; - } - else if(usemax) { - if(fac>maxdist || (maxdist-mindist)<=0.0f) - return 0.0f; - fac= (fac-mindist)/(maxdist-mindist); - return 1.0f - (float)pow((double)fac, (double)power); - } - else - return pow((double)1.0f+fac-mindist, (double)-power); + if(!usemin) + mindist = 0.0; + + return pow((double)1.0+fac-mindist, (double)-power); } static float falloff_func_dist(PartDeflect *pd, float fac) -- cgit v1.2.3 From c1cf50be7947cf46c7675cd867b7121b56eae0e3 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 10 Apr 2009 19:40:21 +0000 Subject: Mesh effector surface option: - Most mesh particle effectors can now have their effection point taken per particle as the nearest point on the mesh surface. - This is activated with the "surface" button in the effector field panel. - Activating the option adds a "surface" entry to the modifier stack where the state of the mesh is read from. For an example of usage see http://www.youtube.com/watch?v=3XkO1EAmJks. --- source/blender/blenkernel/intern/modifier.c | 84 ++++++++++++++++++++++ source/blender/blenkernel/intern/particle_system.c | 33 ++++++++- source/blender/blenloader/intern/readfile.c | 6 ++ source/blender/makesdna/DNA_modifier_types.h | 9 +++ source/blender/makesdna/DNA_object_force.h | 1 + source/blender/src/buttons_editing.c | 12 ++-- source/blender/src/buttons_object.c | 43 ++++++++++- 7 files changed, 178 insertions(+), 10 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index d182e3124fc..1068950d0d6 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6016,6 +6016,82 @@ static void collisionModifier_deformVerts( } + +/* Surface */ + +static void surfaceModifier_initData(ModifierData *md) +{ + SurfaceModifierData *surmd = (SurfaceModifierData*) md; + + surmd->bvhtree = NULL; +} + +static void surfaceModifier_freeData(ModifierData *md) +{ + SurfaceModifierData *surmd = (SurfaceModifierData*) md; + + if (surmd) + { + if(surmd->bvhtree) { + free_bvhtree_from_mesh(surmd->bvhtree); + MEM_freeN(surmd->bvhtree); + } + + surmd->dm->release(surmd->dm); + + surmd->bvhtree = NULL; + surmd->dm = NULL; + } +} + +static int surfaceModifier_dependsOnTime(ModifierData *md) +{ + return 1; +} + +static void surfaceModifier_deformVerts( + ModifierData *md, Object *ob, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts) +{ + SurfaceModifierData *surmd = (SurfaceModifierData*) md; + DerivedMesh *dm = NULL; + float current_time = 0; + unsigned int numverts = 0, i = 0; + + if(surmd->dm) + surmd->dm->release(surmd->dm); + + /* if possible use/create DerivedMesh */ + if(derivedData) surmd->dm = CDDM_copy(derivedData); + else if(ob->type==OB_MESH) surmd->dm = CDDM_from_mesh(ob->data, ob); + + if(!ob->pd) + { + printf("surfaceModifier_deformVerts: Should not happen!\n"); + return; + } + + if(surmd->dm) + { + CDDM_apply_vert_coords(surmd->dm, vertexCos); + CDDM_calc_normals(surmd->dm); + + numverts = surmd->dm->getNumVerts ( surmd->dm ); + + /* convert to global coordinates */ + for(i = 0; iobmat, CDDM_get_vert(surmd->dm, i)->co); + + if(surmd->bvhtree) + free_bvhtree_from_mesh(surmd->bvhtree); + else + surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); + + bvhtree_from_mesh_faces(surmd->bvhtree, surmd->dm, 0.0, 2, 6); + } +} + + /* Boolean */ static void booleanModifier_copyData(ModifierData *md, ModifierData *target) @@ -8217,6 +8293,14 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->deformVerts = collisionModifier_deformVerts; // mti->copyData = collisionModifier_copyData; + mti = INIT_TYPE(Surface); + mti->type = eModifierTypeType_OnlyDeform; + mti->initData = surfaceModifier_initData; + mti->flags = eModifierTypeFlag_AcceptsMesh; + mti->dependsOnTime = surfaceModifier_dependsOnTime; + mti->freeData = surfaceModifier_freeData; + mti->deformVerts = surfaceModifier_deformVerts; + mti = INIT_TYPE(Boolean); mti->type = eModifierTypeType_Nonconstructive; mti->flags = eModifierTypeFlag_AcceptsMesh diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 0ffdd11c37a..bbf62d033bf 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -77,6 +77,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_scene.h" +#include "BKE_bvhutils.h" #include "PIL_time.h" @@ -2447,7 +2448,6 @@ void psys_end_effectors(ParticleSystem *psys) if(ec->rng) rng_free(ec->rng); - } BLI_freelistN(lb); @@ -2544,6 +2544,7 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P ParticleData *epa; ParticleKey estate; PartDeflect *pd; + SurfaceModifierData *surmd = NULL; ListBase *lb=&psys->effectors; ParticleEffectorCache *ec; float distance, vec_to_part[3]; @@ -2571,8 +2572,34 @@ void do_effectors(int pa_no, ParticleData *pa, ParticleKey *state, Object *ob, P if(psys->part->type!=PART_HAIR && psys->part->integrator) where_is_object_time(eob,cfra); - /* use center of object for distance calculus */ - VecSubf(vec_to_part, state->co, eob->obmat[3]); + if(pd && pd->flag&PFIELD_SURFACE) { + surmd = (SurfaceModifierData *)modifiers_findByType ( eob, eModifierType_Surface ); + } + if(surmd) { + /* closest point in the object surface is an effector */ + BVHTreeNearest nearest; + float velocity[3]; + + nearest.index = -1; + nearest.dist = FLT_MAX; + + /* using velocity corrected location allows for easier sliding over effector surface */ + VecCopyf(velocity, state->vel); + VecMulf(velocity, psys_get_timestep(psys->part)); + VecAddf(vec_to_part, state->co, velocity); + + BLI_bvhtree_find_nearest(surmd->bvhtree->tree, vec_to_part, &nearest, surmd->bvhtree->nearest_callback, surmd->bvhtree); + + if(nearest.index != -1) { + VecSubf(vec_to_part, state->co, nearest.co); + } + else + vec_to_part[0] = vec_to_part[1] = vec_to_part[2] = 0.0f; + } + else + /* use center of object for distance calculus */ + VecSubf(vec_to_part, state->co, eob->obmat[3]); + distance = VecLength(vec_to_part); falloff=effector_falloff(pd,eob->obmat[2],vec_to_part); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 06c8370bde2..63dd1e8e6cb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3207,6 +3207,12 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) collmd->mfaces = NULL; } + else if (md->type==eModifierType_Surface) { + SurfaceModifierData *surmd = (SurfaceModifierData*) md; + + surmd->dm = NULL; + surmd->bvhtree = NULL; + } else if (md->type==eModifierType_Hook) { HookModifierData *hmd = (HookModifierData*) md; diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index ae07434a37f..077481dfa6e 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -39,6 +39,7 @@ typedef enum ModifierType { eModifierType_Fluidsim, eModifierType_Mask, eModifierType_SimpleDeform, + eModifierType_Surface, NUM_MODIFIER_TYPES } ModifierType; @@ -418,6 +419,14 @@ typedef struct CollisionModifierData { struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth object */ } CollisionModifierData; +typedef struct SurfaceModifierData { + ModifierData modifier; + + struct DerivedMesh *dm; + + struct BVHTreeFromMesh *bvhtree; /* bounding volume hierarchy of the mesh faces */ +} SurfaceModifierData; + typedef enum { eBooleanModifierOp_Intersect, eBooleanModifierOp_Union, diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 21c5242a703..49435000820 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -225,6 +225,7 @@ typedef struct SoftBody { #define PFIELD_USEMAXR 512 #define PFIELD_USEMINR 1024 #define PFIELD_TEX_ROOTCO 2048 +#define PFIELD_SURFACE 4096 /* pd->falloff */ #define PFIELD_FALL_SPHERE 0 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 8b249815b6f..2ec30bfa864 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1031,7 +1031,7 @@ static uiBlock *modifiers_add_menu(void *ob_v) /* Only allow adding through appropriate other interfaces */ if(ELEM3(i, eModifierType_Softbody, eModifierType_Hook, eModifierType_ParticleSystem)) continue; - if(ELEM3(i, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim)) continue; + if(ELEM4(i, eModifierType_Cloth, eModifierType_Collision, eModifierType_Surface, eModifierType_Fluidsim)) continue; if((mti->flags&eModifierTypeFlag_AcceptsCVs) || (ob->type==OB_MESH && (mti->flags&eModifierTypeFlag_AcceptsMesh))) { @@ -1771,7 +1771,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiDefBut(block, TEX, B_MODIFIER_REDRAW, "", x+10, y-1, buttonWidth-60, 19, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); /* Softbody not allowed in this situation, enforce! */ - if ((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) { + if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) { uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering"); but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, VICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display"); if (mti->flags&eModifierTypeFlag_SupportsEditmode) { @@ -1813,7 +1813,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco // deletion over the deflection panel // fluid particle modifier can't be deleted here - if(md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Collision && !modifier_is_fluid_particles(md)) + if(md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Collision && md->type!=eModifierType_Surface && !modifier_is_fluid_particles(md)) { but = uiDefIconBut(block, BUT, B_MODIFIER_RECALC, VICON_X, x+width-70+40, y, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier"); uiButSetFunc(but, modifiers_del, ob, md); @@ -1884,6 +1884,8 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco height = 31; } else if (md->type==eModifierType_Collision) { height = 31; + } else if (md->type==eModifierType_Surface) { + height = 31; } else if (md->type==eModifierType_Fluidsim) { height = 31; } else if (md->type==eModifierType_Boolean) { @@ -1924,7 +1926,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco y -= 18; - if (!isVirtual && (md->type!=eModifierType_Collision)) { + if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) { uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */ uiBlockBeginAlign(block); @@ -2369,6 +2371,8 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco } else if (md->type==eModifierType_Collision) { uiDefBut(block, LABEL, 1, "See Collision panel.", lx, (cy-=19), buttonWidth,19, NULL, 0.0, 0.0, 0, 0, ""); + } else if (md->type==eModifierType_Surface) { + uiDefBut(block, LABEL, 1, "See Fields panel.", lx, (cy-=19), buttonWidth,19, NULL, 0.0, 0.0, 0, 0, ""); } else if (md->type==eModifierType_Fluidsim) { uiDefBut(block, LABEL, 1, "See Fluidsim panel.", lx, (cy-=19), buttonWidth,19, NULL, 0.0, 0.0, 0, 0, ""); } else if (md->type==eModifierType_Boolean) { diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 5c41390b150..7fc504ba8d3 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3340,6 +3340,35 @@ static void object_panel_collision(Object *ob) } } } +static void object_surface__enabletoggle ( void *ob_v, void *arg2 ) +{ + Object *ob = ob_v; + PartDeflect *pd= ob->pd; + ModifierData *md = modifiers_findByType ( ob, eModifierType_Surface ); + + if(!md) + { + if(pd && (pd->flag & PFIELD_SURFACE) + && ELEM5(pd->forcefield,PFIELD_HARMONIC,PFIELD_FORCE,PFIELD_HARMONIC,PFIELD_CHARGE,PFIELD_LENNARDJ)) + { + md = modifier_new ( eModifierType_Surface ); + BLI_addtail ( &ob->modifiers, md ); + DAG_scene_sort(G.scene); + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWVIEW3D, 0); + } + } + else if(!pd || !(pd->flag & PFIELD_SURFACE) + || ELEM5(pd->forcefield,PFIELD_HARMONIC,PFIELD_FORCE,PFIELD_HARMONIC,PFIELD_CHARGE,PFIELD_LENNARDJ)) + { + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + BLI_remlink ( &ob->modifiers, md ); + modifier_free ( md ); + DAG_scene_sort(G.scene); + allqueue(REDRAWBUTSEDIT, 0); + } +} static void object_panel_fields(Object *ob) { uiBlock *block; @@ -3425,9 +3454,12 @@ static void object_panel_fields(Object *ob) } if(ob->particlesystem.first) - uiDefButS(block, MENU, B_FIELD_DEP, menustr, 80,180,70,20, &pd->forcefield, 0.0, 0.0, 0, 0, tipstr); + but = uiDefButS(block, MENU, B_FIELD_DEP, menustr, 80,180,70,20, &pd->forcefield, 0.0, 0.0, 0, 0, tipstr); else - uiDefButS(block, MENU, B_FIELD_DEP, menustr, 10,180,140,20, &pd->forcefield, 0.0, 0.0, 0, 0, tipstr); + but = uiDefButS(block, MENU, B_FIELD_DEP, menustr, 10,180,140,20, &pd->forcefield, 0.0, 0.0, 0, 0, tipstr); + + if(!particles) + uiButSetFunc(but, object_surface__enabletoggle, ob, NULL); uiBlockEndAlign(block); uiDefBut(block, LABEL, 0, "",160,180,150,2, NULL, 0.0, 0, 0, 0, ""); @@ -3472,7 +3504,12 @@ static void object_panel_fields(Object *ob) } else if(particles==0 && ELEM(pd->forcefield,PFIELD_VORTEX,PFIELD_WIND)==0){ //uiDefButF(block, NUM, B_FIELD_CHANGE, "Distance: ", 10,20,140,20, &pd->f_dist, 0, 1000.0, 10, 0, "Falloff power (real gravitational fallof = 2)"); - uiDefButBitS(block, TOG, PFIELD_PLANAR, B_FIELD_CHANGE, "Planar", 10,15,140,20, &pd->flag, 0.0, 0, 0, 0, "Create planar field"); + uiDefButBitS(block, TOG, PFIELD_PLANAR, B_FIELD_CHANGE, "Planar", 10,35,140,20, &pd->flag, 0.0, 0, 0, 0, "Create planar field"); + } + + if(particles==0 && ELEM5(pd->forcefield,PFIELD_HARMONIC,PFIELD_FORCE,PFIELD_HARMONIC,PFIELD_CHARGE,PFIELD_LENNARDJ)) { + but = uiDefButBitS(block, TOG, PFIELD_SURFACE, B_FIELD_CHANGE, "Surface", 10,15,140,20, &pd->flag, 0.0, 0, 0, 0, "Use closest point on surface"); + uiButSetFunc(but, object_surface__enabletoggle, ob, NULL); } uiBlockEndAlign(block); -- cgit v1.2.3 From 48514b3d52dd642a2e759dca635ff69505a7f767 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 10 Apr 2009 21:07:32 +0000 Subject: Fix for: [#18499] Particle size can only be set in steps of 0.1 - Some button settings were wrong. --- source/blender/src/buttons_object.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 7fc504ba8d3..7161bc8c266 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -4428,11 +4428,11 @@ static void object_panel_particle_extra(Object *ob) buty-=buth; /* size changes must create a recalc event always so that sizes are updated properly */ - uiDefButF(block, NUM, B_PART_RECALC, "Size:", butx,(buty-=buth),butw,buth, &part->size, 0.01, 100, 10, 1, "The size of the particles"); - uiDefButF(block, NUM, B_PART_RECALC, "Rand:", butx,(buty-=buth),butw,buth, &part->randsize, 0.0, 1.0, 10, 1, "Give the particle size a random variation"); + uiDefButF(block, NUM, B_PART_RECALC, "Size:", butx,(buty-=buth),butw,buth, &part->size, 0.001, 100, 10, 0, "The size of the particles"); + uiDefButF(block, NUM, B_PART_RECALC, "Rand:", butx,(buty-=buth),butw,buth, &part->randsize, 0.0, 1.0, 10, 0, "Give the particle size a random variation"); uiDefButBitI(block, TOG, PART_SIZEMASS, B_PART_RECALC, "Mass from size", butx,(buty-=buth),butw,buth, &part->flag, 0, 0, 0, 0, "Multiply mass with particle size"); - uiDefButF(block, NUM, B_PART_RECALC, "Mass:", butx,(buty-=buth),butw,buth, &part->mass, 0.01, 100, 10, 1, "Specify the mass of the particles"); + uiDefButF(block, NUM, B_PART_RECALC, "Mass:", butx,(buty-=buth),butw,buth, &part->mass, 0.001, 100, 10, 0, "Specify the mass of the particles"); } /* copy from buttons_shading.c */ static void autocomplete_uv(char *str, void *arg_v) @@ -4936,8 +4936,8 @@ static void object_panel_particle_system(Object *ob) } if(part->type!=PART_HAIR) { - uiDefButF(block, NUM, B_PART_INIT, "Life:", butx,(buty-=buth),butw,buth, &part->lifetime, 1.0, MAXFRAMEF, 100, 1, "Specify the life span of the particles"); - uiDefButF(block, NUM, B_PART_INIT, "Rand:", butx,(buty-=buth),butw,buth, &part->randlife, 0.0, 1.0, 10, 1, "Give the particle life a random variation"); + uiDefButF(block, NUM, B_PART_INIT, "Life:", butx,(buty-=buth),butw,buth, &part->lifetime, 1.0, MAXFRAMEF, 100, 0, "Specify the life span of the particles"); + uiDefButF(block, NUM, B_PART_INIT, "Rand:", butx,(buty-=buth),butw,buth, &part->randlife, 0.0, 1.0, 10, 0, "Give the particle life a random variation"); } uiBlockEndAlign(block); -- cgit v1.2.3 From 55d2b184ec1b2c1adfe182ead937cedae1a8208d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 07:24:04 +0000 Subject: added "toggle" an option for the property actuator. much less hassle then setting up a property sensor and 2 assignment actuators, or through python. --- source/blender/makesdna/DNA_actuator_types.h | 1 + source/blender/src/buttons_logic.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 48432b8c6e2..2252126b46c 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -357,6 +357,7 @@ typedef struct FreeCamera { #define ACT_PROP_ASSIGN 0 #define ACT_PROP_ADD 1 #define ACT_PROP_COPY 2 +#define ACT_PROP_TOGGLE 3 /* constraint flag */ #define ACT_CONST_LOCX 1 diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 56879f80198..1f604aa8480 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1970,12 +1970,17 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh pa= act->data; - str= "Type %t|Assign %x0|Add %x1|Copy %x2"; + str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle%x3"; uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); - if(pa->type==ACT_PROP_COPY) { + + if(pa->type==ACT_PROP_TOGGLE) { + /* no ui */ + ysize -= 22; + } + else if(pa->type==ACT_PROP_COPY) { uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property"); } -- cgit v1.2.3 From 17f35293ee9d83605db7d73e7213d206d507a587 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 16:10:43 +0000 Subject: PropertyActuator toggle option didnt run when the Value field was empty. --- source/blender/src/buttons_logic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 1f604aa8480..97f07c7553c 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1970,7 +1970,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh pa= act->data; - str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle%x3"; + str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3"; uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); -- cgit v1.2.3 From 5b942b9d5b4e45de872ecceff8ccccfe2c94bbef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 17:07:40 +0000 Subject: [#18516] Particle children API for python (Complete). from Alberto Santos (dnakhain) ---- This patch complete previous one that I submit with new variables relationated with Particle System children (With variables related to Rough, Kink and Branch). --- source/blender/python/api2_2x/Particle.c | 505 ++++++++++++++++++++++---- source/blender/python/api2_2x/doc/Particle.py | 32 ++ 2 files changed, 475 insertions(+), 62 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/Particle.c b/source/blender/python/api2_2x/Particle.c index c3f2e0f89c0..a7db8290c62 100644 --- a/source/blender/python/api2_2x/Particle.c +++ b/source/blender/python/api2_2x/Particle.c @@ -152,6 +152,38 @@ static int Part_setChildSize( BPy_PartSys * self, PyObject * args ); static PyObject *Part_getChildSize( BPy_PartSys * self ); static int Part_setChildRandom( BPy_PartSys * self, PyObject * args ); static PyObject *Part_getChildRandom( BPy_PartSys * self ); +static int Part_setChildRough1( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRough1( BPy_PartSys * self ); +static int Part_setChildRough1Size( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRough1Size( BPy_PartSys * self ); +static int Part_setChildRough2( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRough2( BPy_PartSys * self ); +static int Part_setChildRough2Size( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRough2Size( BPy_PartSys * self ); +static int Part_setChildRough2Thres( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRough2Thres( BPy_PartSys * self ); +static int Part_setChildRoughE( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRoughE( BPy_PartSys * self ); +static int Part_setChildRoughEShape( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildRoughEShape( BPy_PartSys * self ); +static int Part_setChildKink( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildKink( BPy_PartSys * self ); +static int Part_setChildKinkAxis( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildKinkAxis( BPy_PartSys * self ); +static int Part_setChildKinkFreq( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildKinkFreq( BPy_PartSys * self ); +static int Part_setChildKinkShape( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildKinkShape( BPy_PartSys * self ); +static int Part_setChildKinkAmp( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildKinkAmp( BPy_PartSys * self ); +static int Part_setChildBranch( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildBranch( BPy_PartSys * self ); +static int Part_setChildBranchAnim( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildBranchAnim( BPy_PartSys * self ); +static int Part_setChildBranchSymm( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildBranchSymm( BPy_PartSys * self ); +static int Part_setChildBranchThre( BPy_PartSys * self, PyObject * args ); +static PyObject *Part_getChildBranchThre( BPy_PartSys * self ); /*****************************************************************************/ /* Python Effect_Type callback function prototypes: */ @@ -371,6 +403,70 @@ static PyGetSetDef BPy_ParticleSys_getseters[] = { (getter)Part_getChildRandom, (setter)Part_setChildRandom, "Random variation to the size of the child particles", NULL}, + {"childRough1", + (getter)Part_getChildRough1, (setter)Part_setChildRough1, + "Amount of location dependant rough", + NULL}, + {"childRough1Size", + (getter)Part_getChildRough1Size, (setter)Part_setChildRough1Size, + "Size of location dependant rough", + NULL}, + {"childRough2", + (getter)Part_getChildRough2, (setter)Part_setChildRough2, + "Amount of random rough", + NULL}, + {"childRough2Size", + (getter)Part_getChildRough2Size, (setter)Part_setChildRough2Size, + "Size of random rough", + NULL}, + {"childRough2Thresh", + (getter)Part_getChildRough2Thres, (setter)Part_setChildRough2Thres, + "Amount of particles left untouched by random rough", + NULL}, + {"childRoughE", + (getter)Part_getChildRoughE, (setter)Part_setChildRoughE, + "Amount of end point rough", + NULL}, + {"childRoughEShape", + (getter)Part_getChildRoughEShape, (setter)Part_setChildRoughEShape, + "Shape of end point rough", + NULL}, + {"childKink", + (getter)Part_getChildKink, (setter)Part_setChildKink, + "Type of periodic offset on the path (Particle.CHILDKINK[ 'BRAID' | 'WAVE' | 'RADIAL' | 'CURL' | 'NOTHING' ])", + NULL}, + {"childKinkAxis", + (getter)Part_getChildKinkAxis, (setter)Part_setChildKinkAxis, + "Which axis to use for offset (Particle.CHILDKINKAXIS[ 'Z' | 'Y' | 'X' ])", + NULL}, + {"childKinkFreq", + (getter)Part_getChildKinkFreq, (setter)Part_setChildKinkFreq, + "The frequency of the offset (1/total length)", + NULL}, + {"childKinkShape", + (getter)Part_getChildKinkShape, (setter)Part_setChildKinkShape, + "Adjust the offset to the beginning/end", + NULL}, + {"childKinkAmp", + (getter)Part_getChildKinkAmp, (setter)Part_setChildKinkAmp, + "The amplitude of the offset", + NULL}, + {"childBranch", + (getter)Part_getChildBranch, (setter)Part_setChildBranch, + "Branch child paths from eachother", + NULL}, + {"childBranchAnim", + (getter)Part_getChildBranchAnim, (setter)Part_setChildBranchAnim, + "Animate branching", + NULL}, + {"childBranchSymm", + (getter)Part_getChildBranchSymm, (setter)Part_setChildBranchSymm, + "Start and end points are the same", + NULL}, + {"childBranchThre", + (getter)Part_getChildBranchThre, (setter)Part_setChildBranchThre, + "Threshold of branching", + NULL}, {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ }; @@ -614,10 +710,8 @@ PyObject *M_ParticleSys_Get( PyObject * self, PyObject * args ) } if( !wanted_obj){ /* requested object not found */ - char error_msg[64]; - PyOS_snprintf( error_msg, sizeof( error_msg ), - "Particle System '%s' not found", name); - return EXPP_ReturnPyObjError( PyExc_NameError, error_msg ); + PyErr_Format(PyExc_NameError, "Particle System '%s' not found", name); + return NULL; } return wanted_obj; @@ -785,6 +879,48 @@ static PyObject *Particle_ChildTypeDict( void ) return ChildTypes; } +/* create the Blender.Particle.ChildKink constant dict */ + +static PyObject *Particle_ChildKinkDict( void ) +{ + PyObject *ChildKinks = PyConstant_New( ); + + if( ChildKinks ) { + BPy_constant *c = ( BPy_constant * ) ChildKinks; + + PyConstant_Insert( c, "BRAID", + PyInt_FromLong( 4 ) ); + PyConstant_Insert( c, "WAVE", + PyInt_FromLong( 3 ) ); + PyConstant_Insert( c, "RADIAL", + PyInt_FromLong( 2 ) ); + PyConstant_Insert( c, "CURL", + PyInt_FromLong( 1 ) ); + PyConstant_Insert( c, "NOTHING", + PyInt_FromLong( 0 ) ); + } + return ChildKinks; +} + +/* create the Blender.Particle.ChildKinkAxis constant dict */ + +static PyObject *Particle_ChildKinkAxisDict( void ) +{ + PyObject *ChildKinkAxes = PyConstant_New( ); + + if( ChildKinkAxes ) { + BPy_constant *c = ( BPy_constant * ) ChildKinkAxes; + + PyConstant_Insert( c, "Z", + PyInt_FromLong( 2 ) ); + PyConstant_Insert( c, "Y", + PyInt_FromLong( 1 ) ); + PyConstant_Insert( c, "X", + PyInt_FromLong( 0 ) ); + } + return ChildKinkAxes; +} + static PyObject *Particle_DrawAs( void ) { PyObject *DrawAs = PyConstant_New( ); @@ -832,6 +968,8 @@ PyObject *ParticleSys_Init( void ){ PyObject *Dist; PyObject *DrawAs; PyObject *ChildTypes; + PyObject *ChildKinks; + PyObject *ChildKinkAxes; if( PyType_Ready( &ParticleSys_Type ) < 0) @@ -843,6 +981,8 @@ PyObject *ParticleSys_Init( void ){ DrawAs = Particle_DrawAs(); Dist = Particle_DistrDict(); ChildTypes = Particle_ChildTypeDict(); + ChildKinks = Particle_ChildKinkDict(); + ChildKinkAxes = Particle_ChildKinkAxisDict(); submodule = Py_InitModule3( "Blender.Particle", M_ParticleSys_methods, M_ParticleSys_doc ); @@ -859,6 +999,10 @@ PyObject *ParticleSys_Init( void ){ PyModule_AddObject( submodule, "DRAWAS", DrawAs ); if( ChildTypes ) PyModule_AddObject( submodule, "CHILDTYPE", ChildTypes ); + if( ChildKinks ) + PyModule_AddObject( submodule, "CHILDKINK", ChildKinks ); + if( ChildKinkAxes ) + PyModule_AddObject( submodule, "CHILDKINKAXIS", ChildKinkAxes ); return ( submodule ); } @@ -1488,11 +1632,8 @@ static int Part_setEditable( BPy_PartSys * self, PyObject * args ) { int number; - if( !PyInt_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); @@ -1539,11 +1680,8 @@ static int Part_setMultiReact( BPy_PartSys * self, PyObject * args ) { int number; - if( !PyInt_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); @@ -1727,11 +1865,8 @@ static PyObject *Part_getGroundZ( BPy_PartSys * self ) static int Part_setOb( BPy_PartSys * self, PyObject * args ) { Object *obj; - if( !BPy_Object_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected object argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !BPy_Object_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected object argument" ); obj = Object_FromPyObject(args); @@ -1754,11 +1889,8 @@ static int Part_setRandEmission( BPy_PartSys * self, PyObject * args ) { int number; - if( !PyInt_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); @@ -1781,19 +1913,14 @@ static PyObject *Part_getRandEmission( BPy_PartSys * self ) static int Part_setParticleDist( BPy_PartSys * self, PyObject * args ) { int number; - char errstr[128]; - if( !PyInt_Check( args ) ) { - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); - if (number < 0 || number > 3){ - sprintf ( errstr, "expected int argument between 0 - 3" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if (number < 0 || number > 3) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument between 0 - 3" ); self->psys->part->from = (short)number; @@ -1811,11 +1938,8 @@ static int Part_setEvenDist( BPy_PartSys * self, PyObject * args ) { int number; - if( !PyInt_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); @@ -1838,19 +1962,14 @@ static PyObject *Part_getEvenDist( BPy_PartSys * self ) static int Part_setDist( BPy_PartSys * self, PyObject * args ) { int number; - char errstr[128]; - if( !PyInt_Check( args ) ) { - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); - if (number < 0 || number > 2){ - sprintf ( errstr, "expected int argument between 0 - 2" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if (number < 0 || number > 2) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument between 0 - 2" ); self->psys->part->distr = (short)number; @@ -1900,11 +2019,8 @@ static int Part_setInvert( BPy_PartSys * self, PyObject * args ) { int number; - if( !PyInt_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); @@ -1927,11 +2043,9 @@ static PyObject *Part_getInvert( BPy_PartSys * self ) static int Part_setTargetOb( BPy_PartSys * self, PyObject * args ) { Object *obj; - if( !BPy_Object_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected object argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + + if( !BPy_Object_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected object argument" ); obj = Object_FromPyObject(args); @@ -2005,11 +2119,8 @@ static int Part_setRenderObject( BPy_PartSys * self, PyObject * args ) int number,nr; ParticleSystem *psys = 0L; - if( !PyInt_Check( args ) ) { - char errstr[128]; - sprintf ( errstr, "expected int argument" ); - return EXPP_ReturnIntError( PyExc_TypeError, errstr ); - } + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); number = PyInt_AS_LONG( args ); @@ -2225,3 +2336,273 @@ static PyObject *Part_getChildRandom( BPy_PartSys * self ) { return PyFloat_FromDouble( ((float)( self->psys->part->childrandsize )) ); } + +static int Part_setChildRough1( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->rough1, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRough1( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->rough1 )) ); +} + +static int Part_setChildRough1Size( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->rough1_size, + 0.01, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRough1Size( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->rough1_size )) ); +} + +static int Part_setChildRough2( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->rough2, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRough2( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->rough2 )) ); +} + +static int Part_setChildRough2Size( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->rough2_size, + 0.01, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRough2Size( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->rough2_size )) ); +} + +static int Part_setChildRough2Thres( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->rough2_thres, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRough2Thres( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->rough2_thres )) ); +} + +static int Part_setChildRoughE( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->rough_end, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRoughE( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->rough_end )) ); +} + +static int Part_setChildRoughEShape( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->rough_end_shape, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildRoughEShape( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->rough_end_shape )) ); +} + +static int Part_setChildKink( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setIValueRange( args, &self->psys->part->kink, + 0, 4, 'h' ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildKink( BPy_PartSys * self ) +{ + return PyInt_FromLong( (short)( self->psys->part->kink ) ); +} + +static int Part_setChildKinkAxis( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setIValueRange( args, &self->psys->part->kink_axis, + 0, 2, 'h' ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildKinkAxis( BPy_PartSys * self ) +{ + return PyInt_FromLong( (short)( self->psys->part->kink_axis ) ); +} + +static int Part_setChildKinkFreq( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->kink_freq, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildKinkFreq( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->kink_freq )) ); +} + +static int Part_setChildKinkShape( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->kink_shape, + -0.999, 0.999 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildKinkShape( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->kink_shape )) ); +} + +static int Part_setChildKinkAmp( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->kink_amp, + 0.0, 10.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildKinkAmp( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->kink_amp )) ); +} + +static int Part_setChildBranch( BPy_PartSys * self, PyObject * args ) +{ + int number; + + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); + + number = PyInt_AS_LONG( args ); + + if (number){ + self->psys->part->flag |= PART_BRANCHING; + }else{ + self->psys->part->flag &= ~PART_BRANCHING; + } + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return 0; +} + +static PyObject *Part_getChildBranch( BPy_PartSys * self ) +{ + return PyInt_FromLong( ((long)( self->psys->part->flag & PART_BRANCHING )) > 0 ); +} + +static int Part_setChildBranchAnim( BPy_PartSys * self, PyObject * args ) +{ + int number; + + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); + + number = PyInt_AS_LONG( args ); + + if (number){ + self->psys->part->flag |= PART_ANIM_BRANCHING; + }else{ + self->psys->part->flag &= ~PART_ANIM_BRANCHING; + } + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return 0; +} + +static PyObject *Part_getChildBranchAnim( BPy_PartSys * self ) +{ + return PyInt_FromLong( ((long)( self->psys->part->flag & PART_ANIM_BRANCHING )) > 0 ); +} + +static int Part_setChildBranchSymm( BPy_PartSys * self, PyObject * args ) +{ + int number; + + if( !PyInt_Check( args ) ) + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); + + number = PyInt_AS_LONG( args ); + + if (number){ + self->psys->part->flag |= PART_SYMM_BRANCHING; + }else{ + self->psys->part->flag &= ~PART_SYMM_BRANCHING; + } + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return 0; +} + +static PyObject *Part_getChildBranchSymm( BPy_PartSys * self ) +{ + return PyInt_FromLong( ((long)( self->psys->part->flag & PART_SYMM_BRANCHING )) > 0 ); +} + +static int Part_setChildBranchThre( BPy_PartSys * self, PyObject * args ) +{ + int res = EXPP_setFloatRange( args, &self->psys->part->branch_thres, + 0.0, 1.0 ); + + psys_flush_settings( self->psys->part, PSYS_ALLOC, 1 ); + + return res; +} + +static PyObject *Part_getChildBranchThre( BPy_PartSys * self ) +{ + return PyFloat_FromDouble( ((float)( self->psys->part->branch_thres )) ); +} diff --git a/source/blender/python/api2_2x/doc/Particle.py b/source/blender/python/api2_2x/doc/Particle.py index 47bcc7c88a3..9728c896904 100644 --- a/source/blender/python/api2_2x/doc/Particle.py +++ b/source/blender/python/api2_2x/doc/Particle.py @@ -141,6 +141,38 @@ class Particle: @type childSize: float @ivar childRand: Random variation to the size of the child particles @type childRand: float + @ivar childRough1: Amount of location dependant rough + @type childRough1: float + @ivar childRough1Size: Size of location dependant rough + @type childRough1Size: float + @ivar childRough2: Amount of random rough + @type childRough2: float + @ivar childRough2Size: Size of random rough + @type childRough2Size: float + @ivar childRough2Thresh: Amount of particles left untouched by random rough + @type childRough2Thresh: float + @ivar childRoughE: Amount of end point rough + @type childRoughE: float + @ivar childRoughEShape: Shape of end point rough + @type childRoughEShape: float + @ivar childKink: Type of periodic offset on the path (Particle.CHILDKINK[ 'BRAID' | 'WAVE' | 'RADIAL' | 'CURL' | 'NOTHING' ]) + @type childKink: int + @ivar childKinkAxis: Which axis to use for offset (Particle.CHILDKINKAXIS[ 'Z' | 'Y' | 'X' ]) + @type childKinkAxis: int + @ivar childKinkFreq: The frequency of the offset (1/total length) + @type childKinkFreq: float + @ivar childKinkShape: Adjust the offset to the beginning/end + @type childKinkShape: float + @ivar childKinkAmp: The amplitude of the offset + @type childKinkAmp: float + @ivar childBranch: Branch child paths from eachother + @type childBranch: int + @ivar childBranch: Animate branching + @type childBranch: int + @ivar childBranch: Start and end points are the same + @type childBranch: int + @ivar childBranch: Threshold of branching + @type childBranch: float """ def freeEdit(): -- cgit v1.2.3 From 5b07f06136bc96eedf703210046101efa05f749c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 20:19:27 +0000 Subject: fix some refcounting issues with PyDict_SetItemString --- source/blender/python/BPY_interface.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 4de7942666c..7b992dff472 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -106,6 +106,7 @@ static int setup_armature_weakrefs() { PyObject *maindict; PyObject *main_module; + PyObject *list; char *list_name = ARM_WEAKREF_LIST_NAME; main_module = PyImport_AddModule( "__main__"); @@ -121,14 +122,14 @@ static int setup_armature_weakrefs() PyDict_DelItemString(maindict,list_name); Py_XDECREF( weakreflink ); } - - if (PyDict_SetItemString(maindict, - list_name, - PyList_New(0)) == -1){ + + list= PyList_New(0); + if (PyDict_SetItemString(maindict, list_name, list) == -1){ printf("Oops - setup_armature_weakrefs()\n"); - + Py_DECREF(list); return 0; } + Py_DECREF(list); /* the dict owns it now */ } return 1; } @@ -1238,13 +1239,14 @@ static int bpy_pydriver_create_dict(void) /* import some modules: builtins, Blender, math, Blender.noise */ - PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins()); + PyDict_SetItemString(d, "__builtins__", PyEval_GetBuiltins()); /* borrow ref, ok */ mod = PyImport_ImportModule("Blender"); if (mod) { PyDict_SetItemString(d, "Blender", mod); PyDict_SetItemString(d, "b", mod); Py_DECREF(mod); + Py_DECREF(mod); } else { PyErr_Clear(); } @@ -1257,6 +1259,7 @@ static int bpy_pydriver_create_dict(void) PyDict_SetItemString(d, "math", mod); PyDict_SetItemString(d, "m", mod); Py_DECREF(mod); + Py_DECREF(mod); } mod = PyImport_ImportModule("Blender.Noise"); @@ -1264,6 +1267,7 @@ static int bpy_pydriver_create_dict(void) PyDict_SetItemString(d, "noise", mod); PyDict_SetItemString(d, "n", mod); Py_DECREF(mod); + Py_DECREF(mod); } else { PyErr_Clear(); } @@ -1276,6 +1280,7 @@ static int bpy_pydriver_create_dict(void) PyDict_SetItemString(d, "pydrivers", mod); PyDict_SetItemString(d, "p", mod); Py_DECREF(mod); + Py_DECREF(mod); } else { PyErr_Clear(); } -- cgit v1.2.3 From 6f12e584a97f664c654ddfbe5f721d2a7be3d491 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Mon, 13 Apr 2009 19:33:22 +0000 Subject: SVN maintenance. --- source/blender/python/api2_2x/bpy_internal_import.c | 2 +- source/blender/python/api2_2x/bpy_internal_import.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c index d8280d4d609..d022fddeb57 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.c +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -1,5 +1,5 @@ /* - * $Id: bpy_types.h 14444 2008-04-16 22:40:48Z hos $ + * $Id$ * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/python/api2_2x/bpy_internal_import.h b/source/blender/python/api2_2x/bpy_internal_import.h index 773749b10f9..c461565b5ac 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.h +++ b/source/blender/python/api2_2x/bpy_internal_import.h @@ -1,5 +1,5 @@ /* - * $Id: bpy_types.h 14444 2008-04-16 22:40:48Z hos $ + * $Id$ * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or -- cgit v1.2.3 From 0b8661ab4da1a7cfbc756640649a2d07bb36cc64 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 13 Apr 2009 20:08:33 +0000 Subject: BGE: Occlusion culling and other performance improvements. Added occlusion culling capability in the BGE. More info: http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.49/Game_Engine#BGE_Scenegraph_improvement MSVC, scons, cmake, Makefile updated. Other minor performance improvements: - The rasterizer was computing the openGL model matrix of the objects too many times - DBVT view frustrum culling was not properly culling behind the near plane: Large objects behind the camera were sent to the GPU - Remove all references to mesh split/join feature as it is not yet functional --- source/blender/blenkernel/intern/world.c | 3 ++- source/blender/blenloader/intern/readfile.c | 3 ++- source/blender/makesdna/DNA_actuator_types.h | 4 +++- source/blender/makesdna/DNA_object_types.h | 2 ++ source/blender/makesdna/DNA_world_types.h | 5 +++-- source/blender/python/api2_2x/Object.c | 3 ++- source/blender/src/buttons_logic.c | 26 +++++++++++++++----------- source/blender/src/buttons_shading.c | 10 +++++++--- 8 files changed, 36 insertions(+), 20 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 594d18f1ca7..6635ef29d51 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -106,7 +106,8 @@ World *add_world(char *name) wrld->ao_approx_error= 0.25f; wrld->physicsEngine= WOPHY_BULLET;//WOPHY_SUMO; Bullet by default - wrld->mode = WO_DBVT_CAMERA_CULLING; // DBVT culling by default + wrld->mode = WO_DBVT_CULLING; // DBVT culling by default + wrld->occlusionRes = 128; wrld->preview = NULL; return wrld; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 63dd1e8e6cb..c3a355160e0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8057,7 +8057,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } /* DBVT culling by default */ for(wrld=main->world.first; wrld; wrld= wrld->id.next) { - wrld->mode |= WO_DBVT_CAMERA_CULLING; + wrld->mode |= WO_DBVT_CULLING; + wrld->occlusionRes = 128; } } diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 2252126b46c..aeabae42adf 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -195,7 +195,8 @@ typedef struct bGameActuator { typedef struct bVisibilityActuator { /** bit 0: Is this object visible? - ** bit 1: Apply recursively */ + ** bit 1: Apply recursively + ** bit 2: Is this object an occluder? */ int flag; } bVisibilityActuator; @@ -458,6 +459,7 @@ typedef struct FreeCamera { /* Set means the object will become invisible */ #define ACT_VISIBILITY_INVISIBLE (1 << 0) #define ACT_VISIBILITY_RECURSIVE (1 << 1) +#define ACT_VISIBILITY_OCCLUSION (1 << 2) /* twodfilter->type */ #define ACT_2DFILTER_ENABLED -2 diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index b17896aec70..3a408404b0b 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -437,6 +437,7 @@ extern Object workob; #define OB_COLLISION 65536 #define OB_SOFT_BODY 0x20000 +#define OB_OCCLUDER 0x40000 /* ob->gameflag2 */ #define OB_NEVER_DO_ACTIVITY_CULLING 1 @@ -455,6 +456,7 @@ extern Object workob; #define OB_BODY_TYPE_DYNAMIC 2 #define OB_BODY_TYPE_RIGID 3 #define OB_BODY_TYPE_SOFT 4 +#define OB_BODY_TYPE_OCCLUDER 5 /* ob->scavisflag */ #define OB_VIS_SENS 1 diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index a51e9704be2..f599364ed66 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -88,7 +88,8 @@ typedef struct World { * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling */ short mode; - int physicsEngine; /* here it's aligned */ + short occlusionRes; /* resolution of occlusion Z buffer in pixel */ + short physicsEngine; /* here it's aligned */ float misi, miststa, mistdist, misthi; @@ -135,7 +136,7 @@ typedef struct World { #define WO_DOF 4 #define WO_ACTIVITY_CULLING 8 #define WO_AMB_OCC 16 -#define WO_DBVT_CAMERA_CULLING 32 +#define WO_DBVT_CULLING 32 /* aomix */ #define WO_AOADD 0 diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index fd2301bfae4..2de2906335f 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -3561,7 +3561,7 @@ static int Object_setRBMass( BPy_Object * self, PyObject * args ) /* this is too low level, possible to add helper methods */ -#define GAMEFLAG_MASK ( OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \ +#define GAMEFLAG_MASK ( OB_OCCLUDER | OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \ OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | OB_SOFT_BODY | \ OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \ OB_MAINACTOR ) @@ -5542,6 +5542,7 @@ static PyObject *M_Object_RBFlagsDict( void ) if( M ) { BPy_constant *d = ( BPy_constant * ) M; + PyConstant_Insert( d, "OCCLUDER", PyInt_FromLong( OB_OCCLUDER ) ); PyConstant_Insert( d, "COLLISION", PyInt_FromLong( OB_COLLISION ) ); PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) ); PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) ); diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 97f07c7553c..2f68720acb0 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -2455,18 +2455,18 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh xco + 10, yco - 20, (width - 20)/3, 19, &visAct->flag, 0.0, 0.0, 0, 0, "Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner)"); - uiDefButBitI(block, TOG, ACT_VISIBILITY_INVISIBLE, B_REDR, - "Invisible", + uiDefButBitI(block, TOG, ACT_VISIBILITY_OCCLUSION, B_REDR, + "Occlusion", xco + 10 + ((width - 20)/3), yco - 20, (width - 20)/3, 19, &visAct->flag, 0.0, 0.0, 0, 0, - "Set the object invisible. Initialized from the objects render restriction toggle (access in the outliner)"); + "Set the object to occlude objects behind it. Initialized from the object type in physics button"); uiBlockEndAlign(block); uiDefButBitI(block, TOG, ACT_VISIBILITY_RECURSIVE, B_NOP, "Children", xco + 10 + (((width - 20)/3)*2)+10, yco - 20, ((width - 20)/3)-10, 19, &visAct->flag, 0.0, 0.0, 0, 0, - "Sets all the children of this object to the same visibility recursively"); + "Sets all the children of this object to the same visibility/occlusion recursively"); yco-= ysize; @@ -3033,25 +3033,29 @@ static void check_body_type(void *arg1_but, void *arg2_object) Object *ob = arg2_object; switch (ob->body_type) { + case OB_BODY_TYPE_OCCLUDER: + ob->gameflag |= OB_OCCLUDER; + ob->gameflag &= ~(OB_COLLISION|OB_DYNAMIC); + break; case OB_BODY_TYPE_NO_COLLISION: - ob->gameflag &= ~OB_COLLISION; + ob->gameflag &= ~(OB_COLLISION|OB_OCCLUDER|OB_DYNAMIC); break; case OB_BODY_TYPE_STATIC: ob->gameflag |= OB_COLLISION; - ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY); + ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER); break; case OB_BODY_TYPE_DYNAMIC: ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR; - ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY); + ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY|OB_OCCLUDER); break; case OB_BODY_TYPE_RIGID: ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR; - ob->gameflag &= ~(OB_SOFT_BODY); + ob->gameflag &= ~(OB_SOFT_BODY|OB_OCCLUDER); break; default: case OB_BODY_TYPE_SOFT: ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR; - ob->gameflag &= ~(OB_RIGID_BODY); + ob->gameflag &= ~(OB_RIGID_BODY|OB_OCCLUDER); /* assume triangle mesh, if no bounds chosen for soft body */ if ((ob->gameflag & OB_BOUNDS) && (ob->boundtypegameflag & OB_COLLISION)) - ob->body_type = OB_BODY_TYPE_NO_COLLISION; + ob->body_type = (ob->gameflag & OB_OCCLUDER) ? OB_BODY_TYPE_OCCLUDER : OB_BODY_TYPE_NO_COLLISION; else if (!(ob->gameflag & OB_DYNAMIC)) ob->body_type = OB_BODY_TYPE_STATIC; else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) @@ -3234,7 +3238,7 @@ static void buttons_bullet(uiBlock *block, Object *ob) //only enable game soft body if Blender Soft Body exists but = uiDefButS(block, MENU, REDRAWVIEW3D, - "Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4", + "Object type%t|Occluder%x5|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4", 10, 205, 100, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation"); uiButSetFunc(but, check_body_type, but, ob); diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index e68c86349ce..a129698cce3 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2181,7 +2181,7 @@ static void world_panel_mistaph(World *wrld) uiSetButLock(wrld->id.lib!=0, ERROR_LIBDATA_MESSAGE); #if GAMEBLENDER == 1 - uiDefButI(block, MENU, B_REDR, + uiDefButS(block, MENU, B_REDR, #ifdef USE_ODE "Physics %t|None %x0|Sumo %x2|Ode %x4 |Bullet %x5", #else @@ -2198,8 +2198,12 @@ static void world_panel_mistaph(World *wrld) /* Gravitation for the game worlds */ uiDefButF(block, NUMSLI,0, "Grav ", 150,180,150,19, &(wrld->gravity), 0.0, 25.0, 0, 0, "Sets the gravitation constant of the game world"); - if (wrld->physicsEngine == WOPHY_BULLET) - uiDefButBitS(block, TOG, WO_DBVT_CAMERA_CULLING, 0, "DBVT culling", 10,160,140,19, &wrld->mode, 0, 0, 0, 0, "Toggles use of optimized Bullet DBVT tree for camera culling"); + if (wrld->physicsEngine == WOPHY_BULLET) { + uiDefButBitS(block, TOG, WO_DBVT_CULLING, B_REDR, "DBVT culling", 10,160,140,19, &wrld->mode, 0, 0, 0, 0, "Toggles use of optimized Bullet DBVT tree for view frustrum and occlusion culling"); + if (wrld->mode & WO_DBVT_CULLING) + uiDefButS(block, NUM, B_REDR, "Occlu Res:", + 150, 160, 150, 19, &wrld->occlusionRes, 128.0, 1024.0, 0, 0, "Sets the size of the occlusion buffer in pixel, use higher value for better precsion (slower)"); + } #endif uiBlockSetCol(block, TH_BUT_SETTING1); -- cgit v1.2.3 From 3511f8ef9fe6a2a6491fbae3a44a407f280a19e0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Apr 2009 12:34:39 +0000 Subject: BGE Physics Clamp objects min/max velocity. Accessed with bullet physics from the advanced button with dynamic and rigid body objects. - useful for preventing unstable physics in cases where objects move too fast. - can add linear velocity with the motion actuator to give smooth motion transitions, without moving too fast. - minimum velocity means objects don't stop moving. - python scripts can adjust these values speedup or throttle velocity in the existing direction. Also made copy properties from an object with no properties work (in case you want to clear all props) --- source/blender/makesdna/DNA_object_types.h | 4 +++- source/blender/src/buttons_logic.c | 18 ++++++++++++++++++ source/blender/src/editobject.c | 13 ++++++------- 3 files changed, 27 insertions(+), 8 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 3a408404b0b..82da883df4a 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -157,7 +157,9 @@ typedef struct Object { float formfactor; float rdamping, sizefac; float margin; - int pad3; + float max_vel; /* clamp the maximum velocity 0.0 is disabled */ + float min_vel; /* clamp the maximum velocity 0.0 is disabled */ + float pad3; /* clamp the maximum velocity 0.0 is disabled */ char dt, dtx; char totcol; /* copy of mesh or curve or meta */ diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 2f68720acb0..67531e9b3b8 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -3139,6 +3139,7 @@ static uiBlock *advanced_bullet_menu(void *arg_ob) uiDefButF(block, NUM, 0, "Margin", xco, yco, 180, 19, &ob->margin, 0.001, 1.0, 1, 0, "Collision margin"); + yco -= 20; if (ob->gameflag & OB_RIGID_BODY) @@ -3166,7 +3167,24 @@ static uiBlock *advanced_bullet_menu(void *arg_ob) uiDefButBitI(block, TOG, OB_LOCK_RIGID_BODY_Z_ROT_AXIS, 0, "Lock Z Rot Axis", xco+=180, yco, 180, 19, &ob->gameflag2, 0, 0, 0, 0, "Disable simulation of angular motion along the Z axis"); + yco -= 20; } + xco = 0; + + uiBlockEndAlign(block); + + uiDefBut(block, LABEL, 0, "Clamp Velocity (zero disables)", xco, yco, 180*2, 19, NULL, 0, 0, 0, 0, ""); + + uiBlockBeginAlign(block); + + uiDefButF(block, NUM, 0, "Min", + xco+=180, yco, 90, 19, &ob->min_vel, 0.0, 1000.0, 1, 0, + "Clamp velocity to this minimum speed (except when totally still)"); + uiDefButF(block, NUM, 0, "Max", + xco+=90, yco, 90, 19, &ob->max_vel, 0.0, 1000.0, 1, 0, + "Clamp velocity to this maximum speed"); + uiBlockEndAlign(block); + /* uiDefButBitI(block, TOG, OB_BSB_COL_CL_RS, 0, "Cluster Collision RS", xco, yco, 180, 19, &ob->bsoft->collisionflags, 0, 0, 0, 0, diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index bb9be49c347..2f127f9a3ec 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -3205,14 +3205,12 @@ static void copymenu_properties(Object *ob) prop= prop->next; } - if(tot==0) { - error("No properties in the active object to copy"); - return; - } - str= MEM_callocN(50 + 33*tot, "copymenu prop"); - strcpy(str, "Copy Property %t|Replace All|Merge All|%l"); + if (tot) + strcpy(str, "Copy Property %t|Replace All|Merge All|%l"); + else + strcpy(str, "Copy Property %t|Clear All (no properties on active)"); tot= 0; prop= ob->prop.first; @@ -3526,7 +3524,8 @@ void copy_attr(short event) base->object->formfactor = ob->formfactor; base->object->damping= ob->damping; base->object->rdamping= ob->rdamping; - base->object->mass= ob->mass; + base->object->min_vel= ob->min_vel; + base->object->max_vel= ob->max_vel; if (ob->gameflag & OB_BOUNDS) { base->object->boundtype = ob->boundtype; } -- cgit v1.2.3 From bcabc596c9a50dc5c604648c3e83f06eb079d2e2 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 14 Apr 2009 17:13:21 +0000 Subject: Bugfix #18108 Another bug in the 'radius per vertex' feature in curves. If you set front/back face off for curves, and make it bevel or give depth, the curves should draw as tubes. This feature didn't work in 2.48 either... Still unsure about this implementation, campbell can check! --- source/blender/blenkernel/BKE_curve.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index a8d4ece7a21..79f4708fd41 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -47,7 +47,7 @@ struct BevList; #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_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || cu->bevobj) ? 1:0) +#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || cu->bevobj || cu->ext1!=0.0 || cu->ext2!=0.0) ? 1:0) void unlink_curve( struct Curve *cu); -- cgit v1.2.3 From c62dfc498d240dfa09ec0365dbfb0f56e307ad43 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Apr 2009 17:19:09 +0000 Subject: [#18517] Python scripts segfault on loading own error, EXPP_incr_ret from a macro was an implicit decloration in BGL.c For some reason this only crashed on 64bit linux To my defence the BGE makes so many warnings that they become usless, need to improve the situation here at some point. --- source/blender/python/api2_2x/BGL.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/BGL.h b/source/blender/python/api2_2x/BGL.h index 89e56811b29..bad6330dd8d 100644 --- a/source/blender/python/api2_2x/BGL.h +++ b/source/blender/python/api2_2x/BGL.h @@ -304,7 +304,8 @@ typedef struct _Buffer { #define ret_def_void #define ret_set_void -#define ret_ret_void return EXPP_incr_ret(Py_None) +/* would use Py_RETURN_NONE - except for py 2.3 doesnt have it */ +#define ret_ret_void { Py_INCREF(Py_None); return Py_None; } #define ret_def_GLint int ret_int #define ret_set_GLint ret_int= -- cgit v1.2.3 From efb7dd86ff001efe26fba1caef70a87806d138f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Apr 2009 04:34:27 +0000 Subject: Fix for own recent reference count error. - The armature weakref list was being incref'd twice then decrefed twice (incref and decref were used incorrectly), now only once. My 'fix' broke this. - In bpy_pydriver_create_dict the 2 refs added from running PyDict_SetItemString twice were undone when clearing the dictionary (added comment) - changed Py_XDECREF to Py_DECREF int BPY_pyconstraint_update and BPY_pyconstraint_target, Py_XDECREF checs for NULL value which would have crashed blender before it got to Py_XDECREF anyway. - after every error is reported (PyErr_Print), remove sys.last_traceback and clear the error, I found this fixed certain crashes (usually when starting the game engine or exiting blender), so best do this all the time. - header_text.c, CcdPhysicsEnvironment.cpp, KX_CameraActuator.cpp - remove some warnings. --- .../blender/nodes/intern/SHD_nodes/SHD_dynamic.c | 6 +- source/blender/python/BPY_interface.c | 201 +++++++++++---------- source/blender/python/api2_2x/Draw.c | 7 + .../blender/python/api2_2x/bpy_internal_import.c | 6 +- source/blender/src/header_text.c | 1 + source/blender/src/imagepaint.c | 3 +- 6 files changed, 121 insertions(+), 103 deletions(-) (limited to 'source/blender') diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c index 2065ac2ed33..88efd47fa66 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c @@ -340,7 +340,11 @@ static void node_dynamic_pyerror_print(bNode *node) PyGILState_STATE gilstate = PyGILState_Ensure(); fprintf(stderr, "\nError in dynamic node script \"%s\":\n", node->name); - if (PyErr_Occurred()) { PyErr_Print(); } + if (PyErr_Occurred()) { + PyErr_Print(); + PyErr_Clear(); + PySys_SetObject("last_traceback", NULL); + } else { fprintf(stderr, "Not a valid dynamic node Python script.\n"); } PyGILState_Release(gilstate); diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 7b992dff472..c46c6c083b2 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -97,6 +97,17 @@ PyObject *bpy_pydriver_Dict = NULL; PyObject *bpy_orig_syspath_List = NULL; +static void BPY_Err_Clear(void) +{ + /* Added in 2.48a, the last_traceback can reference Objects for example, increasing + * their user count. Not to mention holding references to wrapped data. + * This is especially bad when the PyObject for the wrapped data is free'd, after blender + * has alredy dealocated the pointer */ + PySys_SetObject( "last_traceback", NULL); + + PyErr_Clear(); +} + /* * set up a weakref list for Armatures * creates list in __main__ module dict @@ -107,30 +118,29 @@ static int setup_armature_weakrefs() PyObject *maindict; PyObject *main_module; PyObject *list; - char *list_name = ARM_WEAKREF_LIST_NAME; + PyObject *list_name = PyString_FromString(ARM_WEAKREF_LIST_NAME); main_module = PyImport_AddModule( "__main__"); if(main_module){ - PyObject *weakreflink; maindict= PyModule_GetDict(main_module); /* check if there is already a dict entry for the armature weakrefs, * and delete if so before making another one */ - - weakreflink= PyDict_GetItemString(maindict,list_name); - if( weakreflink != NULL ) { - PyDict_DelItemString(maindict,list_name); - Py_XDECREF( weakreflink ); - } + + if (PyDict_DelItem(maindict, list_name)==-1) + PyErr_Clear(); list= PyList_New(0); - if (PyDict_SetItemString(maindict, list_name, list) == -1){ - printf("Oops - setup_armature_weakrefs()\n"); + if (PyDict_SetItem(maindict, list_name, list) == -1){ + PyErr_Print(); + BPY_Err_Clear(); Py_DECREF(list); + Py_DECREF(list_name); return 0; } Py_DECREF(list); /* the dict owns it now */ } + Py_DECREF(list_name); return 1; } @@ -532,16 +542,6 @@ static PyObject *traceback_getFilename( PyObject * tb ) else return PyString_FromString("unknown"); } -static void BPY_Err_Clear(void) -{ - /* Added in 2.48a, the last_traceback can reference Objects for example, increasing - * their user count. Not to mention holding references to wrapped data. - * This is especially bad when the PyObject for the wrapped data is free'd, after blender - * has alredy dealocated the pointer */ - PySys_SetObject( "last_traceback", Py_None); - - PyErr_Clear(); -} /**************************************************************************** * Description: Blender Python error handler. This catches the error and * stores filename and line number in a global @@ -1137,6 +1137,7 @@ void BPY_free_finished_script( Script * script ) if( PyErr_Occurred( ) ) { /* if script ended after filesel */ PyErr_Print( ); /* eventual errors are handled now */ + BPY_Err_Clear( ); error_pyscript( ); } @@ -1245,10 +1246,9 @@ static int bpy_pydriver_create_dict(void) if (mod) { PyDict_SetItemString(d, "Blender", mod); PyDict_SetItemString(d, "b", mod); - Py_DECREF(mod); - Py_DECREF(mod); + Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */ } else { - PyErr_Clear(); + BPY_Err_Clear(); } mod = PyImport_ImportModule("math"); @@ -1258,18 +1258,18 @@ static int bpy_pydriver_create_dict(void) /* Only keep for backwards compat! - just import all math into root, they are standard */ PyDict_SetItemString(d, "math", mod); PyDict_SetItemString(d, "m", mod); - Py_DECREF(mod); - Py_DECREF(mod); - } + Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */ + } else { + BPY_Err_Clear(); + } mod = PyImport_ImportModule("Blender.Noise"); if (mod) { PyDict_SetItemString(d, "noise", mod); PyDict_SetItemString(d, "n", mod); - Py_DECREF(mod); - Py_DECREF(mod); + Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */ } else { - PyErr_Clear(); + BPY_Err_Clear(); } /* If there's a Blender text called pydrivers.py, import it. @@ -1279,10 +1279,9 @@ static int bpy_pydriver_create_dict(void) if (mod) { PyDict_SetItemString(d, "pydrivers", mod); PyDict_SetItemString(d, "p", mod); - Py_DECREF(mod); - Py_DECREF(mod); + Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */ } else { - PyErr_Clear(); + BPY_Err_Clear(); } } /* short aliases for some Get() functions: */ @@ -1297,7 +1296,7 @@ static int bpy_pydriver_create_dict(void) Py_DECREF(fcn); } } else { - PyErr_Clear(); + BPY_Err_Clear(); } /* TODO - change these */ @@ -1311,7 +1310,7 @@ static int bpy_pydriver_create_dict(void) Py_DECREF(fcn); } } else { - PyErr_Clear(); + BPY_Err_Clear(); } /* ma(matname) == Blender.Material.Get(matname) */ @@ -1324,7 +1323,7 @@ static int bpy_pydriver_create_dict(void) Py_DECREF(fcn); } } else { - PyErr_Clear(); + BPY_Err_Clear(); } return 0; @@ -1350,6 +1349,7 @@ static float pydriver_error(IpoDriver *driver) { fprintf(stderr, "\nError in Ipo Driver: No Object\nThis is the failed Python expression:\n'%s'\n\n", driver->name); PyErr_Print(); + BPY_Err_Clear(); return 0.0f; } @@ -1445,7 +1445,7 @@ void BPY_pyconstraint_update(Object *owner, bConstraint *con) return; } - Py_XDECREF(retval); + Py_DECREF(retval); retval = NULL; /* try to find NUM_TARGETS */ @@ -1578,9 +1578,9 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase con->flag |= PYCON_SCRIPTERROR; /* free temp objects */ - Py_XDECREF(idprop); - Py_XDECREF(srcmat); - Py_XDECREF(tarmats); + Py_DECREF(idprop); + Py_DECREF(srcmat); + Py_DECREF(tarmats); ReleaseGlobalDictionary(globals); @@ -1589,7 +1589,7 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase return; } - if (retval) {Py_XDECREF( retval );} + Py_DECREF( retval ); retval = NULL; gval = PyDict_GetItemString(globals, "doConstraint"); @@ -1597,9 +1597,9 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase printf("ERROR: no doConstraint function in constraint!\n"); /* free temp objects */ - Py_XDECREF(idprop); - Py_XDECREF(srcmat); - Py_XDECREF(tarmats); + Py_DECREF(idprop); + Py_DECREF(srcmat); + Py_DECREF(tarmats); ReleaseGlobalDictionary(globals); @@ -1612,15 +1612,15 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase if (PyFunction_Check(gval)) { pyargs = Py_BuildValue("OOO", srcmat, tarmats, idprop); retval = PyObject_CallObject(gval, pyargs); - Py_XDECREF(pyargs); + Py_DECREF(pyargs); } else { printf("ERROR: doConstraint is supposed to be a function!\n"); con->flag |= PYCON_SCRIPTERROR; - Py_XDECREF(idprop); - Py_XDECREF(srcmat); - Py_XDECREF(tarmats); + Py_DECREF(idprop); + Py_DECREF(srcmat); + Py_DECREF(tarmats); ReleaseGlobalDictionary(globals); @@ -1634,9 +1634,9 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase con->flag |= PYCON_SCRIPTERROR; /* free temp objects */ - Py_XDECREF(idprop); - Py_XDECREF(srcmat); - Py_XDECREF(tarmats); + Py_DECREF(idprop); + Py_DECREF(srcmat); + Py_DECREF(tarmats); ReleaseGlobalDictionary(globals); @@ -1650,10 +1650,10 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase printf("Error in PyConstraint - doConstraint: Function not returning a matrix!\n"); con->flag |= PYCON_SCRIPTERROR; - Py_XDECREF(idprop); - Py_XDECREF(srcmat); - Py_XDECREF(tarmats); - Py_XDECREF(retval); + Py_DECREF(idprop); + Py_DECREF(srcmat); + Py_DECREF(tarmats); + Py_DECREF(retval); ReleaseGlobalDictionary(globals); @@ -1667,10 +1667,10 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase printf("Error in PyConstraint - doConstraint: Matrix returned is the wrong size!\n"); con->flag |= PYCON_SCRIPTERROR; - Py_XDECREF(idprop); - Py_XDECREF(srcmat); - Py_XDECREF(tarmats); - Py_XDECREF(retval); + Py_DECREF(idprop); + Py_DECREF(srcmat); + Py_DECREF(tarmats); + Py_DECREF(retval); ReleaseGlobalDictionary(globals); @@ -1687,10 +1687,10 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase } /* free temp objects */ - Py_XDECREF(idprop); - Py_XDECREF(srcmat); - Py_XDECREF(tarmats); - Py_XDECREF(retval); + Py_DECREF(idprop); + Py_DECREF(srcmat); + Py_DECREF(tarmats); + Py_DECREF(retval); /* clear globals */ ReleaseGlobalDictionary(globals); @@ -1745,10 +1745,10 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct) con->flag |= PYCON_SCRIPTERROR; /* free temp objects */ - Py_XDECREF(tar); - Py_XDECREF(subtar); - Py_XDECREF(idprop); - Py_XDECREF(tarmat); + Py_DECREF(tar); + Py_DECREF(subtar); + Py_DECREF(idprop); + Py_DECREF(tarmat); ReleaseGlobalDictionary(globals); @@ -1757,17 +1757,17 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct) return; } - Py_XDECREF(retval); + Py_DECREF(retval); retval = NULL; /* try to find doTarget function to set the target matrix */ gval = PyDict_GetItemString(globals, "doTarget"); if (!gval) { /* free temp objects */ - Py_XDECREF(tar); - Py_XDECREF(subtar); - Py_XDECREF(idprop); - Py_XDECREF(tarmat); + Py_DECREF(tar); + Py_DECREF(subtar); + Py_DECREF(idprop); + Py_DECREF(tarmat); ReleaseGlobalDictionary(globals); @@ -1780,16 +1780,16 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct) if (PyFunction_Check(gval)) { pyargs = Py_BuildValue("OOOO", tar, subtar, tarmat, idprop); retval = PyObject_CallObject(gval, pyargs); - Py_XDECREF(pyargs); + Py_DECREF(pyargs); } else { printf("ERROR: doTarget is supposed to be a function!\n"); con->flag |= PYCON_SCRIPTERROR; - Py_XDECREF(tar); - Py_XDECREF(subtar); - Py_XDECREF(idprop); - Py_XDECREF(tarmat); + Py_DECREF(tar); + Py_DECREF(subtar); + Py_DECREF(idprop); + Py_DECREF(tarmat); ReleaseGlobalDictionary(globals); @@ -1804,10 +1804,10 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct) /* free temp objects */ - Py_XDECREF(tar); - Py_XDECREF(subtar); - Py_XDECREF(idprop); - Py_XDECREF(tarmat); + Py_DECREF(tar); + Py_DECREF(subtar); + Py_DECREF(idprop); + Py_DECREF(tarmat); ReleaseGlobalDictionary(globals); @@ -1819,11 +1819,11 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct) if (!PyObject_TypeCheck(retval, &matrix_Type)) { con->flag |= PYCON_SCRIPTERROR; - Py_XDECREF(tar); - Py_XDECREF(subtar); - Py_XDECREF(idprop); - Py_XDECREF(tarmat); - Py_XDECREF(retval); + Py_DECREF(tar); + Py_DECREF(subtar); + Py_DECREF(idprop); + Py_DECREF(tarmat); + Py_DECREF(retval); ReleaseGlobalDictionary(globals); @@ -1837,11 +1837,11 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct) printf("Error in PyConstraint - doTarget: Matrix returned is the wrong size!\n"); con->flag |= PYCON_SCRIPTERROR; - Py_XDECREF(tar); - Py_XDECREF(subtar); - Py_XDECREF(idprop); - Py_XDECREF(tarmat); - Py_XDECREF(retval); + Py_DECREF(tar); + Py_DECREF(subtar); + Py_DECREF(idprop); + Py_DECREF(tarmat); + Py_DECREF(retval); ReleaseGlobalDictionary(globals); @@ -1858,11 +1858,11 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct) } /* free temp objects */ - Py_XDECREF(tar); - Py_XDECREF(subtar); - Py_XDECREF(idprop); - Py_XDECREF(tarmat); - Py_XDECREF(retval); + Py_DECREF(tar); + Py_DECREF(subtar); + Py_DECREF(idprop); + Py_DECREF(tarmat); + Py_DECREF(retval); /* clear globals */ ReleaseGlobalDictionary(globals); @@ -1897,7 +1897,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2) con->flag |= PYCON_SCRIPTERROR; /* free temp objects */ - Py_XDECREF(idprop); + Py_DECREF(idprop); PyGILState_Release(gilstate); @@ -1913,7 +1913,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2) /* free temp objects */ ReleaseGlobalDictionary( globals ); - Py_XDECREF(idprop); + Py_DECREF(idprop); PyGILState_Release(gilstate); @@ -1928,7 +1928,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2) printf("ERROR: getSettings is supposed to be a function!\n"); ReleaseGlobalDictionary( globals ); - Py_XDECREF(idprop); + Py_DECREF(idprop); PyGILState_Release(gilstate); @@ -1941,7 +1941,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2) /* free temp objects */ ReleaseGlobalDictionary(globals); - Py_XDECREF(idprop); + Py_DECREF(idprop); PyGILState_Release(gilstate); @@ -1952,7 +1952,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2) ReleaseGlobalDictionary(globals); /* free temp objects */ - Py_XDECREF(idprop); + Py_DECREF(idprop); Py_DECREF(retval); PyGILState_Release(gilstate); @@ -2107,6 +2107,7 @@ static int bpy_button_eval_error(char *expr) { fprintf(stderr, "\nError in button evaluation:\nThis is the failed Python expression:\n'%s'\n\n", expr); PyErr_Print(); + BPY_Err_Clear(); return -1; } diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index 2af2261808b..57b3869d775 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -614,6 +614,9 @@ static void exit_pydraw( SpaceScript * sc, short err ) if( err ) { PyErr_Print( ); + PyErr_Clear( ); + PySys_SetObject("last_traceback", NULL); + script->flags = 0; /* mark script struct for deletion */ SCRIPT_SET_NULL(script); script->scriptname[0] = '\0'; @@ -838,6 +841,8 @@ static void exec_but_callback(void *pyobj, void *data) if (!result) { Py_DECREF(pyvalue); PyErr_Print( ); + PyErr_Clear( ); + PySys_SetObject("last_traceback", NULL); error_pyscript( ); } Py_XDECREF( result ); @@ -1129,6 +1134,8 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args ) if (!result) { PyErr_Print( ); + PyErr_Clear( ); + PySys_SetObject("last_traceback", NULL); error_pyscript( ); } else { /* copied from do_clever_numbuts in toolbox.c */ diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c index d022fddeb57..9d2d15e0991 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.c +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -84,6 +84,8 @@ PyObject *importText( char *name ) if( PyErr_Occurred( ) ) { PyErr_Print( ); + PyErr_Clear( ); + PySys_SetObject("last_traceback", NULL); free_compiled_text( text ); return NULL; } @@ -138,6 +140,8 @@ PyObject *reimportText( PyObject *module ) /* if compile failed.... return this error */ if( PyErr_Occurred( ) ) { PyErr_Print( ); + PyErr_Clear( ); + PySys_SetObject("last_traceback", NULL); free_compiled_text( text ); return NULL; } @@ -182,7 +186,7 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k Py_XDECREF( exception ); Py_XDECREF( err ); Py_XDECREF( tb ); - printf( "imported from text buffer...\n" ); + /* printf( "imported from text buffer...\n" ); */ } else { PyErr_Restore( exception, err, tb ); } diff --git a/source/blender/src/header_text.c b/source/blender/src/header_text.c index 050ff192df6..850b7d6cab1 100644 --- a/source/blender/src/header_text.c +++ b/source/blender/src/header_text.c @@ -74,6 +74,7 @@ #include "BIF_toolbox.h" #include "BKE_global.h" +#include "BKE_scene.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_sca.h" diff --git a/source/blender/src/imagepaint.c b/source/blender/src/imagepaint.c index 09666f4819d..ede6679b9f5 100644 --- a/source/blender/src/imagepaint.c +++ b/source/blender/src/imagepaint.c @@ -1921,7 +1921,7 @@ static void rect_to_uvspace_persp( } /* This works as we need it to but we can save a few steps and not use it */ - +#if 0 static float angle_2d_clockwise(const float p1[2], const float p2[2], const float p3[2]) { float v1[2], v2[2]; @@ -1931,6 +1931,7 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa return -atan2(v1[0]*v2[1] - v1[1]*v2[0], v1[0]*v2[0]+v1[1]*v2[1]); } +#endif #define ISECT_1 (1) #define ISECT_2 (1<<1) -- cgit v1.2.3 From 19c869ab64a0e14727217c7d221e03d32a614132 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Apr 2009 08:08:42 +0000 Subject: BGE Py Api importing modules wasnt returning the error from the blender text if it failed. --- source/blender/python/BPY_interface.c | 3 +- .../blender/python/api2_2x/bpy_internal_import.c | 70 ++++++++++++++++------ .../blender/python/api2_2x/bpy_internal_import.h | 4 +- 3 files changed, 56 insertions(+), 21 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index c46c6c083b2..3b539be7a95 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -1275,7 +1275,8 @@ static int bpy_pydriver_create_dict(void) /* If there's a Blender text called pydrivers.py, import it. * Users can add their own functions to this module. */ if (G.f&G_DOSCRIPTLINKS) { - mod = importText("pydrivers"); /* can also use PyImport_Import() */ + int found; /* not used but needed as an arg */ + mod = importText("pydrivers", &found); /* can also use PyImport_Import() */ if (mod) { PyDict_SetItemString(d, "pydrivers", mod); PyDict_SetItemString(d, "p", mod); diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c index 9d2d15e0991..d944c24d928 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.c +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -56,7 +56,7 @@ void bpy_import_main_set(struct Main *maggie) } -PyObject *importText( char *name ) +PyObject *importText( char *name, int *found ) { Text *text; char txtname[22]; /* 21+NULL */ @@ -64,6 +64,8 @@ PyObject *importText( char *name ) int namelen = strlen( name ); Main *maggie= bpy_import_main ? bpy_import_main:G.main; + *found= 0; + if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */ memcpy( txtname, name, namelen ); @@ -76,7 +78,9 @@ PyObject *importText( char *name ) if( !text ) return NULL; - + else + *found = 1; + if( !text->compiled ) { buf = txt_to_buf( text ); text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); @@ -99,7 +103,7 @@ PyObject *importText( char *name ) * find in-memory module and recompile */ -PyObject *reimportText( PyObject *module ) +PyObject *reimportText( PyObject *module, int *found ) { Text *text; char *txtname; @@ -107,6 +111,8 @@ PyObject *reimportText( PyObject *module ) char *buf = NULL; Main *maggie= bpy_import_main ? bpy_import_main:G.main; + *found= 0; + /* get name, filename from the module itself */ txtname = PyModule_GetFilename( module ); @@ -125,6 +131,8 @@ PyObject *reimportText( PyObject *module ) /* uh-oh.... didn't find it */ if( !text ) return NULL; + else + *found = 1; /* if previously compiled, free the object */ /* (can't see how could be NULL, but check just in case) */ @@ -155,8 +163,9 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k { PyObject *exception, *err, *tb; char *name; + int found= 0; PyObject *globals = NULL, *locals = NULL, *fromlist = NULL; - PyObject *m; + PyObject *newmodule; //PyObject_Print(args, stderr, 0); #if (PY_VERSION_HEX >= 0x02060000) @@ -173,24 +182,37 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k &name, &globals, &locals, &fromlist ) ) return NULL; #endif - m = PyImport_ImportModuleEx( name, globals, locals, fromlist ); - - if( m ) - return m; - else - PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ - m = importText( name ); - if( m ) { /* found module, ignore above exception */ + /* import existing builtin modules or modules that have been imported alredy */ + newmodule = PyImport_ImportModuleEx( name, globals, locals, fromlist ); + + if(newmodule) + return newmodule; + + PyErr_Fetch( &exception, &err, &tb ); /* get the python error incase we cant import as blender text either */ + + /* importing from existing modules failed, see if we have this module as blender text */ + newmodule = importText( name, &found ); + + if( newmodule ) {/* found module as blender text, ignore above exception */ PyErr_Clear( ); Py_XDECREF( exception ); Py_XDECREF( err ); Py_XDECREF( tb ); /* printf( "imported from text buffer...\n" ); */ - } else { + } + else if (found==1) { /* blender text module failed to execute but was found, use its error message */ + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + return NULL; + } + else { + /* no blender text was found that could import the module + * rause the original error from PyImport_ImportModuleEx */ PyErr_Restore( exception, err, tb ); } - return m; + return newmodule; } @@ -203,7 +225,8 @@ static PyObject *blender_reload( PyObject * self, PyObject * args ) PyObject *exception, *err, *tb; PyObject *module = NULL; PyObject *newmodule = NULL; - + int found= 0; + /* check for a module arg */ if( !PyArg_ParseTuple( args, "O:bpy_reload", &module ) ) return NULL; @@ -216,14 +239,25 @@ static PyObject *blender_reload( PyObject * self, PyObject * args ) /* no file, try importing from memory */ PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ - newmodule = reimportText( module ); - if( newmodule ) { /* found module, ignore above exception */ + newmodule = reimportText( module, &found ); + if( newmodule ) {/* found module as blender text, ignore above exception */ PyErr_Clear( ); Py_XDECREF( exception ); Py_XDECREF( err ); Py_XDECREF( tb ); - } else + /* printf( "imported from text buffer...\n" ); */ + } + else if (found==1) { /* blender text module failed to execute but was found, use its error message */ + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + return NULL; + } + else { + /* no blender text was found that could import the module + * rause the original error from PyImport_ImportModuleEx */ PyErr_Restore( exception, err, tb ); + } return newmodule; } diff --git a/source/blender/python/api2_2x/bpy_internal_import.h b/source/blender/python/api2_2x/bpy_internal_import.h index c461565b5ac..7fe412019ab 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.h +++ b/source/blender/python/api2_2x/bpy_internal_import.h @@ -35,8 +35,8 @@ #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ -PyObject *importText( char *name ); -PyObject *reimportText( PyObject *module ); +PyObject *importText( char *name, int *found ); +PyObject *reimportText( PyObject *module, int *found ); extern PyMethodDef bpy_import[]; extern PyMethodDef bpy_reload[]; -- cgit v1.2.3 From 3616eb9031df319b2865172482413d7dd916c46c Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Wed, 15 Apr 2009 16:16:00 +0000 Subject: Fixing more errors coverity found. Imagepaint make sure ibuf exists before we use it. This is CID# 545 editmesh_tools.c make sure were not indexing array with -1 This is CID# 137 (also removed some trailing whitespace I found) anim5.c totlen could be -1 so check its > -1 This is CID# 134 Kent --- source/blender/imbuf/intern/anim5.c | 2 +- source/blender/src/editmesh_tools.c | 26 +++++++++++++++----------- source/blender/src/imagepaint.c | 3 +-- 3 files changed, 17 insertions(+), 14 deletions(-) (limited to 'source/blender') diff --git a/source/blender/imbuf/intern/anim5.c b/source/blender/imbuf/intern/anim5.c index ab203fe80de..b6f29b6a145 100644 --- a/source/blender/imbuf/intern/anim5.c +++ b/source/blender/imbuf/intern/anim5.c @@ -425,7 +425,7 @@ int startanim5(struct anim * anim) { /* de hele file wordt in het geheugen gemapped */ totlen = BLI_filesize(file); - if (totlen && file>=0) { + if (totlen>0 && file>=0) { lseek(file, 0L, SEEK_SET); mem= MEM_mallocN(totlen, "mmap"); diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index 690b4481ec9..377cb42e2f5 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -2520,11 +2520,13 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype) } } } - sort[hold]->f &= ~SELECT; - sort[hold]->f2 |= EDGENEW; - length[hold] = -1; - } - } + if (hold > -1) { + sort[hold]->f &= ~SELECT; + sort[hold]->f2 |= EDGENEW; + length[hold] = -1; + } + } + } // Beauty Long Edges else { @@ -2541,13 +2543,15 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype) } } } - sort[hold]->f &= ~SELECT; - sort[hold]->f2 |= EDGENEW; - length[hold] = -1; - } - } + if (hold > -1) { + sort[hold]->f &= ~SELECT; + sort[hold]->f2 |= EDGENEW; + length[hold] = -1; + } + } + } } - } + } } gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); diff --git a/source/blender/src/imagepaint.c b/source/blender/src/imagepaint.c index ede6679b9f5..4d6c0898bce 100644 --- a/source/blender/src/imagepaint.c +++ b/source/blender/src/imagepaint.c @@ -708,8 +708,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float } ibuf = BKE_image_get_ibuf((Image *)tf->tpage, NULL); /* TODO - this may be slow, the only way around it is to have an ibuf index per face */ - - + if (!ibuf) return 0; if (interp) { float x, y; -- cgit v1.2.3 From b7e40b955fd635d703b70344dd91afc1506ecbc4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Apr 2009 18:20:19 +0000 Subject: Optional margin for packing UV islands and the 'Pack Islands' menu item. Useful for baking with bleed enabled. --- source/blender/makesdna/DNA_scene_types.h | 2 ++ source/blender/src/buttons_editing.c | 5 ++++- source/blender/src/parametrizer.c | 12 ++++++------ source/blender/src/parametrizer.h | 2 +- source/blender/src/unwrapper.c | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index bf5b2ad3df5..d26bdd469f6 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -412,6 +412,8 @@ typedef struct ToolSettings { short unwrapper; float uvcalc_radius; float uvcalc_cubesize; + float uvcalc_margin; + float pad; short uvcalc_mapdir; short uvcalc_mapalign; short uvcalc_flag; diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 2ec30bfa864..779909ec713 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -6622,7 +6622,10 @@ static void editing_panel_mesh_uvautocalculation(void) uiDefButBitS(block, TOGN, UVCALC_NO_ASPECT_CORRECT, B_NOP, "Image Aspect",100,row,200,butH,&G.scene->toolsettings->uvcalc_flag, 0, 0, 0, 0, "Scale the UV Unwrapping to correct for the current images aspect ratio"); row-= butHB+butS; - uiDefButBitS(block, TOG, UVCALC_TRANSFORM_CORRECT, B_NOP, "Transform Correction",100,row,200,butH,&G.scene->toolsettings->uvcalc_flag, 0, 0, 0, 0, "Correct for UV distortion while transforming, (only works with edge slide now)"); + uiDefButBitS(block, TOG, UVCALC_TRANSFORM_CORRECT, B_NOP, "Transform Correction",100,row,200,butH,&G.scene->toolsettings->uvcalc_flag, 0, 0, 0, 0, "Correct for UV distortion while transforming, (only works with edge slide now)"); + + row-= butHB+butS; + uiDefButF(block, NUM,B_NOP ,"Pack Margin:",100,row,200,butH, &G.scene->toolsettings->uvcalc_margin, 0.0, 1.0, 10, 2, "Add a margin between UV islands when unwrapping or with 'Pack Islands' in the UV window"); row= 180; diff --git a/source/blender/src/parametrizer.c b/source/blender/src/parametrizer.c index 1cf796d86bc..654113f5f0c 100644 --- a/source/blender/src/parametrizer.c +++ b/source/blender/src/parametrizer.c @@ -4125,8 +4125,8 @@ void param_smooth_area(ParamHandle *handle) } } -void param_pack(ParamHandle *handle) -{ +void param_pack(ParamHandle *handle, float margin) +{ /* box packing variables */ boxPack *boxarray, *box; float tot_width, tot_height, scale; @@ -4158,13 +4158,13 @@ void param_pack(ParamHandle *handle) p_chart_uv_bbox(chart, trans, chart->u.pack.size); - trans[0] = -trans[0]; - trans[1] = -trans[1]; + trans[0] = -(trans[0] - margin); + trans[1] = -(trans[1] - margin); p_chart_uv_translate(chart, trans); - box->w = chart->u.pack.size[0] + trans[0]; - box->h = chart->u.pack.size[1] + trans[1]; + box->w = (chart->u.pack.size[0] + trans[0]) + margin*2; + box->h = (chart->u.pack.size[1] + trans[1]) + margin*2; box->index = i; /* warning this index skips PCHART_NOPACK boxes */ } diff --git a/source/blender/src/parametrizer.h b/source/blender/src/parametrizer.h index c468b8d62c5..f1454ee3865 100644 --- a/source/blender/src/parametrizer.h +++ b/source/blender/src/parametrizer.h @@ -73,7 +73,7 @@ void param_smooth_area(ParamHandle *handle); /* Packing */ -void param_pack(ParamHandle *handle); +void param_pack(ParamHandle *handle, float margin); /* Average area for all charts */ diff --git a/source/blender/src/unwrapper.c b/source/blender/src/unwrapper.c index 612e068c6ca..fadc087df65 100644 --- a/source/blender/src/unwrapper.c +++ b/source/blender/src/unwrapper.c @@ -327,7 +327,7 @@ void unwrap_lscm(short seamcut) param_lscm_solve(handle); param_lscm_end(handle); - param_pack(handle); + param_pack(handle, G.scene->toolsettings->uvcalc_margin); param_flush(handle); @@ -442,7 +442,7 @@ void pack_charts_tface_uv(void) if(!EM_texFaceCheck()) return; handle = construct_param_handle(em, 1, 0, 1); - param_pack(handle); + param_pack(handle, G.scene->toolsettings->uvcalc_margin); param_flush(handle); param_delete(handle); -- cgit v1.2.3 From 52a3d5c518cb969dad321d6f0486d9f33dd95791 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Apr 2009 19:20:12 +0000 Subject: BGE Python API Free python modules defined within the blendfile between loading scenes since they would end up accessing old GameLogic, Rasterizer modules as well as old game engine data in the module namespace which can cause problems. --- .../blender/python/api2_2x/bpy_internal_import.c | 62 ++++++++++++++++++++++ .../blender/python/api2_2x/bpy_internal_import.h | 1 + 2 files changed, 63 insertions(+) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c index d944c24d928..a62ae689f59 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.c +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -265,3 +265,65 @@ static PyObject *blender_reload( PyObject * self, PyObject * args ) PyMethodDef bpy_import[] = { {"bpy_import", blender_import, METH_KEYWORDS, "blenders import"} }; PyMethodDef bpy_reload[] = { {"bpy_reload", blender_reload, METH_VARARGS, "blenders reload"} }; + +/* Clear user modules. + * This is to clear any modules that could be defined from running scripts in blender. + * + * Its also needed for the BGE Python api so imported scripts are not used between levels + * + * This clears every modules that has a __file__ attribute (is not a builtin) + * and is a filename only (no path). since pythons bultins include a full path even for win32. + * even if we remove a python module a reimport will bring it back again. + */ + + +#if defined(WIN32) || defined(WIN64) +#define SEPSTR "\\" +#else +#define SEPSTR "/" +#endif + + +void importClearUserModules(void) +{ + PyObject *modules= PySys_GetObject("modules"); + + char *fname; + char *file_extension; + + /* looping over the dict */ + PyObject *key, *value; + Py_ssize_t pos = 0; + + /* new list */ + PyObject *list= PyList_New(0); + + /* go over sys.modules and remove anything with a + * sys.modukes[x].__file__ thats ends with a .py and has no path + */ + while (PyDict_Next(modules, &pos, &key, &value)) { + fname= PyModule_GetFilename(value); + if(fname) { + if ((strstr(fname, SEPSTR))==0) { /* no path ? */ + file_extension = strstr(fname, ".py"); + if(file_extension && *(file_extension + 3) == '\0') { /* .py extension ? */ + /* now we can be fairly sure its a python import from the blendfile */ + PyList_Append(list, key); /* free'd with the list */ + } + } + } + else { + PyErr_Clear(); + } + } + + /* remove all our modules */ + for(pos=0; pos < PyList_Size(list); pos++) { + /* PyObject_Print(key, stderr, 0); */ + key= PyList_GET_ITEM(list, pos); + PyDict_DelItem(modules, key); + } + + Py_DECREF(list); /* removes all references from append */ +} + diff --git a/source/blender/python/api2_2x/bpy_internal_import.h b/source/blender/python/api2_2x/bpy_internal_import.h index 7fe412019ab..9d440406636 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.h +++ b/source/blender/python/api2_2x/bpy_internal_import.h @@ -37,6 +37,7 @@ PyObject *importText( char *name, int *found ); PyObject *reimportText( PyObject *module, int *found ); +void importClearUserModules( void ); /* Clear user modules */ extern PyMethodDef bpy_import[]; extern PyMethodDef bpy_reload[]; -- cgit v1.2.3 From 0c1bfa4a37d9ba40b8ad66656363ecfa77e0db1d Mon Sep 17 00:00:00 2001 From: Andre Susano Pinto Date: Wed, 15 Apr 2009 19:33:25 +0000 Subject: Merging Shrinkwrap Constraint! +bvhtree cache (if the derived model doenst gets destroyed then the same BVHtree can be used) this was needed to allow shrinkwrap constraint to be usable. It has been ready for a long time.. but only got merged now, for 2.49. --- source/blender/blenkernel/BKE_DerivedMesh.h | 2 + source/blender/blenkernel/BKE_bvhutils.h | 45 ++++- source/blender/blenkernel/BKE_shrinkwrap.h | 4 +- source/blender/blenkernel/intern/DerivedMesh.c | 5 + source/blender/blenkernel/intern/bvhutils.c | 196 ++++++++++++++----- source/blender/blenkernel/intern/constraint.c | 162 ++++++++++++++++ source/blender/blenkernel/intern/shrinkwrap.c | 257 ++++++++++++------------- source/blender/blenloader/intern/readfile.c | 13 ++ source/blender/include/butspace.h | 1 + source/blender/makesdna/DNA_constraint_types.h | 12 +- source/blender/src/buttons_editing.c | 14 +- source/blender/src/buttons_object.c | 40 ++++ source/blender/src/editconstraint.c | 5 + 13 files changed, 568 insertions(+), 188 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 5a1e266adeb..263b17151e7 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -44,6 +44,7 @@ #include "DNA_customdata_types.h" #include "BKE_customdata.h" +#include "BKE_bvhutils.h" struct MVert; struct MEdge; @@ -69,6 +70,7 @@ struct DerivedMesh { int numVertData, numEdgeData, numFaceData; int needsFree; /* checked on ->release, is set to 0 for cached results */ int deformedOnly; /* set by modifier stack if only deformed from original */ + BVHCache bvhCache; /* Misc. Queries */ diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index dd9ea61f24b..66c8d99959a 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -31,6 +31,7 @@ #define BKE_BVHUTILS_H #include "BLI_kdopbvh.h" +#include "BLI_linklist.h" /* * This header encapsulates necessary code to buld a BVH @@ -52,7 +53,7 @@ typedef struct BVHTreeFromMesh BVHTree_RayCastCallback raycast_callback; /* Mesh represented on this BVHTree */ - struct DerivedMesh *mesh; + struct DerivedMesh *mesh; /* Vertex array, so that callbacks have instante access to data */ struct MVert *vert; @@ -61,6 +62,9 @@ typedef struct BVHTreeFromMesh /* radius for raycast */ float sphere_radius; + /* Private data */ + int cached; + } BVHTreeFromMesh; /* @@ -74,7 +78,7 @@ typedef struct BVHTreeFromMesh * * free_bvhtree_from_mesh should be called when the tree is no longer needed. */ -void bvhtree_from_mesh_verts(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); +BVHTree* bvhtree_from_mesh_verts(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); /* * Builds a bvh tree where nodes are the faces of the given mesh. @@ -84,15 +88,50 @@ void bvhtree_from_mesh_verts(struct BVHTreeFromMesh *data, struct DerivedMesh *m * so that the coordinates and rays are first translated on the mesh local coordinates. * Reason for this is that later bvh_from_mesh_* might use a cache system and so it becames possible to reuse * a BVHTree. + * + * The returned value is the same as in data->tree, its only returned to make it easier to test + * the success * * free_bvhtree_from_mesh should be called when the tree is no longer needed. */ -void bvhtree_from_mesh_faces(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); +BVHTree* bvhtree_from_mesh_faces(struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); /* * Frees data allocated by a call to bvhtree_from_mesh_*. */ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data); + +/* + * BVHCache + */ + +//Using local coordinates +#define BVHTREE_FROM_FACES 0 +#define BVHTREE_FROM_VERTICES 1 + +typedef LinkNode* BVHCache; + + +/* + * Queries a bvhcache for the chache bvhtree of the request type + */ +BVHTree *bvhcache_find(BVHCache *cache, int type); + +/* + * Inserts a BVHTree of the given type under the cache + * After that the caller no longer needs to worry when to free the BVHTree + * as that will be done when the cache is freed. + * + * A call to this assumes that there was no previous cached tree of the given type + */ +void bvhcache_insert(BVHCache *cache, BVHTree *tree, int type); + +/* + * inits and frees a bvhcache + */ +void bvhcache_init(BVHCache *cache); +void bvhcache_free(BVHCache *cache); + #endif diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index eed22ff9d8e..6ce449f7824 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -95,6 +95,8 @@ void space_transform_invert_normal(const SpaceTransform *data, float *no); struct Object; struct DerivedMesh; +struct MVert; +struct MDeformVert; struct ShrinkwrapModifierData; struct MDeformVert; struct BVHTree; @@ -105,8 +107,8 @@ typedef struct ShrinkwrapCalcData ShrinkwrapModifierData *smd; //shrinkwrap modifier data struct Object *ob; //object we are applying shrinkwrap to - struct DerivedMesh *original; //mesh before shrinkwrap + MVert *vert; //Array of verts being projected (to fetch normals or other data) float (*vertexCos)[3]; //vertexs being shrinkwraped int numVerts; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c934f7d9fe7..d43cbdebe72 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -77,6 +77,7 @@ #include "BKE_texture.h" #include "BKE_utildefines.h" #include "BKE_particle.h" +#include "BKE_bvhutils.h" #include "BLO_sys_types.h" // for intptr_t support @@ -182,6 +183,8 @@ void DM_init_funcs(DerivedMesh *dm) dm->getVertDataArray = DM_get_vert_data_layer; dm->getEdgeDataArray = DM_get_edge_data_layer; dm->getFaceDataArray = DM_get_face_data_layer; + + bvhcache_init(&dm->bvhCache); } void DM_init(DerivedMesh *dm, @@ -218,6 +221,8 @@ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, int DM_release(DerivedMesh *dm) { if (dm->needsFree) { + bvhcache_free(&dm->bvhCache); + CustomData_free(&dm->vertData, dm->numVertData); CustomData_free(&dm->edgeData, dm->numEdgeData); CustomData_free(&dm->faceData, dm->numFaceData); diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index ae449843d2a..d9e005811d0 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "BKE_bvhutils.h" @@ -45,6 +46,8 @@ #include "BKE_global.h" #include "BLI_arithb.h" +#include "BLI_linklist.h" +#include "MEM_guardedalloc.h" /* Math stuff for ray casting on mesh faces and for nearest surface */ @@ -480,30 +483,47 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r * BVH builders */ // Builds a bvh tree.. where nodes are the vertexs of the given mesh -void bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { - int i; - int numVerts= mesh->getNumVerts(mesh); - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); - BVHTree *tree = NULL; + BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES); - memset(data, 0, sizeof(*data)); + //Not in cache + if(tree == NULL) + { + int i; + int numVerts= mesh->getNumVerts(mesh); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); - if(vert == NULL) + if(vert != NULL) + { + tree = BLI_bvhtree_new(numVerts, epsilon, tree_type, axis); + + if(tree != NULL) + { + for(i = 0; i < numVerts; i++) + BLI_bvhtree_insert(tree, i, vert[i].co, 1); + + BLI_bvhtree_balance(tree); + + //Save on cache for later use +// printf("BVHTree built and saved on cache\n"); + bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_VERTICES); + } + } + } + else { - printf("bvhtree cant be build: cant get a vertex array"); - return; +// printf("BVHTree is already build, using cached tree\n"); } - tree = BLI_bvhtree_new(numVerts, epsilon, tree_type, axis); - if(tree != NULL) - { - for(i = 0; i < numVerts; i++) - BLI_bvhtree_insert(tree, i, vert[i].co, 1); - BLI_bvhtree_balance(tree); + //Setup BVHTreeFromMesh + memset(data, 0, sizeof(*data)); + data->tree = tree; - data->tree = tree; + if(data->tree) + { + data->cached = TRUE; //a NULL nearest callback works fine //remeber the min distance to point is the same as the min distance to BV of point @@ -516,43 +536,62 @@ void bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float eps data->sphere_radius = epsilon; } + + return data->tree; } // Builds a bvh tree.. where nodes are the faces of the given mesh. -void bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { - int i; - int numFaces= mesh->getNumFaces(mesh); - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); - MFace *face = mesh->getFaceDataArray(mesh, CD_MFACE); - BVHTree *tree = NULL; - - memset(data, 0, sizeof(*data)); + BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES); - if(vert == NULL && face == NULL) + //Not in cache + if(tree == NULL) { - printf("bvhtree cant be build: cant get a vertex/face array"); - return; - } + int i; + int numFaces= mesh->getNumFaces(mesh); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); + MFace *face = mesh->getFaceDataArray(mesh, CD_MFACE); - /* Create a bvh-tree of the given target */ - tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); - if(tree != NULL) - { - for(i = 0; i < numFaces; i++) + if(vert != NULL && face != NULL) { - float co[4][3]; - VECCOPY(co[0], vert[ face[i].v1 ].co); - VECCOPY(co[1], vert[ face[i].v2 ].co); - VECCOPY(co[2], vert[ face[i].v3 ].co); - if(face[i].v4) - VECCOPY(co[3], vert[ face[i].v4 ].co); + /* Create a bvh-tree of the given target */ + tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); + if(tree != NULL) + { + for(i = 0; i < numFaces; i++) + { + float co[4][3]; + VECCOPY(co[0], vert[ face[i].v1 ].co); + VECCOPY(co[1], vert[ face[i].v2 ].co); + VECCOPY(co[2], vert[ face[i].v3 ].co); + if(face[i].v4) + VECCOPY(co[3], vert[ face[i].v4 ].co); - BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + } + BLI_bvhtree_balance(tree); + + //Save on cache for later use +// printf("BVHTree built and saved on cache\n"); + bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_FACES); + } } - BLI_bvhtree_balance(tree); + } + else + { +// printf("BVHTree is already build, using cached tree\n"); + } + + + //Setup BVHTreeFromMesh + memset(data, 0, sizeof(*data)); + data->tree = tree; + + if(data->tree) + { + data->cached = TRUE; - data->tree = tree; data->nearest_callback = mesh_faces_nearest_point; data->raycast_callback = mesh_faces_spherecast; @@ -562,6 +601,8 @@ void bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float eps data->sphere_radius = epsilon; } + return data->tree; + } // Frees data allocated by a call to bvhtree_from_mesh_*. @@ -569,9 +610,78 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data) { if(data->tree) { - BLI_bvhtree_free(data->tree); + if(!data->cached) + BLI_bvhtree_free(data->tree); + memset( data, 0, sizeof(data) ); } } +/* BVHCache */ +typedef struct BVHCacheItem +{ + int type; + BVHTree *tree; + +} BVHCacheItem; + +static void bvhcacheitem_set_if_match(void *_cached, void *_search) +{ + BVHCacheItem * cached = (BVHCacheItem *)_cached; + BVHCacheItem * search = (BVHCacheItem *)_search; + + if(search->type == cached->type) + { + search->tree = cached->tree; + } +} + +BVHTree *bvhcache_find(BVHCache *cache, int type) +{ + BVHCacheItem item; + item.type = type; + item.tree = NULL; + + BLI_linklist_apply(*cache, bvhcacheitem_set_if_match, &item); + return item.tree; +} + +void bvhcache_insert(BVHCache *cache, BVHTree *tree, int type) +{ + BVHCacheItem *item = NULL; + + assert( tree != NULL ); + assert( bvhcache_find(cache, type) == NULL ); + + item = MEM_mallocN(sizeof(BVHCacheItem), "BVHCacheItem"); + assert( item != NULL ); + + item->type = type; + item->tree = tree; + + BLI_linklist_prepend( cache, item ); +} + + +void bvhcache_init(BVHCache *cache) +{ + *cache = NULL; +} + +static void bvhcacheitem_free(void *_item) +{ + BVHCacheItem *item = (BVHCacheItem *)_item; + + BLI_bvhtree_free(item->tree); + MEM_freeN(item); +} + + +void bvhcache_free(BVHCache *cache) +{ + BLI_linklist_free(*cache, (LinkNodeFreeFP)bvhcacheitem_free); + *cache = NULL; +} + + diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index db98c200566..f93fc403404 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -40,6 +40,7 @@ #include "DNA_armature_types.h" #include "DNA_constraint_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_action_types.h" #include "DNA_curve_types.h" @@ -63,6 +64,7 @@ #include "BKE_global.h" #include "BKE_library.h" #include "BKE_idprop.h" +#include "BKE_shrinkwrap.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" @@ -3239,6 +3241,165 @@ static bConstraintTypeInfo CTI_TRANSFORM = { transform_evaluate /* evaluate */ }; +/* ---------- Shrinkwrap Constraint ----------- */ + +static int shrinkwrap_get_tars (bConstraint *con, ListBase *list) +{ + if (con && list) { + bShrinkwrapConstraint *data = con->data; + bConstraintTarget *ct; + + SINGLETARGETNS_GET_TARS(con, data->target, ct, list) + + return 1; + } + + return 0; +} + + +static void shrinkwrap_flush_tars (bConstraint *con, ListBase *list, short nocopy) +{ + if (con && list) { + bShrinkwrapConstraint *data = con->data; + bConstraintTarget *ct= list->first; + + SINGLETARGETNS_FLUSH_TARS(con, data->target, ct, list, nocopy) + } +} + + +static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +{ + bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data; + + if( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) + { + int fail = FALSE; + float co[3] = {0.0f, 0.0f, 0.0f}; + float no[3] = {0.0f, 0.0f, 0.0f}; + float dist; + + SpaceTransform transform; + DerivedMesh *target = object_get_derived_final(ct->tar, CD_MASK_BAREMESH); + BVHTreeRayHit hit; + BVHTreeNearest nearest; + + BVHTreeFromMesh treeData; + memset( &treeData, 0, sizeof(treeData) ); + + nearest.index = -1; + nearest.dist = FLT_MAX; + + hit.index = -1; + hit.dist = 100000.0f; //TODO should use FLT_MAX.. but normal projection doenst yet supports it + + Mat4One(ct->matrix); + + if(target != NULL) + { + space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat); + + switch(scon->shrinkType) + { + case MOD_SHRINKWRAP_NEAREST_SURFACE: + case MOD_SHRINKWRAP_NEAREST_VERTEX: + + if(scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX) + bvhtree_from_mesh_verts(&treeData, target, 0.0, 2, 6); + else + bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6); + + if(treeData.tree == NULL) + { + fail = TRUE; + break; + } + + space_transform_apply(&transform, co); + + BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData); + + dist = VecLenf(co, nearest.co); + VecLerpf(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ + space_transform_invert(&transform, co); + break; + + case MOD_SHRINKWRAP_PROJECT: + if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f; + if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) no[1] = 1.0f; + if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) no[2] = 1.0f; + + if(INPR(no,no) < FLT_EPSILON) + { + fail = TRUE; + break; + } + + Normalize(no); + + + bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6); + if(treeData.tree == NULL) + { + fail = TRUE; + break; + } + + if(normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE) + { + fail = TRUE; + break; + } + VECCOPY(co, hit.co); + break; + } + + free_bvhtree_from_mesh(&treeData); + + target->release(target); + + if(fail == TRUE) + { + /* Don't move the point */ + co[0] = co[1] = co[2] = 0.0f; + } + + /* co is in local object coordinates, change it to global and update target position */ + VecMat4MulVecfl(co, cob->matrix, co); + VECCOPY(ct->matrix[3], co); + } + } +} + +static void shrinkwrap_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +{ + bConstraintTarget *ct= targets->first; + + /* only evaluate if there is a target */ + if (VALID_CONS_TARGET(ct)) + { + VECCOPY(cob->matrix[3], ct->matrix[3]); + } +} + +static bConstraintTypeInfo CTI_SHRINKWRAP = { + CONSTRAINT_TYPE_SHRINKWRAP, /* type */ + sizeof(bShrinkwrapConstraint), /* size */ + "Shrinkwrap", /* name */ + "bShrinkwrapConstraint", /* struct name */ + NULL, /* free data */ + NULL, /* relink data */ + NULL, /* copy data */ + NULL, /* new data */ + shrinkwrap_get_tars, /* get constraint targets */ + shrinkwrap_flush_tars, /* flush constraint targets */ + shrinkwrap_get_tarmat, /* get a target matrix */ + shrinkwrap_evaluate /* evaluate */ +}; + + + /* ************************* Constraints Type-Info *************************** */ /* All of the constraints api functions use bConstraintTypeInfo structs to carry out * and operations that involve constraint specifc code. @@ -3270,6 +3431,7 @@ static void constraints_init_typeinfo () { constraintsTypeInfo[17]= &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */ constraintsTypeInfo[18]= &CTI_CLAMPTO; /* ClampTo Constraint */ constraintsTypeInfo[19]= &CTI_TRANSFORM; /* Transformation Constraint */ + constraintsTypeInfo[20]= &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */ } /* This function should be used for getting the appropriate type-info when only diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index ab98fb1f007..6784f014efa 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -148,6 +148,7 @@ static float squared_dist(const float *a, const float *b) void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { + DerivedMesh *ss_mesh = NULL; ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData; //remove loop dependencies on derived meshs (TODO should this be done elsewhere?) @@ -158,15 +159,14 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM //Configure Shrinkwrap calc data calc.smd = smd; calc.ob = ob; - calc.original = dm; calc.numVerts = numVerts; calc.vertexCos = vertexCos; //DeformVertex calc.vgroup = get_named_vertexgroup_num(calc.ob, calc.smd->vgroup_name); - if(calc.original) + if(dm) { - calc.dvert = calc.original->getVertDataArray(calc.original, CD_MDEFORMVERT); + calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); } else if(calc.ob->type == OB_LATTICE) { @@ -176,17 +176,54 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM if(smd->target) { - //TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array - calc.target = CDDM_copy( object_get_derived_final(smd->target, CD_MASK_BAREMESH) ); + calc.target = object_get_derived_final(smd->target, CD_MASK_BAREMESH); - //TODO there might be several "bugs" on non-uniform scales matrixs.. because it will no longer be nearest surface, not sphere projection + //TODO there might be several "bugs" on non-uniform scales matrixs + //because it will no longer be nearest surface, not sphere projection //because space has been deformed space_transform_setup(&calc.local2target, ob, smd->target); - calc.keepDist = smd->keepDist; //TODO: smd->keepDist is in global units.. must change to local + //TODO: smd->keepDist is in global units.. must change to local + calc.keepDist = smd->keepDist; } + + calc.vgroup = get_named_vertexgroup_num(calc.ob, smd->vgroup_name); + + if(dm != NULL) + { + //Setup arrays to get vertexs positions, normals and deform weights + calc.vert = dm->getVertDataArray(dm, CD_MVERT); + calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); + + //Using vertexs positions/normals as if a subsurface was applied + if(smd->subsurfLevels) + { + SubsurfModifierData ssmd; + memset(&ssmd, 0, sizeof(ssmd)); + ssmd.subdivType = ME_CC_SUBSURF; //catmull clark + ssmd.levels = smd->subsurfLevels; //levels + + ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0); + + if(ss_mesh) + { + calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT); + if(calc.vert) + { + //TRICKY: this code assumes subsurface will have the transformed original vertices + //in their original order at the end of the vert array. + calc.vert = calc.vert + ss_mesh->getNumVerts(ss_mesh) - dm->getNumVerts(dm); + } + } + + //Just to make sure we are not letting any memory behind + assert(ssmd.emCache == NULL); + assert(ssmd.mCache == NULL); + } + } + //Projecting target defined - lets work! if(calc.target) { @@ -207,8 +244,8 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM } //free memory - if(calc.target) - calc.target->release( calc.target ); + if(ss_mesh) + ss_mesh->release(ss_mesh); } /* @@ -244,8 +281,17 @@ void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); if(weight == 0.0f) continue; - VECCOPY(tmp_co, co); - space_transform_apply(&calc->local2target, tmp_co); //Convert the coordinates to the tree coordinates + + //Convert the vertex to tree coordinates + if(calc->vert) + { + VECCOPY(tmp_co, calc->vert[i].co); + } + else + { + VECCOPY(tmp_co, co); + } + space_transform_apply(&calc->local2target, tmp_co); //Use local proximity heuristics (to reduce the nearest search) // @@ -348,172 +394,115 @@ void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) int i; //Options about projection direction - const char use_normal = calc->smd->shrinkOpts; - float proj_axis[3] = {0.0f, 0.0f, 0.0f}; - MVert *vert = NULL; //Needed in case of vertex normal - DerivedMesh* ss_mesh = NULL; + const char use_normal = calc->smd->shrinkOpts; + float proj_axis[3] = {0.0f, 0.0f, 0.0f}; //Raycast and tree stuff BVHTreeRayHit hit; - BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; //target + BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh; //auxiliar target - DerivedMesh * aux_mesh = NULL; - BVHTreeFromMesh auxData= NULL_BVHTreeFromMesh; + DerivedMesh *auxMesh = NULL; + BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh; SpaceTransform local2aux; -do -{ + //If the user doesn't allows to project in any direction of projection axis + //then theres nothing todo. + if((use_normal & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0) + return; + //Prepare data to retrieve the direction in which we should project each vertex if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) { - //No Mvert information: jump to "free memory and return" part - if(calc->original == NULL) break; - - if(calc->smd->subsurfLevels) - { - SubsurfModifierData smd; - memset(&smd, 0, sizeof(smd)); - smd.subdivType = ME_CC_SUBSURF; //catmull clark - smd.levels = calc->smd->subsurfLevels; //levels - - ss_mesh = subsurf_make_derived_from_derived(calc->original, &smd, FALSE, NULL, 0, 0); - - if(ss_mesh) - { - vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT); - if(vert) - { - //TRICKY: this code assumes subsurface will have the transformed original vertices - //in their original order at the end of the vert array. - vert = vert - + ss_mesh->getNumVerts(ss_mesh) - - calc->original->getNumVerts(calc->original); - } - } - - //To make sure we are not letting any memory behind - assert(smd.emCache == NULL); - assert(smd.mCache == NULL); - } - else - vert = calc->original->getVertDataArray(calc->original, CD_MVERT); - - //Not able to get vert information: jump to "free memory and return" part - if(vert == NULL) break; + if(calc->vert == NULL) return; } else { - //The code supports any axis that is a combination of X,Y,Z.. altought currently UI only allows to set the 3 diferent axis + //The code supports any axis that is a combination of X,Y,Z + //altought currently UI only allows to set the 3 diferent axis if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) proj_axis[0] = 1.0f; if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f; if(calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f; Normalize(proj_axis); - //Invalid projection direction: jump to "free memory and return" part - if(INPR(proj_axis, proj_axis) < FLT_EPSILON) break; + //Invalid projection direction + if(INPR(proj_axis, proj_axis) < FLT_EPSILON) + return; } - //If the user doesn't allows to project in any direction of projection axis... then theres nothing todo. - if((use_normal & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0) - break; //jump to "free memory and return" part - - - //Build target tree - BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, calc->keepDist, 4, 6)); - if(treeData.tree == NULL) - break; //jump to "free memory and return" part - - - //Build auxiliar target if(calc->smd->auxTarget) { + auxMesh = object_get_derived_final(calc->smd->auxTarget, CD_MASK_BAREMESH); space_transform_setup( &local2aux, calc->ob, calc->smd->auxTarget); - - aux_mesh = CDDM_copy( object_get_derived_final(calc->smd->auxTarget, CD_MASK_BAREMESH) ); //TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array - if(aux_mesh) - BENCH(bvhtree_from_mesh_faces(&auxData, aux_mesh, 0.0, 4, 6)); - else - printf("Auxiliar target finalDerived mesh is null\n"); } - - //Now, everything is ready to project the vertexs! -#pragma omp parallel for private(i,hit) schedule(static) - for(i = 0; inumVerts; ++i) + //After sucessufuly build the trees, start projection vertexs + if( bvhtree_from_mesh_faces(&treeData, calc->target, calc->keepDist, 4, 6) + && (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6))) { - float *co = calc->vertexCos[i]; - float tmp_co[3], tmp_no[3]; - float lim = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isnt prepared for that - float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); - - if(weight == 0.0f) continue; - if(ss_mesh) - { - VECCOPY(tmp_co, vert[i].co); - } - else +#pragma omp parallel for private(i,hit) schedule(static) + for(i = 0; inumVerts; ++i) { - VECCOPY(tmp_co, co); - } + float *co = calc->vertexCos[i]; + float tmp_co[3], tmp_no[3]; + float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); + if(weight == 0.0f) continue; - if(vert) - NormalShortToFloat(tmp_no, vert[i].no); - else - VECCOPY( tmp_no, proj_axis ); - + if(calc->vert) + { + VECCOPY(tmp_co, calc->vert[i].co); + if(calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) + NormalShortToFloat(tmp_no, calc->vert[i].no); + else + VECCOPY(tmp_no, proj_axis); + } + else + { + VECCOPY(tmp_co, co); + VECCOPY(tmp_no, proj_axis); + } - hit.index = -1; - hit.dist = lim; + hit.index = -1; + hit.dist = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isnt prepared for that - //Project over positive direction of axis - if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) - { + //Project over positive direction of axis + if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) + { - if(auxData.tree) - normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); + if(auxData.tree) + normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); - normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); - } + normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); + } - //Project over negative direction of axis - if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR) - { - float inv_no[3] = { -tmp_no[0], -tmp_no[1], -tmp_no[2] }; + //Project over negative direction of axis + if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR) + { + float inv_no[3] = { -tmp_no[0], -tmp_no[1], -tmp_no[2] }; - if(auxData.tree) - normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); + if(auxData.tree) + normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); - normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); - } + normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); + } - if(hit.index != -1) - { - VecLerpf(co, co, hit.co, weight); + if(hit.index != -1) + { + VecLerpf(co, co, hit.co, weight); + } } } - -//Simple do{} while(0) structure to allow to easily jump to the "free memory and return" part -} while(0); - //free data structures - free_bvhtree_from_mesh(&treeData); free_bvhtree_from_mesh(&auxData); - - if(aux_mesh) - aux_mesh->release(aux_mesh); - - if(ss_mesh) - ss_mesh->release(ss_mesh); } /* @@ -529,8 +518,6 @@ void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; BVHTreeNearest nearest = NULL_BVHTreeNearest; - - //Create a bvh-tree of the given target BENCH(bvhtree_from_mesh_faces( &treeData, calc->target, 0.0, 2, 6)); if(treeData.tree == NULL) @@ -554,7 +541,14 @@ void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) if(weight == 0.0f) continue; //Convert the vertex to tree coordinates - VECCOPY(tmp_co, co); + if(calc->vert) + { + VECCOPY(tmp_co, calc->vert[i].co); + } + else + { + VECCOPY(tmp_co, co); + } space_transform_apply(&calc->local2target, tmp_co); //Use local proximity heuristics (to reduce the nearest search) @@ -593,7 +587,6 @@ void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) } } - free_bvhtree_from_mesh(&treeData); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c3a355160e0..c88e06a9993 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1850,6 +1850,13 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) data->tar = newlibadr(fd, id->lib, data->tar); } break; + case CONSTRAINT_TYPE_SHRINKWRAP: + { + bShrinkwrapConstraint *data; + data= ((bShrinkwrapConstraint*)con->data); + data->target = newlibadr(fd, id->lib, data->target); + } + break; case CONSTRAINT_TYPE_NULL: break; } @@ -8633,6 +8640,12 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb) expand_doit(fd, mainvar, data->tar); } break; + case CONSTRAINT_TYPE_SHRINKWRAP: + { + bShrinkwrapConstraint *data = (bShrinkwrapConstraint*)curcon->data; + expand_doit(fd, mainvar, data->target); + } + break; default: break; } diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 868d0c3e6c0..8a9c1933c97 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -729,6 +729,7 @@ enum { B_CONSTRAINT_ADD_PYTHON, B_CONSTRAINT_ADD_CLAMPTO, B_CONSTRAINT_ADD_TRANSFORM, + B_CONSTRAINT_ADD_SHRINKWRAP, B_CONSTRAINT_INF }; diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index fe19cf60f12..79f032d0d21 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -317,6 +317,15 @@ typedef struct bDistLimitConstraint { int pad; } bDistLimitConstraint; +typedef struct bShrinkwrapConstraint { + Object *target; + float dist; /* distance to kept from target */ + short shrinkType; /* shrink type (look on MOD shrinkwrap for values) */ + char projAxis; /* axis to project over UP_X, UP_Y, UP_Z */ + char pad[9]; +} bShrinkwrapConstraint; + + /* ------------------------------------------ */ /* bConstraint->type @@ -344,10 +353,11 @@ typedef enum B_CONSTAINT_TYPES { CONSTRAINT_TYPE_RIGIDBODYJOINT, /* rigidbody constraint */ CONSTRAINT_TYPE_CLAMPTO, /* clampto constraint */ CONSTRAINT_TYPE_TRANSFORM, /* transformation (loc/rot/size -> loc/rot/size) constraint */ + CONSTRAINT_TYPE_SHRINKWRAP, /* shrinkwrap (loc/rot) constraint */ /* NOTE: everytime a new constraint is added, update this */ - NUM_CONSTRAINT_TYPES= CONSTRAINT_TYPE_TRANSFORM + NUM_CONSTRAINT_TYPES= CONSTRAINT_TYPE_SHRINKWRAP } B_CONSTRAINT_TYPES; /* bConstraint->flag */ diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 779909ec713..1ecc63fe93d 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1735,6 +1735,7 @@ static int modifier_is_fluid_particles(ModifierData *md) { } return 0; } + static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco, int *yco, int index, int cageIndex, int lastCageIndex) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -1903,12 +1904,10 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco height = 94; } else if (md->type==eModifierType_Shrinkwrap) { ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; - height = 86 + 3; + height = 105 + 3; + if (smd->shrinkType == MOD_SHRINKWRAP_PROJECT) - { height += 19*5; - if(smd->projAxis == 0) height += 19; - } else if (smd->shrinkType == MOD_SHRINKWRAP_NEAREST_SURFACE) height += 19; } else if (md->type == eModifierType_Mask) { @@ -2596,16 +2595,14 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco cy -= 3; uiDefButS(block, MENU, B_MODIFIER_RECALC, shrinktypemenu, lx,(cy-=19),buttonWidth,19, &smd->shrinkType, 0, 0, 0, 0, "Selects type of shrinkwrap algorithm for target position."); + uiDefButC(block, NUM, B_MODIFIER_RECALC, "SS Levels:", lx, (cy-=19), buttonWidth,19, &smd->subsurfLevels, 0, 6, 0, 0, "This indicates the number of CCSubdivisions that must be performed before extracting vertexs positions and normals"); + if (smd->shrinkType == MOD_SHRINKWRAP_PROJECT){ /* UI for projection axis */ uiBlockBeginAlign(block); uiDefButC(block, ROW, B_MODIFIER_RECALC, "Normal" , lx,(cy-=19),buttonWidth,19, &smd->projAxis, 18.0, MOD_SHRINKWRAP_PROJECT_OVER_NORMAL, 0, 0, "Projection over X axis"); - if(smd->projAxis == 0) - { - uiDefButC(block, NUM, B_MODIFIER_RECALC, "SS Levels:", lx, (cy-=19), buttonWidth,19, &smd->subsurfLevels, 0, 6, 0, 0, "This indicates the number of CCSubdivisions that must be performed before extracting vertexs positions and normals"); - } uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS, B_MODIFIER_RECALC, "X", lx+buttonWidth/3*0,(cy-=19),buttonWidth/3,19, &smd->projAxis, 0, 0, 0, 0, "Projection over X axis"); uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS, B_MODIFIER_RECALC, "Y", lx+buttonWidth/3*1,cy,buttonWidth/3,19, &smd->projAxis, 0, 0, 0, 0, "Projection over Y axis"); @@ -6971,3 +6968,4 @@ void editing_panels() } uiClearButLock(); } + diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 7161bc8c266..a41f954c4d8 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -1752,6 +1752,37 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); } break; + + case CONSTRAINT_TYPE_SHRINKWRAP: + { + bShrinkwrapConstraint *data = con->data; + + height = 78; + if(data->shrinkType == MOD_SHRINKWRAP_PROJECT) + height += 18; + + uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); + + /* Draw parameters */ + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefIDPoinBut(block, test_meshobpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->target, "Target Object"); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Dist:", *xco + 75, *yco-42, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+120, *yco-42, 135, 18, &data->dist, -100.0f, 100.0f, 1.0f, 0.0f, "Distance to target"); + + uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Type:", *xco + 70, *yco-60, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButS(block, MENU, B_MODIFIER_RECALC, "Shrinkwrap Type%t|Nearest Surface Point %x0|Projection %x1|Nearest Vertex %x2", *xco+120, *yco-60, 135, 18, &data->shrinkType, 0, 0, 0, 0, "Selects type of shrinkwrap algorithm for target position."); + + if(data->shrinkType == MOD_SHRINKWRAP_PROJECT) + { + /* Draw XYZ toggles */ + uiDefBut(block, LABEL,B_CONSTRAINT_TEST, "Axis:", *xco+ 75, *yco-78, 90, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); + uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS, B_CONSTRAINT_TEST, "X",*xco+120, *yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over X axis"); + uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS, B_CONSTRAINT_TEST, "Y",*xco+165, *yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over Y axis"); + uiDefButBitC(block, TOG, MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS, B_CONSTRAINT_TEST, "Z",*xco+210, *yco-78, 45, 18, &data->projAxis, 0, 0, 0, 0, "Projection over Z axis"); + } + } + break; default: height = 0; break; @@ -1813,6 +1844,7 @@ static uiBlock *add_constraintmenu(void *arg_unused) uiDefBut(block, BUTM, B_CONSTRAINT_ADD_MINMAX, "Floor", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, ""); uiDefBut(block, BUTM, B_CONSTRAINT_ADD_LOCKTRACK, "Locked Track", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, ""); uiDefBut(block, BUTM, B_CONSTRAINT_ADD_FOLLOWPATH, "Follow Path", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, B_CONSTRAINT_ADD_SHRINKWRAP, "Shrinkwrap" , 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 0, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, 120, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -2049,6 +2081,14 @@ void do_constraintbuts(unsigned short event) BIF_undo_push("Add constraint"); } break; + case B_CONSTRAINT_ADD_SHRINKWRAP: + { + con = add_new_constraint(CONSTRAINT_TYPE_SHRINKWRAP); + add_constraint_to_active(ob, con); + + BIF_undo_push("Add constraint"); + } + break; default: break; diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c index 42972e4aa5d..865bf1ba29d 100644 --- a/source/blender/src/editconstraint.c +++ b/source/blender/src/editconstraint.c @@ -366,6 +366,8 @@ void add_constraint (short only_IK) nr= pupmenu("Add Constraint to Active Bone%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Stretch To%x7|%l|Action%x16|Script%x18"); else if ((obsel) && (obsel->type==OB_CURVE)) nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Follow Path%x6|Clamp To%x17|Stretch To%x7|%l|Action%x16|Script%x18"); + else if ((obsel) && (obsel->type==OB_MESH)) + nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Shrinkwrap%x22|Stretch To%x7|%l|Action%x16|Script%x18"); else if (obsel) nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Stretch To%x7|%l|Action%x16|Script%x18"); else @@ -374,6 +376,8 @@ void add_constraint (short only_IK) else { if ((obsel) && (obsel->type==OB_CURVE)) nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Follow Path%x6|Clamp To%x17|%l|Action%x16|Script%x18"); + else if ((obsel) && (obsel->type==OB_MESH)) + nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Shrinkwrap%x22|%l|Action%x16|Script%x18"); else if (obsel) nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|%l|Action%x16|Script%x18"); else @@ -476,6 +480,7 @@ void add_constraint (short only_IK) } else if (nr==20) con = add_new_constraint(CONSTRAINT_TYPE_TRANSFORM); else if (nr==21) con = add_new_constraint(CONSTRAINT_TYPE_DISTLIMIT); + else if (nr==22) con = add_new_constraint(CONSTRAINT_TYPE_SHRINKWRAP); if (con==NULL) return; /* paranoia */ -- cgit v1.2.3 From 32253dfaaf43751037d4dcabd834e812902d6538 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Apr 2009 06:24:47 +0000 Subject: bpy_internal_import.c should build with py2.3 now, also gave bpy_internal_import functions better names. --- source/blender/python/BPY_interface.c | 6 ++-- .../blender/python/api2_2x/bpy_internal_import.c | 33 +++++++++++++--------- .../blender/python/api2_2x/bpy_internal_import.h | 10 +++---- 3 files changed, 27 insertions(+), 22 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 3b539be7a95..ea3d6a54162 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -1276,7 +1276,7 @@ static int bpy_pydriver_create_dict(void) * Users can add their own functions to this module. */ if (G.f&G_DOSCRIPTLINKS) { int found; /* not used but needed as an arg */ - mod = importText("pydrivers", &found); /* can also use PyImport_Import() */ + mod = bpy_text_import("pydrivers", &found); /* can also use PyImport_Import() */ if (mod) { PyDict_SetItemString(d, "pydrivers", mod); PyDict_SetItemString(d, "p", mod); @@ -2831,7 +2831,7 @@ static void DoAllScriptsFromList( ListBase * list, short event ) static void init_ourImport( void ) { PyObject *m, *d; - PyObject *import = PyCFunction_New( bpy_import, NULL ); + PyObject *import = PyCFunction_New( bpy_import_meth, NULL ); m = PyImport_AddModule( "__builtin__" ); d = PyModule_GetDict( m ); @@ -2842,7 +2842,7 @@ static void init_ourImport( void ) static void init_ourReload( void ) { PyObject *m, *d; - PyObject *reload = PyCFunction_New( bpy_reload, NULL ); + PyObject *reload = PyCFunction_New( bpy_reload_meth, NULL ); m = PyImport_AddModule( "__builtin__" ); d = PyModule_GetDict( m ); diff --git a/source/blender/python/api2_2x/bpy_internal_import.c b/source/blender/python/api2_2x/bpy_internal_import.c index a62ae689f59..1e1454dcd5c 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.c +++ b/source/blender/python/api2_2x/bpy_internal_import.c @@ -56,7 +56,7 @@ void bpy_import_main_set(struct Main *maggie) } -PyObject *importText( char *name, int *found ) +PyObject *bpy_text_import( char *name, int *found ) { Text *text; char txtname[22]; /* 21+NULL */ @@ -103,7 +103,7 @@ PyObject *importText( char *name, int *found ) * find in-memory module and recompile */ -PyObject *reimportText( PyObject *module, int *found ) +PyObject *bpy_text_reimport( PyObject *module, int *found ) { Text *text; char *txtname; @@ -172,13 +172,13 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k int dummy_val; /* what does this do?*/ static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; - if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import", kwlist, + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import_meth", kwlist, &name, &globals, &locals, &fromlist, &dummy_val) ) return NULL; #else static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0}; - if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import", kwlist, + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import_meth", kwlist, &name, &globals, &locals, &fromlist ) ) return NULL; #endif @@ -192,7 +192,7 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k PyErr_Fetch( &exception, &err, &tb ); /* get the python error incase we cant import as blender text either */ /* importing from existing modules failed, see if we have this module as blender text */ - newmodule = importText( name, &found ); + newmodule = bpy_text_import( name, &found ); if( newmodule ) {/* found module as blender text, ignore above exception */ PyErr_Clear( ); @@ -228,7 +228,7 @@ static PyObject *blender_reload( PyObject * self, PyObject * args ) int found= 0; /* check for a module arg */ - if( !PyArg_ParseTuple( args, "O:bpy_reload", &module ) ) + if( !PyArg_ParseTuple( args, "O:bpy_reload_meth", &module ) ) return NULL; /* try reimporting from file */ @@ -239,7 +239,7 @@ static PyObject *blender_reload( PyObject * self, PyObject * args ) /* no file, try importing from memory */ PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ - newmodule = reimportText( module, &found ); + newmodule = bpy_text_reimport( module, &found ); if( newmodule ) {/* found module as blender text, ignore above exception */ PyErr_Clear( ); Py_XDECREF( exception ); @@ -262,8 +262,8 @@ static PyObject *blender_reload( PyObject * self, PyObject * args ) return newmodule; } -PyMethodDef bpy_import[] = { {"bpy_import", blender_import, METH_KEYWORDS, "blenders import"} }; -PyMethodDef bpy_reload[] = { {"bpy_reload", blender_reload, METH_VARARGS, "blenders reload"} }; +PyMethodDef bpy_import_meth[] = { {"bpy_import_meth", blender_import, METH_KEYWORDS, "blenders import"} }; +PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", blender_reload, METH_VARARGS, "blenders reload"} }; /* Clear user modules. @@ -284,20 +284,25 @@ PyMethodDef bpy_reload[] = { {"bpy_reload", blender_reload, METH_VARARGS, "blend #endif -void importClearUserModules(void) +void bpy_text_clear_modules(void) { - PyObject *modules= PySys_GetObject("modules"); + PyObject *modules= PySys_GetObject("modules"); char *fname; char *file_extension; /* looping over the dict */ PyObject *key, *value; - Py_ssize_t pos = 0; + int pos = 0; /* new list */ - PyObject *list= PyList_New(0); - + PyObject *list; + + if (modules==NULL) + return; /* should never happen but just incase */ + + list= PyList_New(0); + /* go over sys.modules and remove anything with a * sys.modukes[x].__file__ thats ends with a .py and has no path */ diff --git a/source/blender/python/api2_2x/bpy_internal_import.h b/source/blender/python/api2_2x/bpy_internal_import.h index 9d440406636..137818bb0db 100644 --- a/source/blender/python/api2_2x/bpy_internal_import.h +++ b/source/blender/python/api2_2x/bpy_internal_import.h @@ -35,11 +35,11 @@ #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ -PyObject *importText( char *name, int *found ); -PyObject *reimportText( PyObject *module, int *found ); -void importClearUserModules( void ); /* Clear user modules */ -extern PyMethodDef bpy_import[]; -extern PyMethodDef bpy_reload[]; +PyObject* bpy_text_import( char *name, int *found ); +PyObject* bpy_text_reimport( PyObject *module, int *found ); +void bpy_text_clear_modules( void ); /* Clear user modules */ +extern PyMethodDef bpy_import_meth[]; +extern PyMethodDef bpy_reload_meth[]; /* The game engine has its own Main struct, if this is set search this rather then G.main */ struct Main *bpy_import_main_get(void); -- cgit v1.2.3 From 0cda4903b1a6f8a94e45fef9847c5b3a5fe56890 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Apr 2009 02:33:14 +0000 Subject: [#18533] Little fix in Particle API doc from Alberto Santos (dnakhain) --- source/blender/python/api2_2x/doc/Particle.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/doc/Particle.py b/source/blender/python/api2_2x/doc/Particle.py index 9728c896904..6107f0bda2f 100644 --- a/source/blender/python/api2_2x/doc/Particle.py +++ b/source/blender/python/api2_2x/doc/Particle.py @@ -40,13 +40,25 @@ This module provides access to the B{Particle} in Blender. - LINE: Draw as lines - PATH: Draw pathes - OBJECT: Draw object - - GROUP: Draw goup + - GROUP: Draw group - BILLBOARD: Draw as billboard @type CHILDTYPE: readonly dictionary @var CHILDTYPE: Constant dict used for whith L{Particle.CHILDTYPE} - NONE: set no children - PARTICLES: set children born from particles - FACES: set children born from faces +@type CHILDKINK: readonly dictionary +@var CHILDKINK: Type of periodic offset on the path + - NOTHING: set no offset on the path + - CURL: set curl offset on the path + - RADIAL: set radial offset on the path + - WAVE: set wave offset on the path + - BRAID: set braid offset on the path +@type CHILDKINKAXIS: readonly dictionary +@var CHILDKINKAXIS: Which axis to use for offset + - X: set X axis for offset + - Y: set Y axis for offset + - Z: set Z axis for offset """ class Particle: -- cgit v1.2.3 From aed9f92734b043ac686ffc10c3374b4cd5ce3153 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Apr 2009 06:21:49 +0000 Subject: packing from the UV window with margin had a problem with feedback, so running again and again would give different results. Scale the margin by the combined area of all boxes to give predictable results. --- source/blender/src/parametrizer.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/parametrizer.c b/source/blender/src/parametrizer.c index 654113f5f0c..feb774b604a 100644 --- a/source/blender/src/parametrizer.c +++ b/source/blender/src/parametrizer.c @@ -4134,6 +4134,7 @@ void param_pack(ParamHandle *handle, float margin) PChart *chart; int i, unpacked=0; float trans[2]; + double area= 0.0; PHandle *phandle = (PHandle*)handle; @@ -4146,6 +4147,7 @@ void param_pack(ParamHandle *handle, float margin) /* we may not use all these boxes */ boxarray = MEM_mallocN( phandle->ncharts*sizeof(boxPack), "boxPack box"); + for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; @@ -4158,14 +4160,40 @@ void param_pack(ParamHandle *handle, float margin) p_chart_uv_bbox(chart, trans, chart->u.pack.size); - trans[0] = -(trans[0] - margin); - trans[1] = -(trans[1] - margin); + trans[0] = -trans[0]; + trans[1] = -trans[1]; p_chart_uv_translate(chart, trans); - box->w = (chart->u.pack.size[0] + trans[0]) + margin*2; - box->h = (chart->u.pack.size[1] + trans[1]) + margin*2; + box->w = chart->u.pack.size[0] + trans[0]; + box->h = chart->u.pack.size[1] + trans[1]; box->index = i; /* warning this index skips PCHART_NOPACK boxes */ + + if(margin>0.0f) + area += sqrt(box->w*box->h); + } + + if(margin>0.0f) { + /* multiply the margin by the area to give pradictable results not dependant on UV scale, + * ...Without using the area running pack multiple times also gives a bad feedback loop. + * multiply by 0.1 so the margin value from the UI can be from 0.0 to 1.0 but not give a massive margin */ + margin = (margin*(float)area) * 0.1; + unpacked= 0; + for (i = 0; i < phandle->ncharts; i++) { + chart = phandle->charts[i]; + + if (chart->flag & PCHART_NOPACK) { + unpacked++; + continue; + } + + box = boxarray+(i-unpacked); + trans[0] = margin * area; + trans[1] = margin * area; + p_chart_uv_translate(chart, trans); + box->w += (margin * area) *2; + box->h += (margin * area) *2; + } } boxPack2D(boxarray, phandle->ncharts-unpacked, &tot_width, &tot_height); -- cgit v1.2.3 From 80e40d504c457ed3041fed925a6b3f80f54dffe1 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 17 Apr 2009 10:38:10 +0000 Subject: bugfix #18287 Texture nodes hang when nodes have a cyclic case. Added a (temp?) provision to tag node->need_exec zero for cyclic nodes, and added check for this in texture nodes. There was also a bug in 'tag changed' for texture nodes, which not only tagged, but also called the tree exec (should not happen!). In general the texture exec needs recode; it doesn't use the stacks as provided per node, but recurses itself to previous nodes, giving problems like this. Node execs should only do their own bizz, the node system handles dependency and eval order nicely already. --- source/blender/blenkernel/intern/node.c | 39 ++++++++++++++++------ .../blender/nodes/intern/TEX_nodes/TEX_texture.c | 2 +- source/blender/nodes/intern/TEX_util.c | 9 ++++- 3 files changed, 38 insertions(+), 12 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 9a78f8ea02a..e4e5883b2d8 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1644,7 +1644,8 @@ void ntreeSolveOrder(bNodeTree *ntree) might be different for editor or for "real" use... */ } -/* should be callback! */ +/* Should be callback! */ +/* Do not call execs here */ void NodeTagChanged(bNodeTree *ntree, bNode *node) { if(ntree->type==NTREE_COMPOSIT) { @@ -1664,8 +1665,6 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node) } node->need_exec= 1; } - else if(ntree->type == NTREE_TEXTURE) - ntreeTexUpdatePreviews(ntree); } void NodeTagIDChanged(bNodeTree *ntree, ID *id) @@ -2067,6 +2066,11 @@ void ntreeBeginExecTree(bNodeTree *ntree) /* tag used outputs, so we know when we can skip operations */ for(node= ntree->nodes.first; node; node= node->next) { bNodeSocket *sock; + + /* composite has own need_exec tag handling */ + if(ntree->type!=NTREE_COMPOSIT) + node->need_exec= 1; + for(sock= node->inputs.first; sock; sock= sock->next) { if(sock->link) { ns= ntree->stack + sock->link->fromsock->stack_index; @@ -2075,9 +2079,22 @@ void ntreeBeginExecTree(bNodeTree *ntree) } else sock->ns.sockettype= sock->type; + + if(sock->link) { + bNodeLink *link= sock->link; + /* this is the test for a cyclic case */ + if(link->fromnode && link->tonode) { + if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF); + else { + node->need_exec= 0; + } + } + } } + if(node->type==NODE_GROUP && node->id) group_tag_used_outputs(node, ntree->stack); + } if(ntree->type==NTREE_COMPOSIT) @@ -2160,13 +2177,15 @@ void ntreeExecTree(bNodeTree *ntree, void *callerdata, int thread) } for(node= ntree->nodes.first; node; node= node->next) { - if(node->typeinfo->execfunc) { - node_get_stack(node, stack, nsin, nsout); - node->typeinfo->execfunc(callerdata, node, nsin, nsout); - } - else if(node->type==NODE_GROUP && node->id) { - node_get_stack(node, stack, nsin, nsout); - node_group_execute(stack, callerdata, node, nsin, nsout); + if(node->need_exec) { + if(node->typeinfo->execfunc) { + node_get_stack(node, stack, nsin, nsout); + node->typeinfo->execfunc(callerdata, node, nsin, nsout); + } + else if(node->type==NODE_GROUP && node->id) { + node_get_stack(node, stack, nsin, nsout); + node_group_execute(stack, callerdata, node, nsin, nsout); + } } } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c index 884d2cd0eb6..30492b84764 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c @@ -47,7 +47,7 @@ static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, shor Tex *nodetex = (Tex *)node->id; - if(node->custom2) { + if(node->custom2 || node->need_exec==0) { /* this node refers to its own texture tree! */ QUATCOPY( out, diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c index 562072328a8..1aabb7ae514 100644 --- a/source/blender/nodes/intern/TEX_util.c +++ b/source/blender/nodes/intern/TEX_util.c @@ -34,6 +34,12 @@ obtain a colour value from this, a node further up the chain reads the TexDelegate* from its input stack, and uses tex_call_delegate to retrieve the colour from the delegate. + + comments: (ton) + + This system needs recode, a node system should rely on the stack, and + callbacks for nodes only should evaluate own node, not recursively go + over other previous ones. */ #include @@ -43,7 +49,8 @@ void tex_call_delegate(TexDelegate *dg, float *out, float *coord, short thread) { - dg->fn(out, coord, dg->node, dg->in, thread); + if(dg->node->need_exec) + dg->fn(out, coord, dg->node, dg->in, thread); } void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread) -- cgit v1.2.3 From faef9f0ac77837fc0ff1ab305d68c102c4419ec9 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sat, 18 Apr 2009 17:16:08 +0000 Subject: SCons * some misc changes, mainly cleaning and style unification that were lying around --- source/blender/blenkernel/SConscript | 38 +++++++++++++------------ source/blender/nodes/SConscript | 30 ++++++++++---------- source/blender/python/SConscript | 9 ++++-- source/blender/src/SConscript | 54 +++++++++++++++++++----------------- 4 files changed, 70 insertions(+), 61 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index a7e4d8807b2..f68e2b70c86 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -15,56 +15,58 @@ incs += ' ../gpu #/extern/glew/include' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] -defs = '' +defs = [] if not env['WITH_BF_PYTHON']: - defs += 'DISABLE_PYTHON' + defs.append('DISABLE_PYTHON') else: incs += ' ../python' incs += ' ' + env['BF_PYTHON_INC'] + if env['BF_DEBUG']: + defs.append('_DEBUG') if env['WITH_BF_QUICKTIME']: - incs += ' ../quicktime' + incs += ' ../quicktime' if env['WITH_BF_SDL']: incs += ' ' + env['BF_SDL_INC'] else: - defs += ' DISABLE_SDL' + defs.append('DISABLE_SDL') if env['WITH_BF_INTERNATIONAL']: - defs += ' WITH_FREETYPE2' + defs.append('WITH_FREETYPE2') if env['WITH_BF_VERSE']: - defs += ' WITH_VERSE' + defs.append('WITH_VERSE') incs += ' ' + env['BF_VERSE_INCLUDE'] if env['WITH_BF_VERSE']: - defs += ' WITH_VERSE' + defs.append('WITH_VERSE') if env['WITH_BF_OPENEXR']: - defs += ' WITH_OPENEXR' + defs.append('WITH_OPENEXR') if env['WITH_BF_OPENJPEG']: - defs += ' WITH_OPENJPEG' + defs.append('WITH_OPENJPEG') if env['WITH_BF_DDS']: - defs += ' WITH_DDS' + defs.append('WITH_DDS') if env['WITH_BF_FFMPEG']: - defs += ' WITH_FFMPEG' - incs += ' ' + env['BF_FFMPEG_INC'] + defs.append('WITH_FFMPEG') + incs += ' ' + env['BF_FFMPEG_INC'] if env['WITH_BF_QUICKTIME']: - defs += ' WITH_QUICKTIME' - incs += ' ' + env['BF_QUICKTIME_INC'] + defs.append('WITH_QUICKTIME') + incs += ' ' + env['BF_QUICKTIME_INC'] if env['WITH_BF_BULLET']: - defs += ' WITH_BULLET' + defs.append('WITH_BULLET') if env['BF_NO_ELBEEM']: - defs += ' DISABLE_ELBEEM' + defs.append('DISABLE_ELBEEM') if env['WITH_BF_PLAYER']: - SConscript(['bad_level_call_stubs/SConscript']) + SConscript(['bad_level_call_stubs/SConscript']) -env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = Split(defs), libtype=['core','player'], priority = [65, 20] ) +env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [65, 20] ) diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript index d38303d7d20..bf8df8a9156 100644 --- a/source/blender/nodes/SConscript +++ b/source/blender/nodes/SConscript @@ -17,29 +17,31 @@ incs += ' ../gpu #/extern/glew/include ' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] -defs = '' +defs = [] if env['WITH_BF_PYTHON']: - incs += ' ' + env['BF_PYTHON_INC'] - incs += ' ../python' + incs += ' ' + env['BF_PYTHON_INC'] + incs += ' ../python' + if env['BF_DEBUG']: + defs.append('_DEBUG') else: - defs += 'DISABLE_PYTHON' + defs.append('DISABLE_PYTHON') if env['WITH_BF_INTERNATIONAL']: - defs += ' WITH_FREETYPE2' + defs.append('WITH_FREETYPE2') if env['WITH_BF_OPENEXR']: - defs += ' WITH_OPENEXR' + defs.append('WITH_OPENEXR') if env['WITH_BF_FFMPEG']: - defs += ' WITH_FFMPEG' - incs += ' ' + env['BF_FFMPEG_INC'] + defs.append('WITH_FFMPEG') + incs += ' ' + env['BF_FFMPEG_INC'] if env['WITH_BF_QUICKTIME']: - defs += ' WITH_QUICKTIME' - incs += ' ' + env['BF_QUICKTIME_INC'] + defs.append('WITH_QUICKTIME') + incs += ' ' + env['BF_QUICKTIME_INC'] -env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = Split(defs), libtype=['intern', 'core', 'player'], priority = [200, 200, 400] ) -env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = Split(defs), libtype=['intern', 'core', 'player'], priority = [200, 175, 300] ) -env.BlenderLib ( libname = 'bf_shdnodes', sources = shdsources, includes = Split(incs), defines = Split(defs), libtype=['intern', 'core', 'player'], priority = [200, 175, 300] ) -env.BlenderLib ( libname = 'bf_texnodes', sources = texsources, includes = Split(incs), defines = Split(defs), libtype=['intern', 'core', 'player'], priority = [200, 175, 300] ) +env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = defs, libtype=['intern', 'core', 'player'], priority = [200, 200, 400] ) +env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = defs, libtype=['intern', 'core', 'player'], priority = [200, 175, 300] ) +env.BlenderLib ( libname = 'bf_shdnodes', sources = shdsources, includes = Split(incs), defines = defs, libtype=['intern', 'core', 'player'], priority = [200, 175, 300] ) +env.BlenderLib ( libname = 'bf_texnodes', sources = texsources, includes = Split(incs), defines = defs, libtype=['intern', 'core', 'player'], priority = [200, 175, 300] ) diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index 670041a6504..e869cfba556 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -14,17 +14,20 @@ defs = [] if env['OURPLATFORM'] in ('win32-mingw') and env['BF_DEBUG']: defs.append('Py_TRACE_REFS') +if env['BF_DEBUG']: + defs.append('_DEBUG') + if env['WITH_BF_QUICKTIME']: incs += ' ' + env['BF_QUICKTIME_INC'] defs.append('WITH_QUICKTIME') if env['WITH_BF_OPENEXR']: - defs.append('WITH_OPENEXR') + defs.append('WITH_OPENEXR') if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') + defs.append('WITH_FFMPEG') if env['BF_BUILDINFO']: - defs.append('NAN_BUILDINFO') + defs.append('NAN_BUILDINFO') env.BlenderLib ( libname='blender_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype=['core','game2'], priority = [60,115] ) diff --git a/source/blender/src/SConscript b/source/blender/src/SConscript index 2e5dda6c772..ff6db036459 100644 --- a/source/blender/src/SConscript +++ b/source/blender/src/SConscript @@ -34,39 +34,41 @@ incs += ' ' + env['BF_OPENGL_INC'] defs = [] if env['WITH_BF_PYTHON']: - incs += ' ../python ' + env['BF_PYTHON_INC'] + incs += ' ../python ' + env['BF_PYTHON_INC'] + if env['BF_DEBUG']: + defs.append('_DEBUG') else: - defs.append('DISABLE_PYTHON') + defs.append('DISABLE_PYTHON') if env['BF_TWEAK_MODE']: - defs.append('TWEAK_MODE') + defs.append('TWEAK_MODE') if not env['WITH_BF_YAFRAY']: - defs.append('DISABLE_YAFRAY') + defs.append('DISABLE_YAFRAY') if env['WITH_BF_INTERNATIONAL']: - incs += ' ../ftfont' - defs.append('INTERNATIONAL') - defs.append('FTGL_STATIC_LIBRARY') + incs += ' ../ftfont' + defs.append('INTERNATIONAL') + defs.append('FTGL_STATIC_LIBRARY') if env['WITH_BF_OPENEXR']: - defs.append('WITH_OPENEXR') + defs.append('WITH_OPENEXR') if env['WITH_BF_OPENJPEG']: - defs.append('WITH_OPENJPEG') + defs.append('WITH_OPENJPEG') if env['WITH_BF_DDS']: - defs.append('WITH_DDS') + defs.append('WITH_DDS') if env['WITH_BF_QUICKTIME']: - incs += ' ' + env['BF_QUICKTIME_INC'] - defs.append('WITH_QUICKTIME') + incs += ' ' + env['BF_QUICKTIME_INC'] + defs.append('WITH_QUICKTIME') if env['WITH_BF_ICONV']: - incs += ' ../quicktime' - incs += ' ' + env['BF_ICONV_INC'] - defs.append('WITH_ICONV') + incs += ' ../quicktime' + incs += ' ' + env['BF_ICONV_INC'] + defs.append('WITH_ICONV') if env['WITH_BF_GAMEENGINE']: defs.append('GAMEBLENDER=1') @@ -74,33 +76,33 @@ if env['WITH_BF_GAMEENGINE']: defs.append('USE_SUMO_SOLID') if env['WITH_BF_FFMPEG']: - defs.append('WITH_FFMPEG') - incs += ' ' + env['BF_FFMPEG_INC'] + defs.append('WITH_FFMPEG') + incs += ' ' + env['BF_FFMPEG_INC'] if env['WITH_BF_OGG']: - defs.append('WITH_OGG') + defs.append('WITH_OGG') if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross'): - incs += ' ' + env['BF_PTHREADS_INC'] + incs += ' ' + env['BF_PTHREADS_INC'] if env['WITH_BF_VERSE']: - defs.append('WITH_VERSE') - incs += ' ' + env['BF_VERSE_INCLUDE'] + defs.append('WITH_VERSE') + incs += ' ' + env['BF_VERSE_INCLUDE'] # TODO buildinfo if env['BF_BUILDINFO']: - defs.append('NAN_BUILDINFO') + defs.append('NAN_BUILDINFO') if env['BF_NO_ELBEEM']: - defs.append('DISABLE_ELBEEM') + defs.append('DISABLE_ELBEEM') if env['WITH_BF_SDL']: - incs += ' ' + env['BF_SDL_INC'] + incs += ' ' + env['BF_SDL_INC'] else: - defs.append('DISABLE_SDL') + defs.append('DISABLE_SDL') if env['WITH_BF_BULLET']: - defs.append('WITH_BULLET') + defs.append('WITH_BULLET') if env['BF_SPLIT_SRC'] and (env['OURPLATFORM'] == 'win32-mingw'): for i in range(numlibs): -- cgit v1.2.3 From e4611218abf717c4d0790f22cc4f44e002380b5c Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 19 Apr 2009 00:09:47 +0000 Subject: BPy * access to sample buffers count of Lamp --- source/blender/python/api2_2x/Lamp.c | 28 ++++++++++++++++++++++++++++ source/blender/python/api2_2x/doc/Lamp.py | 3 +++ 2 files changed, 31 insertions(+) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 799833d4ee0..3b7a785f32e 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -191,6 +191,7 @@ static PyObject *Lamp_getTypesConst( void ); static PyObject *Lamp_getMode( BPy_Lamp * self ); static PyObject *Lamp_getModesConst( void ); static PyObject *Lamp_getSamples( BPy_Lamp * self ); +static PyObject *Lamp_getSampleBuffers( BPy_Lamp * self ); static PyObject *Lamp_getRaySamplesX( BPy_Lamp * self ); static PyObject *Lamp_getRaySamplesY( BPy_Lamp * self ); static PyObject *Lamp_getAreaSizeX( BPy_Lamp * self ); @@ -241,6 +242,7 @@ static int Lamp_setIpo( BPy_Lamp * self, PyObject * args ); static int Lamp_setType( BPy_Lamp * self, PyObject * args ); static int Lamp_setMode( BPy_Lamp * self, PyObject * args ); static int Lamp_setSamples( BPy_Lamp * self, PyObject * args ); +static int Lamp_setSampleBuffers( BPy_Lamp * self, PyObject * args ); static int Lamp_setRaySamplesX( BPy_Lamp * self, PyObject * args ); static int Lamp_setRaySamplesY( BPy_Lamp * self, PyObject * args ); static int Lamp_setAreaSizeX( BPy_Lamp * self, PyObject * args ); @@ -447,6 +449,10 @@ static PyGetSetDef BPy_Lamp_getseters[] = { (getter)Lamp_getSamples, (setter)Lamp_setSamples, "Lamp shadow map samples", NULL}, + {"sampleBuffers", + (getter)Lamp_getSampleBuffers, (setter)Lamp_setSampleBuffers, + "Lamp shadow samples buffers", + NULL}, {"raySamplesX", (getter)Lamp_getRaySamplesX, (setter)Lamp_setRaySamplesX, "Lamp raytracing samples on the X axis", @@ -923,6 +929,11 @@ static PyObject *Lamp_getSamples( BPy_Lamp * self ) return PyInt_FromLong( self->lamp->samp ); } +static PyObject *Lamp_getSampleBuffers( BPy_Lamp * self ) +{ + return PyInt_FromLong( self->lamp->buffers ); +} + static PyObject *Lamp_getRaySamplesX( BPy_Lamp * self ) { return PyInt_FromLong( self->lamp->ray_samp ); @@ -1063,6 +1074,23 @@ static int Lamp_setSamples( BPy_Lamp * self, PyObject * value ) EXPP_LAMP_SAMPLES_MAX, 'h' ); } +static int Lamp_setSampleBuffers( BPy_Lamp * self, PyObject * value ) +{ + int buffers= 1; + if( !PyInt_Check ( value ) ) { + return EXPP_ReturnIntError( PyExc_TypeError, "expected int argument" ); + } + buffers= PyInt_AS_LONG(value); + + if(buffers!=1 && buffers!=4 && buffers!=9) { + return EXPP_ReturnIntError( PyExc_TypeError, + "expected int argument of value 1, 4 or 9" ); + } + + self->lamp->buffers= buffers; + + return 0; +} static int Lamp_setRaySamplesX( BPy_Lamp * self, PyObject * value ) { diff --git a/source/blender/python/api2_2x/doc/Lamp.py b/source/blender/python/api2_2x/doc/Lamp.py index 162d94ccff3..878ca53bb15 100644 --- a/source/blender/python/api2_2x/doc/Lamp.py +++ b/source/blender/python/api2_2x/doc/Lamp.py @@ -136,6 +136,9 @@ class Lamp: @ivar samples: Lamp shadow map samples. Value is clamped to the range [1,16]. @type samples: int + @ivar sampleBuffers: Lamp amount of shadow map sample buffers. + Number of sample buffers for shadow buffer: 1, 4 or 9. + @type sampleBuffers: int @ivar raySamplesX: Lamp raytracing X samples (X is used for the Y axis with square area lamps). Value is clamped to the range [1,16]. @type raySamplesX: int -- cgit v1.2.3 From 904483c96c6adb5dc7976e676d8bb393232eed14 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Sun, 19 Apr 2009 17:47:09 +0000 Subject: Booleans: Should work with modifier stack now. Please report (new) problems. Thanks --- source/blender/blenkernel/BKE_bad_level_calls.h | 4 +- source/blender/blenkernel/BKE_booleanops.h | 5 +- .../blenkernel/bad_level_call_stubs/stubs.c | 3 +- source/blender/blenkernel/intern/modifier.c | 33 +++++- source/blender/src/booleanops.c | 122 +++++++++++---------- 5 files changed, 100 insertions(+), 67 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_bad_level_calls.h b/source/blender/blenkernel/BKE_bad_level_calls.h index 93bfb2339be..0962a174a8e 100644 --- a/source/blender/blenkernel/BKE_bad_level_calls.h +++ b/source/blender/blenkernel/BKE_bad_level_calls.h @@ -160,8 +160,8 @@ void bglEnd(void); struct Object; /* booleanops.c */ -struct DerivedMesh *NewBooleanDerivedMesh(struct Object *ob, - struct Object *ob_select, int int_op_type); +struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm_select, struct Object *ob_select, + int int_op_type); /* verse_*.c */ struct VerseVert; diff --git a/source/blender/blenkernel/BKE_booleanops.h b/source/blender/blenkernel/BKE_booleanops.h index b83b9c89ae8..118066e3806 100644 --- a/source/blender/blenkernel/BKE_booleanops.h +++ b/source/blender/blenkernel/BKE_booleanops.h @@ -42,8 +42,7 @@ int NewBooleanMesh(struct Base *base, struct Base *base_select, int op); /* Performs a boolean between two mesh objects, it is assumed that both objects are in fact mesh object. On success returns a DerivedMesh. On failure returns NULL and reports an error. */ -struct DerivedMesh *NewBooleanDerivedMesh(struct Object *ob, - struct Object *ob_select, - int op); +struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm_select, struct Object *ob_select, + int int_op_type); #endif diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index fecead66bda..5f6472ce56e 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -240,7 +240,8 @@ void bglVertex3f(float x, float y, float z) {} void bglEnd(void) {} /* booleanops.c */ -struct DerivedMesh *NewBooleanDerivedMesh(struct Object *ob, struct Object *ob_select, int int_op_type) { return 0; } +struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm_select, struct Object *ob_select, + int int_op_type) { return 0; } /* LOD_decimation.cpp */ int LOD_LoadMesh(struct LOD_Decimation_Info* info) { return 0;}; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 1068950d0d6..65bbbdfbcfb 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6140,22 +6140,44 @@ static DerivedMesh *booleanModifier_applyModifier( { // XXX doesn't handle derived data BooleanModifierData *bmd = (BooleanModifierData*) md; + DerivedMesh *dm = mesh_get_derived_final(bmd->object, CD_MASK_BAREMESH); /* we do a quick sanity check */ - if(((Mesh *)ob->data)->totface > 3 - && bmd->object && ((Mesh *)bmd->object->data)->totface > 3) { - DerivedMesh *result = NewBooleanDerivedMesh(bmd->object, ob, + if(derivedData->getNumFaces(derivedData) > 3 + && bmd->object && dm->getNumFaces(dm) > 3) { + DerivedMesh *result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, 1 + bmd->operation); + if(dm) + dm->release(dm); + /* if new mesh returned, return it; otherwise there was * an error, so delete the modifier object */ if(result) return result; else bmd->object = NULL; - } + } + + if(dm) + dm->release(dm); + + return derivedData; +} + +CustomDataMask booleanModifier_requiredDataMask(ModifierData *md) +{ + CustomDataMask dataMask = (1 << CD_MTFACE) + (1 << CD_MEDGE); - return derivedData; + dataMask |= (1 << CD_MDEFORMVERT); + + /* particles only need this if they are after a non deform modifier, and + * the modifier stack will only create them in that case. */ +// dataMask |= CD_MASK_ORIGSPACE; + +// dataMask |= CD_MASK_ORCO; + + return dataMask; } /* Particles */ @@ -8311,6 +8333,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->applyModifier = booleanModifier_applyModifier; mti->foreachObjectLink = booleanModifier_foreachObjectLink; mti->updateDepgraph = booleanModifier_updateDepgraph; + mti->requiredDataMask = booleanModifier_requiredDataMask; mti = INIT_TYPE(MeshDeform); mti->type = eModifierTypeType_OnlyDeform; diff --git a/source/blender/src/booleanops.c b/source/blender/src/booleanops.c index 14766d1f746..948797014a4 100644 --- a/source/blender/src/booleanops.c +++ b/source/blender/src/booleanops.c @@ -68,7 +68,7 @@ */ typedef struct { - Mesh *mesh; + DerivedMesh *dm; Object *ob; int pos; } VertexIt; @@ -96,13 +96,13 @@ static void VertexIt_Destruct(CSG_VertexIteratorDescriptor * iterator) static int VertexIt_Done(CSG_IteratorPtr it) { VertexIt * iterator = (VertexIt *)it; - return(iterator->pos >= iterator->mesh->totvert); + return(iterator->pos >= iterator->dm->getNumVerts(iterator->dm)); } static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) { VertexIt * iterator = (VertexIt *)it; - MVert *verts = iterator->mesh->mvert; + MVert *verts = iterator->dm->getVertArray(iterator->dm); float global_pos[3]; @@ -130,7 +130,7 @@ static void VertexIt_Reset(CSG_IteratorPtr it) iterator->pos = 0; } -static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, Object *ob) +static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh *dm, Object *ob) { VertexIt *it; @@ -142,8 +142,8 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, Object *ob) return; } // assign blender specific variables - it->ob = ob; - it->mesh = ob->data; + it->dm = dm; + it->ob = ob; // needed for obmat transformations it->pos = 0; @@ -152,7 +152,7 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, Object *ob) output->Fill = VertexIt_Fill; output->Done = VertexIt_Done; output->Reset = VertexIt_Reset; - output->num_elements = it->mesh->totvert; + output->num_elements = it->dm->getNumVerts(it->dm); output->it = it; } @@ -161,7 +161,7 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, Object *ob) */ typedef struct { - Mesh *mesh; + DerivedMesh *dm; int pos; int offset; } FaceIt; @@ -180,14 +180,14 @@ static int FaceIt_Done(CSG_IteratorPtr it) { // assume CSG_IteratorPtr is of the correct type. FaceIt * iterator = (FaceIt *)it; - return(iterator->pos >= iterator->mesh->totface); + return(iterator->pos >= iterator->dm->getNumFaces(iterator->dm)); } static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) { // assume CSG_IteratorPtr is of the correct type. FaceIt *face_it = (FaceIt *)it; - MFace *mfaces = face_it->mesh->mface; + MFace *mfaces = face_it->dm->getFaceArray(face_it->dm); MFace *mface = &mfaces[face_it->pos]; face->vertex_index[0] = mface->v1; @@ -216,7 +216,7 @@ static void FaceIt_Reset(CSG_IteratorPtr it) } static void FaceIt_Construct( - CSG_FaceIteratorDescriptor *output, Object *ob, int offset) + CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset) { FaceIt *it; if (output == 0) return; @@ -227,7 +227,7 @@ static void FaceIt_Construct( return ; } // assign blender specific variables - it->mesh = ob->data; + it->dm = dm; it->offset = offset; it->pos = 0; @@ -236,7 +236,7 @@ static void FaceIt_Construct( output->Fill = FaceIt_Fill; output->Done = FaceIt_Done; output->Reset = FaceIt_Reset; - output->num_elements = it->mesh->totface; + output->num_elements = it->dm->getNumFaces(it->dm); output->it = it; } @@ -280,7 +280,7 @@ static Object *AddNewBlenderMesh(Base *base) } static void InterpCSGFace( - DerivedMesh *dm, Mesh *orig_me, int index, int orig_index, int nr, + DerivedMesh *dm, DerivedMesh *orig_dm, int index, int orig_index, int nr, float mapmat[][4]) { float obco[3], *co[4], *orig_co[4], w[4][4]; @@ -288,13 +288,13 @@ static void InterpCSGFace( int j; mface = CDDM_get_face(dm, index); - orig_mface = orig_me->mface + orig_index; + orig_mface = orig_dm->getFaceArray(orig_dm) + orig_index; // get the vertex coordinates from the original mesh - orig_co[0] = (orig_me->mvert + orig_mface->v1)->co; - orig_co[1] = (orig_me->mvert + orig_mface->v2)->co; - orig_co[2] = (orig_me->mvert + orig_mface->v3)->co; - orig_co[3] = (orig_mface->v4)? (orig_me->mvert + orig_mface->v4)->co: NULL; + orig_co[0] = (orig_dm->getVertArray(orig_dm) + orig_mface->v1)->co; + orig_co[1] = (orig_dm->getVertArray(orig_dm) + orig_mface->v2)->co; + orig_co[2] = (orig_dm->getVertArray(orig_dm) + orig_mface->v3)->co; + orig_co[3] = (orig_mface->v4)? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co: NULL; // get the vertex coordinates from the new derivedmesh co[0] = CDDM_get_vert(dm, mface->v1)->co; @@ -312,7 +312,7 @@ static void InterpCSGFace( InterpWeightsQ3Dfl(orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco, w[j]); } - CustomData_interp(&orig_me->fdata, &dm->faceData, &orig_index, NULL, (float*)w, 1, index); + CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index); } /* Iterate over the CSG Output Descriptors and create a new DerivedMesh @@ -324,27 +324,28 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( float mapmat[][4], Material **mat, int *totmat, + DerivedMesh *dm1, Object *ob1, + DerivedMesh *dm2, Object *ob2) { - DerivedMesh *dm; + DerivedMesh *result, *orig_dm; GHash *material_hash = NULL; Mesh *me1= (Mesh*)ob1->data; Mesh *me2= (Mesh*)ob2->data; int i; // create a new DerivedMesh - dm = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements); - - CustomData_merge(&me1->fdata, &dm->faceData, CD_MASK_DERIVEDMESH, - CD_DEFAULT, face_it->num_elements); - CustomData_merge(&me2->fdata, &dm->faceData, CD_MASK_DERIVEDMESH, - CD_DEFAULT, face_it->num_elements); + result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements); + CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH, + CD_DEFAULT, face_it->num_elements); + CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH, + CD_DEFAULT, face_it->num_elements); // step through the vertex iterators: for (i = 0; !vertex_it->Done(vertex_it->it); i++) { CSG_IVertex csgvert; - MVert *mvert = CDDM_get_vert(dm, i); + MVert *mvert = CDDM_get_vert(result, i); // retrieve a csg vertex from the boolean module vertex_it->Fill(vertex_it->it, &csgvert); @@ -375,15 +376,16 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( face_it->Step(face_it->it); // find the original mesh and data - orig_ob = (csgface.orig_face < me1->totface)? ob1: ob2; + orig_ob = (csgface.orig_face < dm1->getNumFaces(dm1))? ob1: ob2; + orig_dm = (csgface.orig_face < dm1->getNumFaces(dm1))? dm1: dm2; orig_me = (orig_ob == ob1)? me1: me2; - orig_index = (orig_ob == ob1)? csgface.orig_face: csgface.orig_face - me1->totface; + orig_index = (orig_ob == ob1)? csgface.orig_face: csgface.orig_face - dm1->getNumFaces(dm1); // copy all face layers, including mface - CustomData_copy_data(&orig_me->fdata, &dm->faceData, orig_index, i, 1); + CustomData_copy_data(&orig_dm->faceData, &result->faceData, orig_index, i, 1); // set mface - mface = CDDM_get_face(dm, i); + mface = CDDM_get_face(result, i); mface->v1 = csgface.vertex_index[0]; mface->v2 = csgface.vertex_index[1]; mface->v3 = csgface.vertex_index[2]; @@ -404,29 +406,30 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( else mface->mat_nr = 0; - InterpCSGFace(dm, orig_me, i, orig_index, csgface.vertex_number, + InterpCSGFace(result, orig_dm, i, orig_index, csgface.vertex_number, (orig_me == me2)? mapmat: NULL); - test_index_face(mface, &dm->faceData, i, csgface.vertex_number); + test_index_face(mface, &result->faceData, i, csgface.vertex_number); } if (material_hash) BLI_ghash_free(material_hash, NULL, NULL); - CDDM_calc_edges(dm); - CDDM_calc_normals(dm); + CDDM_calc_edges(result); + CDDM_calc_normals(result); - return dm; + return result; } static void BuildMeshDescriptors( + struct DerivedMesh *dm, struct Object *ob, int face_offset, struct CSG_FaceIteratorDescriptor * face_it, struct CSG_VertexIteratorDescriptor * vertex_it) { - VertexIt_Construct(vertex_it,ob); - FaceIt_Construct(face_it,ob,face_offset); + VertexIt_Construct(vertex_it,dm, ob); + FaceIt_Construct(face_it,dm,face_offset); } static void FreeMeshDescriptors( @@ -438,19 +441,17 @@ static void FreeMeshDescriptors( } DerivedMesh *NewBooleanDerivedMesh_intern( - struct Object *ob, struct Object *ob_select, + DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, int int_op_type, Material **mat, int *totmat) { float inv_mat[4][4]; float map_mat[4][4]; - DerivedMesh *dm = NULL; - Mesh *me1 = get_mesh(ob_select); - Mesh *me2 = get_mesh(ob); + DerivedMesh *result = NULL; - if (me1 == NULL || me2 == NULL) return 0; - if (!me1->totface || !me2->totface) return 0; + if (dm == NULL || dm_select == NULL) return 0; + if (!dm->getNumFaces(dm) || !dm_select->getNumFaces(dm_select)) return 0; // we map the final object back into ob's local coordinate space. For this // we need to compute the inverse transform from global to ob (inv_mat), @@ -481,8 +482,8 @@ DerivedMesh *NewBooleanDerivedMesh_intern( default : op_type = e_csg_intersection; } - BuildMeshDescriptors(ob_select, 0, &fd_1, &vd_1); - BuildMeshDescriptors(ob, me1->totface, &fd_2, &vd_2); + BuildMeshDescriptors(dm_select, ob_select, 0, &fd_1, &vd_1); + BuildMeshDescriptors(dm, ob, dm_select->getNumFaces(dm_select) , &fd_2, &vd_2); bool_op = CSG_NewBooleanFunction(); @@ -496,8 +497,8 @@ DerivedMesh *NewBooleanDerivedMesh_intern( // iterate through results of operation and insert // into new object - dm = ConvertCSGDescriptorsToDerivedMesh( - &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, ob_select, ob); + result = ConvertCSGDescriptorsToDerivedMesh( + &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); // free up the memory CSG_FreeVertexDescriptor(&vd_o); @@ -512,7 +513,7 @@ DerivedMesh *NewBooleanDerivedMesh_intern( FreeMeshDescriptors(&fd_2, &vd_2); } - return dm; + return result; } int NewBooleanMesh(Base *base, Base *base_select, int int_op_type) @@ -521,24 +522,30 @@ int NewBooleanMesh(Base *base, Base *base_select, int int_op_type) int a, maxmat, totmat= 0; Object *ob_new, *ob, *ob_select; Material **mat; + DerivedMesh *result; + DerivedMesh *dm_select; DerivedMesh *dm; ob= base->object; ob_select= base_select->object; + dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH); + dm_select = mesh_create_derived_view(ob_select, 0); // no modifiers in editmode ?? + maxmat= ob->totcol + ob_select->totcol; mat= (Material**)MEM_mallocN(sizeof(Material*)*maxmat, "NewBooleanMeshMat"); /* put some checks in for nice user feedback */ - if((!(get_mesh(ob)->totface)) || (!(get_mesh(ob_select)->totface))) + if (dm == NULL || dm_select == NULL) return 0; + if (!dm->getNumFaces(dm) || !dm_select->getNumFaces(dm_select)) return 0; { MEM_freeN(mat); return -1; } - dm= NewBooleanDerivedMesh_intern(ob, ob_select, int_op_type, mat, &totmat); + result= NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, mat, &totmat); - if (dm == NULL) { + if (result == NULL) { MEM_freeN(mat); return 0; } @@ -547,8 +554,11 @@ int NewBooleanMesh(Base *base, Base *base_select, int int_op_type) ob_new= AddNewBlenderMesh(base_select); me_new= ob_new->data; - DM_to_mesh(dm, me_new); + DM_to_mesh(result, me_new); + result->release(result); + dm->release(dm); + dm_select->release(dm_select); /* add materials to object */ for (a = 0; a < totmat; a++) @@ -562,9 +572,9 @@ int NewBooleanMesh(Base *base, Base *base_select, int int_op_type) return 1; } -DerivedMesh *NewBooleanDerivedMesh(struct Object *ob, struct Object *ob_select, +DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, int int_op_type) { - return NewBooleanDerivedMesh_intern(ob, ob_select, int_op_type, NULL, NULL); + return NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, NULL, NULL); } -- cgit v1.2.3 From b36514a3be32f0d3a5f85557be54e7060c9099da Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Sun, 19 Apr 2009 18:18:52 +0000 Subject: Booleans: - Enable e.g. subsurf before boolean modifier - Fix editmode crash --- source/blender/blenkernel/intern/modifier.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 65bbbdfbcfb..7977e7b0160 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -6143,7 +6143,7 @@ static DerivedMesh *booleanModifier_applyModifier( DerivedMesh *dm = mesh_get_derived_final(bmd->object, CD_MASK_BAREMESH); /* we do a quick sanity check */ - if(derivedData->getNumFaces(derivedData) > 3 + if(dm && (derivedData->getNumFaces(derivedData) > 3) && bmd->object && dm->getNumFaces(dm) > 3) { DerivedMesh *result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, 1 + bmd->operation); @@ -8326,7 +8326,6 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(Boolean); mti->type = eModifierTypeType_Nonconstructive; mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_RequiresOriginalData | eModifierTypeFlag_UsesPointCache; mti->copyData = booleanModifier_copyData; mti->isDisabled = booleanModifier_isDisabled; -- cgit v1.2.3 From fcdbbee208fb64e9f0696843a69726de3c0d36b8 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 19 Apr 2009 21:26:29 +0000 Subject: SCons / epydoc support * properly detect if epydoc is installed. patch by Brandano --- source/blender/python/api2_2x/doc/SConscript | 40 +++++++++++++--------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/doc/SConscript b/source/blender/python/api2_2x/doc/SConscript index eca5d9a615c..4e2c72ba502 100644 --- a/source/blender/python/api2_2x/doc/SConscript +++ b/source/blender/python/api2_2x/doc/SConscript @@ -3,26 +3,22 @@ Import ('env') from optparse import OptionParser -try: - import epydoc -except ImportError: - print "No epydoc install detected, Python API Docs will not be generated " -if epydoc: - from epydoc.docbuilder import build_doc_index - from epydoc import cli - names = env.Glob("source/blender/python/api2_2x/doc/[A-Z]*.py") - docindex = build_doc_index(names) - optvalues = cli.OPTION_DEFAULTS - optvalues["verbose"] = 1 - optvalues["target"] = env["BF_DOCDIR"]+"/BPY_API/" - optvalues["url"] = "http://www.blender.org" - optvalues["top"] = "API_intro" - optvalues["name"] = "Blender" - optvalues["noprivate"] = 1 - optvalues["noframes"] = 1 - optvalues["names"] = names - optparser = OptionParser() - optparser.set_defaults(**optvalues) - (options, args) = optparser.parse_args([]) - cli.write_html(docindex, options) +import epydoc +from epydoc.docbuilder import build_doc_index +from epydoc import cli +names = env.Glob("source/blender/python/api2_2x/doc/[A-Z]*.py") +docindex = build_doc_index(names) +optvalues = cli.OPTION_DEFAULTS +optvalues["verbose"] = 1 +optvalues["target"] = env["BF_DOCDIR"]+"/BPY_API/" +optvalues["url"] = "http://www.blender.org" +optvalues["top"] = "API_intro" +optvalues["name"] = "Blender" +optvalues["noprivate"] = 1 +optvalues["noframes"] = 1 +optvalues["names"] = names +optparser = OptionParser() +optparser.set_defaults(**optvalues) +(options, args) = optparser.parse_args([]) +cli.write_html(docindex, options) -- cgit v1.2.3 From 9078ce5da209bcfd31c60b55118076359ce7244f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Apr 2009 22:02:48 +0000 Subject: Scons epydos changed options - no source code since this is only useful if the epydocs contain code, ours are only docstrings. - set inheritance to included so you dont have to search up the classes to find available functions. - SConstruct, isolate the exception for importing epydoc. - Added a print to the SConscript files otherwise it looks like nothings happening. --- source/blender/python/api2_2x/doc/SConscript | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/doc/SConscript b/source/blender/python/api2_2x/doc/SConscript index 4e2c72ba502..c95b844c1f4 100644 --- a/source/blender/python/api2_2x/doc/SConscript +++ b/source/blender/python/api2_2x/doc/SConscript @@ -10,6 +10,10 @@ names = env.Glob("source/blender/python/api2_2x/doc/[A-Z]*.py") docindex = build_doc_index(names) optvalues = cli.OPTION_DEFAULTS optvalues["verbose"] = 1 +optvalues["quiet"] = 0 +optvalues["include_source_code"] = 0 +optvalues["inheritance"] = "included" +optvalues["show_private"] = 0 optvalues["target"] = env["BF_DOCDIR"]+"/BPY_API/" optvalues["url"] = "http://www.blender.org" optvalues["top"] = "API_intro" @@ -20,5 +24,6 @@ optvalues["names"] = names optparser = OptionParser() optparser.set_defaults(**optvalues) (options, args) = optparser.parse_args([]) +print "Writing Blender Python epydocs to \"%s\"" % optvalues["target"] cli.write_html(docindex, options) -- cgit v1.2.3 From d76a6f5231c015c35123d22e1f5c3ffcdfbf9bbd Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Mon, 20 Apr 2009 13:18:54 +0000 Subject: Booleans: Fix for "no faces" error, reported by alxarch, thanks! --- source/blender/src/booleanops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/src/booleanops.c b/source/blender/src/booleanops.c index 948797014a4..c5b97e475a9 100644 --- a/source/blender/src/booleanops.c +++ b/source/blender/src/booleanops.c @@ -537,7 +537,7 @@ int NewBooleanMesh(Base *base, Base *base_select, int int_op_type) /* put some checks in for nice user feedback */ if (dm == NULL || dm_select == NULL) return 0; - if (!dm->getNumFaces(dm) || !dm_select->getNumFaces(dm_select)) return 0; + if (!dm->getNumFaces(dm) || !dm_select->getNumFaces(dm_select)) { MEM_freeN(mat); return -1; -- cgit v1.2.3